@Test public void shouldSearchProgramProducts() { when(service.search(anyString(), Matchers.any(Pagination.class), anyString())).thenReturn(expectedProgramProductList); when(service.getTotalSearchResultCount("pro", "Program")).thenReturn(20); InOrder order = inOrder(service); ResponseEntity<OpenLmisResponse> programProducts = controller.getByProgram(1, "pro", "Program", "10"); order.verify(service).getTotalSearchResultCount("pro", "Program"); order.verify(service).search(anyString(), Matchers.any(Pagination.class), anyString()); assertThat((List<ProgramProduct>) programProducts.getBody().getData().get(PROGRAM_PRODUCT_LIST), is(expectedProgramProductList)); }
@RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getByProgram(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "searchParam", required = true) String searchParam, @RequestParam(value = "column", required = true, defaultValue = "product") String column, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<ProgramProduct> programProductList = service.search(searchParam, pagination, column); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(PROGRAM_PRODUCT_LIST, programProductList); response.getBody().addData("pagination", pagination); return response; }
ProgramProductController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getByProgram(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "searchParam", required = true) String searchParam, @RequestParam(value = "column", required = true, defaultValue = "product") String column, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<ProgramProduct> programProductList = service.search(searchParam, pagination, column); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(PROGRAM_PRODUCT_LIST, programProductList); response.getBody().addData("pagination", pagination); return response; } }
ProgramProductController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getByProgram(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "searchParam", required = true) String searchParam, @RequestParam(value = "column", required = true, defaultValue = "product") String column, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<ProgramProduct> programProductList = service.search(searchParam, pagination, column); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(PROGRAM_PRODUCT_LIST, programProductList); response.getBody().addData("pagination", pagination); return response; }  }
ProgramProductController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getByProgram(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "searchParam", required = true) String searchParam, @RequestParam(value = "column", required = true, defaultValue = "product") String column, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<ProgramProduct> programProductList = service.search(searchParam, pagination, column); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(PROGRAM_PRODUCT_LIST, programProductList); response.getBody().addData("pagination", pagination); return response; }  @RequestMapping(value = "/programId/{programId}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") ResponseEntity<OpenLmisResponse> getProgramProductsByProgram(@PathVariable Long programId); @RequestMapping(value = "/filter/programId/{programId}/facilityTypeId/{facilityTypeId}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_FACILITY_APPROVED_PRODUCT')") List<ProgramProduct> getUnapprovedProgramProducts(@PathVariable(value = "facilityTypeId") Long facilityTypeId,
                                                           @PathVariable(value = "programId") Long programId); @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> getByProgram(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                                       @RequestParam(value = "searchParam", required = true) String searchParam,
                                                       @RequestParam(value = "column", required = true, defaultValue = "product") String column,
                                                       @Value("${search.page.size}") String limit); @RequestMapping(value = "/{programProductId}/isa", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") void insertIsa(@PathVariable Long programProductId,
                        @RequestBody ProgramProductISA programProductISA,
                        HttpServletRequest request); @RequestMapping(value = "/{programProductId}/isa/{isaId}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") void updateIsa(@PathVariable Long isaId,
            @PathVariable Long programProductId,
            @RequestBody ProgramProductISA programProductISA,
            HttpServletRequest request); }
ProgramProductController extends BaseController { @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getByProgram(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "searchParam", required = true) String searchParam, @RequestParam(value = "column", required = true, defaultValue = "product") String column, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<ProgramProduct> programProductList = service.search(searchParam, pagination, column); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(PROGRAM_PRODUCT_LIST, programProductList); response.getBody().addData("pagination", pagination); return response; }  @RequestMapping(value = "/programId/{programId}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") ResponseEntity<OpenLmisResponse> getProgramProductsByProgram(@PathVariable Long programId); @RequestMapping(value = "/filter/programId/{programId}/facilityTypeId/{facilityTypeId}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_FACILITY_APPROVED_PRODUCT')") List<ProgramProduct> getUnapprovedProgramProducts(@PathVariable(value = "facilityTypeId") Long facilityTypeId,
                                                           @PathVariable(value = "programId") Long programId); @RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> getByProgram(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                                       @RequestParam(value = "searchParam", required = true) String searchParam,
                                                       @RequestParam(value = "column", required = true, defaultValue = "product") String column,
                                                       @Value("${search.page.size}") String limit); @RequestMapping(value = "/{programProductId}/isa", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") void insertIsa(@PathVariable Long programProductId,
                        @RequestBody ProgramProductISA programProductISA,
                        HttpServletRequest request); @RequestMapping(value = "/{programProductId}/isa/{isaId}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") void updateIsa(@PathVariable Long isaId,
            @PathVariable Long programProductId,
            @RequestBody ProgramProductISA programProductISA,
            HttpServletRequest request);  }