### Question:
SimplePageController { @RequestMapping(value = "/pages/{pagePathName}/edit", method = RequestMethod.GET) public ModelAndView showEditPage(@PathVariable(PAGE_PATH_NAME) String pagePathName) throws NotFoundException { checkPermissionToCreateAndEditPage(); SimplePage page = simplePageService.getPageByPathName(pagePathName); SimplePageDto pageDto = new SimplePageDto(page); return new ModelAndView("simplePageEditor") .addObject(PAGE_DTO, pageDto); } @Autowired  SimplePageController(SimplePageService simplePageService, UserService userService); @InitBinder void initBinder(WebDataBinder binder); @RequestMapping(value = "/pages/{pagePathName}", method = RequestMethod.GET) ModelAndView showPage(@PathVariable(PAGE_PATH_NAME) String pagePathName); @RequestMapping(value = "/pages/{pagePathName}/edit", method = RequestMethod.GET) ModelAndView showEditPage(@PathVariable(PAGE_PATH_NAME) String pagePathName); @RequestMapping(value = "/pages/{pagePathName}/edit", method = RequestMethod.POST) ModelAndView update(@Valid @ModelAttribute SimplePageDto simplePageDto,
                               BindingResult result,
                               @PathVariable(PAGE_PATH_NAME) String pagePathName); @RequestMapping(value = "/pages/create/{pagePathName}", method = RequestMethod.GET) ModelAndView createPage(@PathVariable(PAGE_PATH_NAME) String pagePathName);  }### Answer:
@Test public void showEditPageTest() throws NotFoundException { SimplePage simplePage = new SimplePage(NAME, CONTENT, PATH_NAME); when(simplePageService.getPageByPathName(PATH_NAME)).thenReturn(simplePage); ModelAndView modelAndView = controller.showEditPage(PATH_NAME); verify(simplePageService).getPageByPathName(PATH_NAME); assertViewName(modelAndView, "simplePageEditor"); SimplePageDto actualSimplePage = assertAndReturnModelAttributeOfType(modelAndView, "simplePageDto", SimplePageDto.class); assertEqualsSimplePageAndSimplePageDto(actualSimplePage, simplePage); }
@Test (expectedExceptions = NotFoundException.class) public void showEditPageFailTest() throws NotFoundException { doThrow(new NotFoundException()).when(simplePageService).getPageByPathName(PATH_NAME); controller.showEditPage(PATH_NAME); }