@Test public void testRemoveUserById() throws Exception { long id = 1; mockMvc.perform(get("/admin/users/remove-user/" + id).accept(MediaType.APPLICATION_XHTML_XML)) .andExpect(redirectedUrl("/admin/users")) .andExpect(status().isFound()); verify(userService, times(1)) .removeUser(id); verifyNoMoreInteractions(userService); }
@RequestMapping("remove-user/{id}") public String removeUserById(@PathVariable Long id) { userService.removeUser(id); return "redirect:/admin/users"; }
AdminController { @RequestMapping("remove-user/{id}") public String removeUserById(@PathVariable Long id) { userService.removeUser(id); return "redirect:/admin/users"; } }
AdminController { @RequestMapping("remove-user/{id}") public String removeUserById(@PathVariable Long id) { userService.removeUser(id); return "redirect:/admin/users"; } @Autowired  AdminController(IUserService userService); }
AdminController { @RequestMapping("remove-user/{id}") public String removeUserById(@PathVariable Long id) { userService.removeUser(id); return "redirect:/admin/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("remove-user/{id}") public String removeUserById(@PathVariable Long id) { userService.removeUser(id); return "redirect:/admin/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);  }