@Test public void shouldSearchSupplyLines() throws Exception { String searchParam = "supply"; String column = "name"; Integer page = 2; String limit = "10"; List<SupplyLine> supplyLines = asList(new SupplyLine()); Pagination pagination = new Pagination(2, 3); whenNew(Pagination.class).withArguments(page, Integer.parseInt(limit)).thenReturn(pagination); when(service.search(searchParam, column, pagination)).thenReturn(supplyLines); when(service.getTotalSearchResultCount(searchParam, column)).thenReturn(3); ResponseEntity<OpenLmisResponse> response = controller.search(searchParam, column, page, limit); assertThat((List<SupplyLine>) response.getBody().getData().get(SUPPLY_LINES), is(supplyLines)); assertThat((Pagination) response.getBody().getData().get(PAGINATION), is(pagination)); }
@RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "column") String column, @RequestParam(value = "page", defaultValue = "1") Integer page, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<SupplyLine> supplyLines = service.search(searchParam, column, pagination); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(SUPPLY_LINES, supplyLines); response.getBody().addData(PAGINATION, pagination); return response; }
SupplyLineController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "column") String column, @RequestParam(value = "page", defaultValue = "1") Integer page, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<SupplyLine> supplyLines = service.search(searchParam, column, pagination); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(SUPPLY_LINES, supplyLines); response.getBody().addData(PAGINATION, pagination); return response; } }
SupplyLineController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "column") String column, @RequestParam(value = "page", defaultValue = "1") Integer page, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<SupplyLine> supplyLines = service.search(searchParam, column, pagination); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(SUPPLY_LINES, supplyLines); response.getBody().addData(PAGINATION, pagination); return response; }  }
SupplyLineController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "column") String column, @RequestParam(value = "page", defaultValue = "1") Integer page, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<SupplyLine> supplyLines = service.search(searchParam, column, pagination); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(SUPPLY_LINES, supplyLines); response.getBody().addData(PAGINATION, pagination); return response; }  @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam,
                                                 @RequestParam(value = "column") String column,
                                                 @RequestParam(value = "page", defaultValue = "1") Integer page,
                                                 @Value("${search.page.size}") String limit); @RequestMapping(method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") ResponseEntity<OpenLmisResponse> insert(@RequestBody SupplyLine supplyLine,
                                                 HttpServletRequest request); @RequestMapping(value = "/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") ResponseEntity<OpenLmisResponse> update(@RequestBody SupplyLine supplyLine,
                                                 @PathVariable(value = "id") Long supervisoryNodeId,
                                                 HttpServletRequest request); @RequestMapping(value = "/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") SupplyLine getById(@PathVariable(value = "id") Long id); @RequestMapping(value = "/supplying-depots.json", method = GET, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> getSupplyingDepots(HttpServletRequest request); }
SupplyLineController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "column") String column, @RequestParam(value = "page", defaultValue = "1") Integer page, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<SupplyLine> supplyLines = service.search(searchParam, column, pagination); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(SUPPLY_LINES, supplyLines); response.getBody().addData(PAGINATION, pagination); return response; }  @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam,
                                                 @RequestParam(value = "column") String column,
                                                 @RequestParam(value = "page", defaultValue = "1") Integer page,
                                                 @Value("${search.page.size}") String limit); @RequestMapping(method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") ResponseEntity<OpenLmisResponse> insert(@RequestBody SupplyLine supplyLine,
                                                 HttpServletRequest request); @RequestMapping(value = "/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") ResponseEntity<OpenLmisResponse> update(@RequestBody SupplyLine supplyLine,
                                                 @PathVariable(value = "id") Long supervisoryNodeId,
                                                 HttpServletRequest request); @RequestMapping(value = "/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SUPPLY_LINE')") SupplyLine getById(@PathVariable(value = "id") Long id); @RequestMapping(value = "/supplying-depots.json", method = GET, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> getSupplyingDepots(HttpServletRequest request); static final String SUPPLY_LINES; static final String PAGINATION; static final String SUPPLYLINES; static final String SUPPLY_LINE_ID; }