@Test public void testShowUsers() throws Exception { mockMvc.perform(get("/admin/users").accept(MediaType.APPLICATION_XHTML_XML)) .andExpect(view().name("show-users")) .andExpect(model().attributeExists("usersList")) .andExpect(status().isOk()); verify(userService, times(1)) .findAll(); verifyNoMoreInteractions(userService); }
@RequestMapping public String showUsers(Model model) { model.addAttribute("usersList", userService.findAll()); return "show-users"; }
AdminController { @RequestMapping public String showUsers(Model model) { model.addAttribute("usersList", userService.findAll()); return "show-users"; } }
AdminController { @RequestMapping public String showUsers(Model model) { model.addAttribute("usersList", userService.findAll()); return "show-users"; } @Autowired  AdminController(IUserService userService); }
AdminController { @RequestMapping public String showUsers(Model model) { model.addAttribute("usersList", userService.findAll()); return "show-users"; } @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 public String showUsers(Model model) { model.addAttribute("usersList", userService.findAll()); return "show-users"; } @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);  }