ConsentController extends AbstractController { @RequestMapping(value = "signConsentRevokation", method = RequestMethod.POST) public String signConsentRevokation(Model model, HttpServletRequest request, HttpServletResponse response, @RequestParam("consentId") String consentId, @RequestParam("revokationType") String revokationType) { final AuthenticatedUser currentUser = userContext.getCurrentUser(); final Long patientId = patientService.findIdByUsername(currentUser .getUsername()); final Long directConsentId = accessReferenceMapper .getDirectReference(consentId.substring(0, 6)); consentService.addUnsignedConsentRevokationPdf(directConsentId, revokationType); if (consentService .isConsentBelongToThisUser(directConsentId, patientId)) { final ConsentRevokationPdfDto consentRevokationPdfDto = consentService .findConsentRevokationPdfDto(directConsentId); consentRevokationPdfDto.setRevokationType(revokationType); final String javascriptCode = consentService .createRevocationEmbeddedWidget(consentRevokationPdfDto); model.addAttribute("returned_javascript", javascriptCode); return "views/consents/signConsent"; } return "redirect:listConsents.html"; }  @RequestMapping(value = "addConsent.html") String addConsent(Model model); @RequestMapping(value = "addConsentCheck.html") String addConsentCheck(Model model); @RequestMapping(value = "listConsents.html/checkConsentStatus", method = RequestMethod.GET) void ajaxCheckConsentStatus(Model model, HttpServletRequest request,
			HttpServletResponse response); @RequestMapping(value = "/callHippaSpace.html") String callHippaSpace(HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam("domain") String domain,
			@RequestParam("q") String query,
			@RequestParam("rt") String dataformat); @RequestMapping(value = "addConsent.html", method = RequestMethod.POST) @ResponseBody String consentAddPost(@Valid ConsentDto consentDto,
			BindingResult bindingResult, Model model,
			@RequestParam(value = "ICD9", required = false) HashSet<String> icd9); @RequestMapping(value = "listConsents.html") String consentMainPage(
			Model model,
			HttpServletRequest request,
			@RequestParam(value = "duplicateconsent", defaultValue = "-1") String duplicateConsentId); @RequestMapping(value = "editConsent.html") String consetEdit(
			@RequestParam(value = "patientId", defaultValue = "-1") long in_patientId,
			Model model, @RequestParam("consentId") String consentId); @RequestMapping(value = "/deleteConsents", method = RequestMethod.POST) String deleteConsent(@RequestParam("consentId") String consentId); @RequestMapping(value = "/downloadPdf.html", method = RequestMethod.POST) String downloadConsentPdfFile(HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam("consentId") String consentId,
			@RequestParam("doctype") String docType); @RequestMapping("exportCDAR2Consents/{consentId}") String exportCDAR2Consents(HttpServletRequest request,
			HttpServletResponse response,
			@PathVariable("consentId") String consentId); @RequestMapping("exportXACMLConsents/{consentId}") String exportXACMLConsents(HttpServletRequest request,
			HttpServletResponse response,
			@PathVariable("consentId") String consentId); @RequestMapping(value = "toEmail.html") String redirectToEmailLoginPage(); @RequestMapping(value = "validationModal.html") String redirectToValidationModal(); @RequestMapping(value = "signConsent.html", method = RequestMethod.POST) String signConsent(Model model, HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam("consentId") String consentId); @RequestMapping(value = "signConsentRevokation", method = RequestMethod.POST) String signConsentRevokation(Model model,
			HttpServletRequest request, HttpServletResponse response,
			@RequestParam("consentId") String consentId,
			@RequestParam("revokationType") String revokationType); @RequestMapping(value = "tryMyPolicyApply/consentId/{consentId}/c32Id/{c32Id}/purposeOfUse/{purposeOfUse}", method = RequestMethod.GET) @ResponseBody String tryMyPolicyApply(Model model,
			HttpServletRequest request, HttpServletResponse response,
			@PathVariable("consentId") String consentId,
			@PathVariable("c32Id") Long c32Id,
			@PathVariable("purposeOfUse") String purposeOfUse); @SuppressWarnings("unchecked") @RequestMapping(value = "tryMyPolicyLookupC32Documents/{consentId}", method = RequestMethod.GET) @ResponseBody TryMyPolicyDto tryMyPolicyLookupC32Documents(
			Model model, HttpServletRequest request,
			HttpServletResponse response,
			@PathVariable("consentId") String consentId); final static Long SAMPLE_C32_ID; final String C32_DOC_CODE; }
@Test public void testSignConsentRevokation_when_authentication_fails() throws Exception { ConsentRevokationPdfDto consentRevokationPdfDto = mock(ConsentRevokationPdfDto.class); when(consentService.findConsentRevokationPdfDto(anyLong())).thenReturn( consentRevokationPdfDto); when(consentService.isConsentBelongToThisUser(anyLong(), anyLong())) .thenReturn(false); mockMvc.perform( post("/consents/signConsentRevokation").param("consentId", "ScrambledText").param("revokationType", "NO NEVER")) .andExpect(view().name("redirect:listConsents.html")); verify(consentService, never()).signConsentRevokation( consentRevokationPdfDto); }