### Question:
UserController { @RequestMapping(value = "/admin/users/search", method = RequestMethod.GET) public String searchUsers(@RequestParam(required = true) String searchTerm, @RequestParam(required = false, defaultValue = "0") int offset, @RequestParam(required = false) String referringPageId,Model model) { model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId); addNavigationMenusToModel(SELECTED_ITEM, model, referringPageId); final SearchResult<User> users = userService.getUsersByFreeTextSearch( searchTerm, offset, getPageSize()); model.addAttribute(ModelKeys.SEARCH_TERM, searchTerm); model.addAttribute(ModelKeys.SEARCHRESULT, users); return ViewNames.ADMIN_USERS; }  @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 searchUsers() throws Exception { Model model = new ExtendedModelMap(); final String searchTerm = "Doe"; final int offset = 0; final int pageSize = 10; SearchResult<User> searchResult = createSearchResultWithTwoUsers(); expect(userService.getUsersByFreeTextSearch(searchTerm, offset, pageSize)).andReturn(searchResult); replay(userService); String adminUsersView = controller.searchUsers(searchTerm, offset,REFERRER_ID, model); assertEquals(ViewNames.ADMIN_USERS, adminUsersView); assertEquals(searchResult, model.asMap().get(ModelKeys.SEARCHRESULT)); assertEquals(searchTerm, model.asMap().get(ModelKeys.SEARCH_TERM)); assertTrue(model.containsAttribute(TABS)); assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID))); }