### Question:
MessagesController extends AbstractController { @RequestMapping("/messages/{type}/{name}/edit") public ModelAndView showEditPage(final Model model, @PathVariable String type, @PathVariable String name) { model.addAttribute("message", messageService.getMessageByTypeAndName(MessageType.valueOf(type.toUpperCase()), name)); return new ModelAndView("messages/edit"); } MessagesController(final MessageService messageService); @RequestMapping("/messages") ModelAndView showAllMessagesPage(final Model model); @RequestMapping("/messages/{type}") ModelAndView showMessagesOfTypePage(final Model model, @PathVariable String type); @RequestMapping("/messages/{type}/add") ModelAndView showAddMessageToTypePage(final Model model, @PathVariable String type); @RequestMapping("/messages/{type}/{name}/edit") ModelAndView showEditPage(final Model model, @PathVariable String type, @PathVariable String name); @PostMapping("/messages/{type}/add") ModelAndView add(WebRequest request, @PathVariable String type, RedirectAttributes redirectAttributes); @PostMapping("/messages/{type}/{name}/edit") ModelAndView update(WebRequest request, @PathVariable String type, @PathVariable String name, RedirectAttributes redirectAttributes); @PostMapping("/messages/{type}/{name}/delete") ModelAndView delete(final Model model, @PathVariable String type, @PathVariable String name, RedirectAttributes redirectAttributes);  }### Answer:
@Test public void showEditPage() throws Exception { String type = MessageType.REFERRAL_SHARE.toString(); String name = "name"; MessageDto messageDto = mock(MessageDto.class); when(messageService.getMessageByTypeAndName(MessageType.REFERRAL_SHARE, name)).thenReturn(messageDto); this.mockMvc.perform(get("/messages/{type}/{name}/edit", type, name)) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.model().attribute("message", messageDto)) .andExpect(MockMvcResultMatchers.view().name("messages/edit")); }