@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; }
EquipmentInventoryController extends BaseController { @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; } }
EquipmentInventoryController extends BaseController { @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; }  }
EquipmentInventoryController extends BaseController { @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; }  @RequestMapping(value="list", method = RequestMethod.GET) 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); @RequestMapping(value= PROGRAMS, method = RequestMethod.GET) ResponseEntity<OpenLmisResponse> getPrograms(HttpServletRequest request); @RequestMapping(value="facility/programs", method = RequestMethod.GET) ResponseEntity<OpenLmisResponse> getProgramsForFacility(@RequestParam("facilityId") Long facilityId, HttpServletRequest request); @RequestMapping(value="supervised/facilities", method = RequestMethod.GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<ModelMap> getFacilities(@RequestParam("programId") Long programId,  HttpServletRequest request); @RequestMapping(value="by-id", method = RequestMethod.GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getInventory(@RequestParam("id") Long id); @RequestMapping(value="save", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentInventory inventory, HttpServletRequest request); @RequestMapping(value="status/update", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> updateStatus(@RequestBody EquipmentInventory inventory, HttpServletRequest request); }
EquipmentInventoryController extends BaseController { @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; }  @RequestMapping(value="list", method = RequestMethod.GET) 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); @RequestMapping(value= PROGRAMS, method = RequestMethod.GET) ResponseEntity<OpenLmisResponse> getPrograms(HttpServletRequest request); @RequestMapping(value="facility/programs", method = RequestMethod.GET) ResponseEntity<OpenLmisResponse> getProgramsForFacility(@RequestParam("facilityId") Long facilityId, HttpServletRequest request); @RequestMapping(value="supervised/facilities", method = RequestMethod.GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<ModelMap> getFacilities(@RequestParam("programId") Long programId,  HttpServletRequest request); @RequestMapping(value="by-id", method = RequestMethod.GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getInventory(@RequestParam("id") Long id); @RequestMapping(value="save", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentInventory inventory, HttpServletRequest request); @RequestMapping(value="status/update", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> updateStatus(@RequestBody EquipmentInventory inventory, HttpServletRequest request); static final String PROGRAMS; static final String INVENTORY; static final String FACILITIES; static final String PAGINATION; }