@Test public void testSearch() throws Exception { // reindex before searching UserManager userManager = (UserManager) applicationContext.getBean("userManager"); userManager.reindex(); ModelAndView mav = c.handleRequest("admin"); Map m = mav.getModel(); List results = (List) m.get(Constants.USER_LIST); assertNotNull(results); assertTrue(results.size() >= 1); assertEquals("admin/userList", mav.getViewName()); }
@Test public void testSearch() throws Exception { // reindex before searching UserManager userManager = (UserManager) applicationContext.getBean("userManager"); userManager.reindex(); Map<String, Object> model = mockMvc .perform((get("/admin/users")).param("q", "admin")) .andExpect(status().isOk()) .andExpect(model().attributeExists(Constants.USER_LIST)) .andExpect(view().name("admin/userList")) .andReturn() .getModelAndView() .getModel(); List results = (List) model.get(Constants.USER_LIST); assertNotNull(results); assertTrue(results.size() >= 1); }