@Test public void testUserDetail() throws Exception { long id = 1; mockMvc.perform(get("/admin/users/" + id).accept(MediaType.APPLICATION_XHTML_XML)) .andExpect(view().name("user-detail")) .andExpect(model().errorCount(0)) .andExpect(status().isOk()); verify(userService, times(1)) .findOneWithAllBlogs(id); verifyNoMoreInteractions(userService); }
@RequestMapping("{id}") public String userDetail(@PathVariable Long id, Model model) { model.addAttribute("user", userService.findOneWithAllBlogs(id)); return "user-detail"; }
AdminController { @RequestMapping("{id}") public String userDetail(@PathVariable Long id, Model model) { model.addAttribute("user", userService.findOneWithAllBlogs(id)); return "user-detail"; } }
AdminController { @RequestMapping("{id}") public String userDetail(@PathVariable Long id, Model model) { model.addAttribute("user", userService.findOneWithAllBlogs(id)); return "user-detail"; } @Autowired  AdminController(IUserService userService); }
AdminController { @RequestMapping("{id}") public String userDetail(@PathVariable Long id, Model model) { model.addAttribute("user", userService.findOneWithAllBlogs(id)); return "user-detail"; } @Autowired  AdminController(IUserService userService); @RequestMapping String showUsers(Model model); @RequestMapping("{id}") String userDetail(@PathVariable Long id, Model model); @RequestMapping("remove-user/{id}") String removeUserById(@PathVariable Long id); }
AdminController { @RequestMapping("{id}") public String userDetail(@PathVariable Long id, Model model) { model.addAttribute("user", userService.findOneWithAllBlogs(id)); return "user-detail"; } @Autowired  AdminController(IUserService userService); @RequestMapping String showUsers(Model model); @RequestMapping("{id}") String userDetail(@PathVariable Long id, Model model); @RequestMapping("remove-user/{id}") String removeUserById(@PathVariable Long id);  }