@Test public void shouldGetInventory() throws Exception { List<EquipmentInventory> inventories = new ArrayList<>(); Pagination page = new Pagination(1, 2); when(service.getInventory(1L, 1L, 1L, 1L, page)).thenReturn(inventories); ResponseEntity<OpenLmisResponse> response = controller.getInventory(1L, 1L, 1L, 1, "2", request); assertThat(inventories, is(response.getBody().getData().get("inventory"))); }
@RequestMapping(value = "list", method = RequestMethod.GET) public ResponseEntity<OpenLmisResponse> getInventory( @RequestParam("typeId") Long typeId, @RequestParam("programId") Long programId, @RequestParam("equipmentTypeId") Long equipmentTypeId, @RequestParam(value = "page", defaultValue = "1") Integer page, @Value("${search.page.size}") String limit, HttpServletRequest request) { Long userId = loggedInUserId(request); Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords( service.getInventoryCount(userId, typeId, programId, equipmentTypeId)); List<EquipmentInventory> inventory = service.getInventory(userId, typeId, programId, equipmentTypeId, pagination); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(INVENTORY, inventory); response.getBody().addData(PAGINATION, pagination); return response; }