I have written Rest controller as follows:
@RestController
public class RegisterRestController {
@RequestMapping(value = "/create", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public RegisterResponseObject createProspect(
@Valid @RequestBody ProfileBean profileBean) throws Exception {
//If validation passes do something
}
}
Here, if validation fails I am handling exception in Controller advice and sending error object back to client.
How to test this controller with JUnit for validation erros.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire