LegalRepresentativeController { @RequestMapping("connectionMain/deleteLegalRep/{legalRepId}") public String deleteLegalRep(@PathVariable("legalRepId") Long legalRepId) { if (patientService.isLegalRepForCurrentUser(legalRepId)) { patientLegalRepresentativeAssociationService .deletePatientLegalRepresentativeById(legalRepId); return "redirect:/patients/connectionMain.html"; } return "views/resourceNotFound"; }  @RequestMapping(value = "connectionMain.html", method = RequestMethod.POST) ModelAndView addLegalRepresentative(
			@Valid LegalRepresentativeDto newLegalRepresentativeDto,
			BindingResult result, HttpServletResponse response, Model model); @RequestMapping(value = "connectionMain/editLegalRepresenttive/{legalRepId}", method = RequestMethod.POST) ModelAndView editLegalRepresentative(
			@Valid LegalRepresentativeDto newLegalRepresentativeDto,
			BindingResult result, @PathVariable("legalRepId") Long legalRepId,
			HttpServletResponse response, Model model); @RequestMapping("connectionMain/deleteLegalRep/{legalRepId}") String deleteLegalRep(@PathVariable("legalRepId") Long legalRepId);  }
@Test public void testDeleteLegalRep() throws Exception { when(patientService.isLegalRepForCurrentUser((long) 10)).thenReturn( true); mockMvc.perform(get("/patients/connectionMain/deleteLegalRep/10")) .andExpect(redirectedUrl("/patients/connectionMain.html")); mockMvc.perform(get("/patients/connectionMain/deleteLegalRep/9")) .andExpect(view().name("views/resourceNotFound")); }