### Question:
UserController { @RequestMapping(value = "/admin/userdetail/{userid}", method = RequestMethod.GET) public String viewUserDetail(@PathVariable("userid") String userid, @RequestParam(required = false) String referringPageId, Model model) { model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId); addNavigationMenusToModel(SELECTED_ITEM, model,referringPageId ); model.addAttribute(ModelKeys.USER, userService.getUserById(userid)); model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken()); return ViewNames.ADMIN_USERDETAIL; }  @InitBinder(value = {"user"}) void initBinder(WebDataBinder dataBinder); @RequestMapping(value = {"/admin/users"}, method = RequestMethod.GET) String viewUsers(@RequestParam(required = false, defaultValue = "0") int offset,
                            @RequestParam(required = false) final String action,
                            @RequestParam(required = false) String referringPageId,
                            Model model); @RequestMapping(value = "/admin/users/search", method = RequestMethod.GET) String searchUsers(@RequestParam(required = true) String searchTerm,
                              @RequestParam(required = false, defaultValue = "0") int offset,
                              @RequestParam(required = false) String referringPageId,Model model); @RequestMapping(value = "/admin/userdetail/{userid}", method = RequestMethod.GET) String viewUserDetail(@PathVariable("userid") String userid,
                                 @RequestParam(required = false) String referringPageId,
                                 Model model); @RequestMapping(value = "/admin/userdetail/update", method = RequestMethod.POST) String updateUserDetail(@ModelAttribute User user, BindingResult result,
                                   @ModelAttribute(ModelKeys.TOKENCHECK) String sessionToken,
                                   @RequestParam() String token,
                                   @RequestParam(required = false) String referringPageId,
                                   ModelMap modelMap,
                                   SessionStatus status); @RequestMapping(value = "/admin/userdetail/delete", method = RequestMethod.POST) String deleteUserDetail(@ModelAttribute User user,
                                   @ModelAttribute(ModelKeys.TOKENCHECK) String sessionToken,
                                   @RequestParam String token,
                                   @RequestParam(required = false) String confirmdelete,
                                   @RequestParam(required = false) String referringPageId,
                                   ModelMap modelMap,
                                   SessionStatus status); @RequestMapping(method = RequestMethod.GET, value = {"/admin/adduser"}) String setUpForm(ModelMap model, @RequestParam(required = false) String referringPageId); @RequestMapping(value = {"/admin/newaccount", "/admin/newaccount/*"}, method = RequestMethod.POST) String create(@ModelAttribute(value = "newUser") UserForm newUser, BindingResult results, Model model,
                         @RequestParam(required = false) String referringPageId,
                         RedirectAttributes redirectAttributes); @ModelAttribute("authorities") SearchResult<Authority> populateAuthorityList(); @ModelAttribute("loggedInUser") String populateLoggedInUsername(); int getPageSize();  }### Answer:
@Test public void viewAdminUserDetail() throws Exception { Model model = new ExtendedModelMap(); String userid = "123"; User user = new UserImpl(userid, "john.doe.sr"); expect(userService.getUserById(userid)).andReturn(user); replay(userService); String adminUserDetailView = controller.viewUserDetail(userid,REFERRER_ID, model); verify(userService); assertEquals(ViewNames.ADMIN_USERDETAIL, adminUserDetailView); assertTrue(model.containsAttribute(TABS)); assertEquals(user, model.asMap().get("user")); assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID))); }