@Test public void testFindOneHandler() throws NotFoundException { final ExtendedModelMap model = new ExtendedModelMap(); String viewName = userController.show(1L, model); User user = (User) model.get("user"); assertNotNull(user); assertEquals(Long.valueOf(1), user.getId()); assertEquals("users/show", viewName); }
@RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) public String show(@PathVariable Long id, Model model) throws NotFoundException { final User user = userService.findById(id); if (user == null) { throw new NotFoundException(User.class, id); } model.addAttribute("user", user); return "users/show"; }
UserController { @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) public String show(@PathVariable Long id, Model model) throws NotFoundException { final User user = userService.findById(id); if (user == null) { throw new NotFoundException(User.class, id); } model.addAttribute("user", user); return "users/show"; } }
UserController { @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) public String show(@PathVariable Long id, Model model) throws NotFoundException { final User user = userService.findById(id); if (user == null) { throw new NotFoundException(User.class, id); } model.addAttribute("user", user); return "users/show"; }  }
UserController { @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) public String show(@PathVariable Long id, Model model) throws NotFoundException { final User user = userService.findById(id); if (user == null) { throw new NotFoundException(User.class, id); } model.addAttribute("user", user); return "users/show"; }  @Autowired void setUserService(UserService userService); @RequestMapping(value = "/list", method = RequestMethod.GET) String list(Model model); @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) String show(@PathVariable Long id, Model model); }
UserController { @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) public String show(@PathVariable Long id, Model model) throws NotFoundException { final User user = userService.findById(id); if (user == null) { throw new NotFoundException(User.class, id); } model.addAttribute("user", user); return "users/show"; }  @Autowired void setUserService(UserService userService); @RequestMapping(value = "/list", method = RequestMethod.GET) String list(Model model); @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) String show(@PathVariable Long id, Model model);  }