I have written a simple method in my controller as part of my Java Spring Boot Application which works without issue using and I have tested it using Postman. However I am unsure how to unit test this using Junit and Mockito. I have shown a snippet of my code below, first is my Controller.java class and then my test is within a ControllerTest.java. How can I unit test this correctly?
EDIT: I know my test case is the problem, I have removed it as all comments are focusing on why it is wrong. I am asking how do I write a unit test case for this specific saveCase method.
I have already tried looking at examples from below links Rest Controller Unit Test Spring RestController + Junit Testing
@Autowired
Service service;
@PostMapping("/savecase")
public ResponseEntity<PIECase> saveCase(@Valid @RequestBody PIECase pieCase) {
return ResponseEntity.ok(pieService.saveCase(pieCase));
}