UserController { @RequestMapping(method = RequestMethod.GET) public ModelAndView handleRequest(@RequestParam(required = false, value = "q") String query) throws Exception { Model model = new ExtendedModelMap(); try { model.addAttribute(Constants.USER_LIST, userManager.search(query)); } catch (SearchException se) { model.addAttribute("searchError", se.getMessage()); model.addAttribute(userManager.getUsers()); } return new ModelAndView("admin/userList", model.asMap()); }  @Autowired void setUserManager(UserManager userManager); @RequestMapping(method = RequestMethod.GET) ModelAndView handleRequest(@RequestParam(required = false, value = "q") String query);  }
@Test public void testHandleRequest() throws Exception { mockMvc.perform(get("/admin/users")) .andExpect(status().isOk()) .andExpect(model().attributeExists(Constants.USER_LIST)) .andExpect(view().name("admin/userList")); }