@Test public void testRemoveBlog() throws Exception { Long id = 5L; RssFeedEntity rssFeedEntity = new RssFeedEntity(); when(blogService.findOne(id)).thenReturn(rssFeedEntity); mockMvc.perform(get("/blog/remove/" + id).accept(MediaType.APPLICATION_XHTML_XML)) .andExpect(redirectedUrl("/account")) .andExpect(status().isFound()); verify(blogService, times(1)) .findOne(id); verifyNoMoreInteractions(userService); }
@RequestMapping(value = "blog/remove/{id}") public String removeBlog(@PathVariable Long id) { RssFeedEntity rssFeedEntity = blogService.findOne(id); blogService.delete(rssFeedEntity); return "redirect:/account"; }
UserController { @RequestMapping(value = "blog/remove/{id}") public String removeBlog(@PathVariable Long id) { RssFeedEntity rssFeedEntity = blogService.findOne(id); blogService.delete(rssFeedEntity); return "redirect:/account"; } }
UserController { @RequestMapping(value = "blog/remove/{id}") public String removeBlog(@PathVariable Long id) { RssFeedEntity rssFeedEntity = blogService.findOne(id); blogService.delete(rssFeedEntity); return "redirect:/account"; } @Autowired  UserController(IUserService userService, IRssFeedService blogService); }
UserController { @RequestMapping(value = "blog/remove/{id}") public String removeBlog(@PathVariable Long id) { RssFeedEntity rssFeedEntity = blogService.findOne(id); blogService.delete(rssFeedEntity); return "redirect:/account"; } @Autowired  UserController(IUserService userService, IRssFeedService blogService); @RequestMapping("account") String account(Model model, Principal principal); @RequestMapping(value = "account", method = RequestMethod.POST) String doAddBlog(@Valid @ModelAttribute("blog") RssFeedEntity rssFeedEntity, Model model,
                            Principal principal, BindingResult result); @RequestMapping(value = "blog/remove/{id}") String removeBlog(@PathVariable Long id); }
UserController { @RequestMapping(value = "blog/remove/{id}") public String removeBlog(@PathVariable Long id) { RssFeedEntity rssFeedEntity = blogService.findOne(id); blogService.delete(rssFeedEntity); return "redirect:/account"; } @Autowired  UserController(IUserService userService, IRssFeedService blogService); @RequestMapping("account") String account(Model model, Principal principal); @RequestMapping(value = "account", method = RequestMethod.POST) String doAddBlog(@Valid @ModelAttribute("blog") RssFeedEntity rssFeedEntity, Model model,
                            Principal principal, BindingResult result); @RequestMapping(value = "blog/remove/{id}") String removeBlog(@PathVariable Long id);  }