I want to test the response of my request.
I have a controller like this,
@RequestMapping("/user")
public class StandardController(@RequestBody Object body) {
@PostMapping(path=/info")
public ResponseEntity<String> getUserInfo(@Validated @RequestBody CustomDTO customDTO) throws customException {
try {
//process something with customDTO
} catch (Exception e) {
//throw exception
}
}
}
Now I have made one of the properties of CustomDTO
as @NotNull
. When I test the endpoint through Postman I will successfully get 400 as expected if I supply the required field as null value. But how do I test this scenario with Mockito?