@Test public void shouldSearchRequisitionGroup() throws Exception { String searchParam = "searchParam"; String columnName = "columnName"; Integer pageNumber = 1; Integer pageSize = 10; List<RequisitionGroup> requisitionGroups = asList(new RequisitionGroup()); when(staticReferenceDataService.getPropertyValue(SEARCH_PAGE_SIZE)).thenReturn(String.valueOf(pageSize)); Pagination pagination = new Pagination(pageNumber, pageSize); whenNew(Pagination.class).withArguments(pageNumber, pageSize).thenReturn(pagination); when(requisitionGroupService.search(searchParam, columnName, pagination)).thenReturn(requisitionGroups); when(requisitionGroupService.getTotalRecords(searchParam, columnName)).thenReturn(5); ResponseEntity<OpenLmisResponse> response = requisitionGroupController.search(searchParam, columnName, pageNumber); verify(requisitionGroupService).search(searchParam, columnName, pagination); verify(staticReferenceDataService).getPropertyValue(SEARCH_PAGE_SIZE); assertThat(response.getStatusCode(), is(HttpStatus.OK)); assertThat((List<RequisitionGroup>) response.getBody().getData().get("requisitionGroupList"), is(requisitionGroups)); pagination.setTotalRecords(5); assertThat((Pagination) response.getBody().getData().get("pagination"), is(pagination)); }
@RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "columnName") String columnName, @RequestParam(value = "page", defaultValue = "1") Integer page) { Integer pageSize = Integer.parseInt(staticReferenceDataService.getPropertyValue(SEARCH_PAGE_SIZE)); Pagination pagination = new Pagination(page, pageSize); List<RequisitionGroup> requisitionGroupList = requisitionGroupService.search(searchParam, columnName, pagination); pagination.setTotalRecords(requisitionGroupService.getTotalRecords(searchParam, columnName)); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response("requisitionGroupList", requisitionGroupList); response.getBody().addData("pagination", pagination); return response; }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "columnName") String columnName, @RequestParam(value = "page", defaultValue = "1") Integer page) { Integer pageSize = Integer.parseInt(staticReferenceDataService.getPropertyValue(SEARCH_PAGE_SIZE)); Pagination pagination = new Pagination(page, pageSize); List<RequisitionGroup> requisitionGroupList = requisitionGroupService.search(searchParam, columnName, pagination); pagination.setTotalRecords(requisitionGroupService.getTotalRecords(searchParam, columnName)); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response("requisitionGroupList", requisitionGroupList); response.getBody().addData("pagination", pagination); return response; } }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "columnName") String columnName, @RequestParam(value = "page", defaultValue = "1") Integer page) { Integer pageSize = Integer.parseInt(staticReferenceDataService.getPropertyValue(SEARCH_PAGE_SIZE)); Pagination pagination = new Pagination(page, pageSize); List<RequisitionGroup> requisitionGroupList = requisitionGroupService.search(searchParam, columnName, pagination); pagination.setTotalRecords(requisitionGroupService.getTotalRecords(searchParam, columnName)); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response("requisitionGroupList", requisitionGroupList); response.getBody().addData("pagination", pagination); return response; }  }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "columnName") String columnName, @RequestParam(value = "page", defaultValue = "1") Integer page) { Integer pageSize = Integer.parseInt(staticReferenceDataService.getPropertyValue(SEARCH_PAGE_SIZE)); Pagination pagination = new Pagination(page, pageSize); List<RequisitionGroup> requisitionGroupList = requisitionGroupService.search(searchParam, columnName, pagination); pagination.setTotalRecords(requisitionGroupService.getTotalRecords(searchParam, columnName)); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response("requisitionGroupList", requisitionGroupList); response.getBody().addData("pagination", pagination); return response; }  @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam,
                                                 @RequestParam(value = "columnName") String columnName,
                                                 @RequestParam(value = "page", defaultValue = "1") Integer page); @RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id); @RequestMapping(value = "/requisitionGroups", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> insert(@RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id,
                                                 @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam, @RequestParam(value = "columnName") String columnName, @RequestParam(value = "page", defaultValue = "1") Integer page) { Integer pageSize = Integer.parseInt(staticReferenceDataService.getPropertyValue(SEARCH_PAGE_SIZE)); Pagination pagination = new Pagination(page, pageSize); List<RequisitionGroup> requisitionGroupList = requisitionGroupService.search(searchParam, columnName, pagination); pagination.setTotalRecords(requisitionGroupService.getTotalRecords(searchParam, columnName)); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response("requisitionGroupList", requisitionGroupList); response.getBody().addData("pagination", pagination); return response; }  @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam,
                                                 @RequestParam(value = "columnName") String columnName,
                                                 @RequestParam(value = "page", defaultValue = "1") Integer page); @RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id); @RequestMapping(value = "/requisitionGroups", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> insert(@RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id,
                                                 @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); static final String SEARCH_PAGE_SIZE; }