@Test public void testSearchEverythingWithPaging() { SearchResults<Ninja> expected = new SearchResults<Ninja>(pageSize, numLinks); expected.addResults(new Ninja()); Mockito.when(ninjaService.search(null, 1)).thenReturn(expected); SearchResults<Ninja> results = ninjaCrudController.search(null, mockRequest); Mockito.verify(ninjaService).search(null, 1); assertNotNull(results); assertEquals(expected.getTotalResults(), results.getTotalResults()); assertNotNull(results.getSearchTime()); }
@RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) public final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); return results; }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) public final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); return results; } }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) public final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); return results; }  }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) public final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); return results; }  @ExceptionHandler(Exception.class) @ResponseBody Map<String, Object> handleBindException(Exception ex,
			HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) final String searchHtml(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"", "0"}, method = RequestMethod.POST, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> create(@FormBind(name = "formCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = { RequestMethod.PUT, RequestMethod.POST }, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> update(@FormBind(name = "formCommand") T command,
			@PathVariable("id") Long id, BindingResult bindingResult,
			Model uiModel, HttpServletRequest request,
			HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody T get(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); void preProcessCommand(T command); @RequestMapping(value = "{id}", method = RequestMethod.GET) String getHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/view/{id}", method = RequestMethod.GET) String getDisplayHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.DELETE, produces = "application/json") final @ResponseBody Map<String, Object> delete(@PathVariable("id") Long id, T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @SuppressWarnings({ "unchecked" }) @Override void afterPropertiesSet(); final BaseCrudService<T> getService(); }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) public final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); return results; }  @ExceptionHandler(Exception.class) @ResponseBody Map<String, Object> handleBindException(Exception ex,
			HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) final String searchHtml(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"", "0"}, method = RequestMethod.POST, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> create(@FormBind(name = "formCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = { RequestMethod.PUT, RequestMethod.POST }, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> update(@FormBind(name = "formCommand") T command,
			@PathVariable("id") Long id, BindingResult bindingResult,
			Model uiModel, HttpServletRequest request,
			HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody T get(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); void preProcessCommand(T command); @RequestMapping(value = "{id}", method = RequestMethod.GET) String getHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/view/{id}", method = RequestMethod.GET) String getDisplayHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.DELETE, produces = "application/json") final @ResponseBody Map<String, Object> delete(@PathVariable("id") Long id, T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @SuppressWarnings({ "unchecked" }) @Override void afterPropertiesSet(); final BaseCrudService<T> getService();  }