### Question:
PersonController extends AbstractController { @RequestMapping(value = "/person/delete/{id}", method = RequestMethod.GET) public String delete(@PathVariable("id") Long id, RedirectAttributes attributes) { LOGGER.debug("Deleting person with id: " + id); try { Person deleted = personService.delete(id); addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_PERSON_DELETED, deleted.getName()); } catch (PersonNotFoundException e) { LOGGER.debug("No person found with id: " + id); addErrorMessage(attributes, ERROR_MESSAGE_KEY_DELETED_PERSON_WAS_NOT_FOUND); } return createRedirectViewPath(REQUEST_MAPPING_LIST); }  @RequestMapping(value="/person/count", method = RequestMethod.POST) @ResponseBody Long count(@RequestBody SearchDTO searchCriteria); @RequestMapping(value = "/person/delete/{id}", method = RequestMethod.GET) String delete(@PathVariable("id") Long id, RedirectAttributes attributes); @RequestMapping(value = "/person/search/page", method = RequestMethod.POST) @ResponseBody List<PersonDTO> search(@RequestBody SearchDTO searchCriteria); @RequestMapping(value = "/person/create", method = RequestMethod.GET) String showCreatePersonForm(Model model); @RequestMapping(value = "/person/create", method = RequestMethod.POST) String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes); @RequestMapping(value = "/person/edit/{id}", method = RequestMethod.GET) String showEditPersonForm(@PathVariable("id") Long id, Model model, RedirectAttributes attributes); @RequestMapping(value = "/person/edit", method = RequestMethod.POST) String submitEditPersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO updated, BindingResult bindingResult, RedirectAttributes attributes); @RequestMapping(value = REQUEST_MAPPING_LIST, method = RequestMethod.GET) String showList(Model model); @RequestMapping(value = "/person/search", method=RequestMethod.POST) String showSearchResultPage(@ModelAttribute(MODEL_ATTRIBUTE_SEARCH_CRITERIA) SearchDTO searchCriteria, Model model);  }### Answer:
@Test public void delete() throws PersonNotFoundException { Person deleted = PersonTestUtil.createModelObject(PERSON_ID, FIRST_NAME, LAST_NAME); when(personServiceMock.delete(PERSON_ID)).thenReturn(deleted); initMessageSourceForFeedbackMessage(PersonController.FEEDBACK_MESSAGE_KEY_PERSON_DELETED); RedirectAttributes attributes = new RedirectAttributesModelMap(); String view = controller.delete(PERSON_ID, attributes); verify(personServiceMock, times(1)).delete(PERSON_ID); verifyNoMoreInteractions(personServiceMock); assertFeedbackMessage(attributes, PersonController.FEEDBACK_MESSAGE_KEY_PERSON_DELETED); String expectedView = createExpectedRedirectViewPath(PersonController.REQUEST_MAPPING_LIST); assertEquals(expectedView, view); }
@Test public void deleteWhenPersonIsNotFound() throws PersonNotFoundException { when(personServiceMock.delete(PERSON_ID)).thenThrow(new PersonNotFoundException()); initMessageSourceForErrorMessage(PersonController.ERROR_MESSAGE_KEY_DELETED_PERSON_WAS_NOT_FOUND); RedirectAttributes attributes = new RedirectAttributesModelMap(); String view = controller.delete(PERSON_ID, attributes); verify(personServiceMock, times(1)).delete(PERSON_ID); verifyNoMoreInteractions(personServiceMock); assertErrorMessage(attributes, PersonController.ERROR_MESSAGE_KEY_DELETED_PERSON_WAS_NOT_FOUND); String expectedView = createExpectedRedirectViewPath(PersonController.REQUEST_MAPPING_LIST); assertEquals(expectedView, view); }