I've defined this method in my Spring MVC Controller
@PreAuthorize("isAuthenticated() and hasPermission(#request, 'CREATE_REQUISITION')")
@RequestMapping(method = RequestMethod.POST, value = "/trade/createrequisition")
public @ResponseBody
void createRequisition(@RequestBody CreateRequisitionRO[] request,
@RequestHeader("validateOnly") boolean validateOnly) {
.....
}
Then in my TestNG test I'd like to call this method and ensure that the PreAuthorize condition is verified. when I call this method in a normal way (not testing), the PreAuthorize is verified.
If it's possible, how to test this annotation in a TestNG test and how to catch the exception if it throws one ?
Best Regards