@Test public void shouldSave() throws Exception { EquipmentInventory inventory = new EquipmentInventory(); inventory.setId(32L); doNothing().when(service).save(inventory); ResponseEntity<OpenLmisResponse> response = controller.save(inventory, request); assertThat(inventory, is(response.getBody().getData().get("inventory"))); assertThat(response.getBody().getSuccessMsg(), is(notNullValue())); }
@RequestMapping(value="save", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentInventory inventory, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> response; Long userId = loggedInUserId(request); inventory.setCreatedBy(userId); inventory.setModifiedBy(userId); service.save(inventory); service.updateNonFunctionalEquipments(); response = OpenLmisResponse.success(messageService.message("message.equipment.inventory.saved")); response.getBody().addData(INVENTORY, inventory); return response; }
EquipmentInventoryController extends BaseController { @RequestMapping(value="save", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentInventory inventory, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> response; Long userId = loggedInUserId(request); inventory.setCreatedBy(userId); inventory.setModifiedBy(userId); service.save(inventory); service.updateNonFunctionalEquipments(); response = OpenLmisResponse.success(messageService.message("message.equipment.inventory.saved")); response.getBody().addData(INVENTORY, inventory); return response; } }
EquipmentInventoryController extends BaseController { @RequestMapping(value="save", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentInventory inventory, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> response; Long userId = loggedInUserId(request); inventory.setCreatedBy(userId); inventory.setModifiedBy(userId); service.save(inventory); service.updateNonFunctionalEquipments(); response = OpenLmisResponse.success(messageService.message("message.equipment.inventory.saved")); response.getBody().addData(INVENTORY, inventory); return response; }  }
EquipmentInventoryController extends BaseController { @RequestMapping(value="save", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentInventory inventory, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> response; Long userId = loggedInUserId(request); inventory.setCreatedBy(userId); inventory.setModifiedBy(userId); service.save(inventory); service.updateNonFunctionalEquipments(); response = OpenLmisResponse.success(messageService.message("message.equipment.inventory.saved")); response.getBody().addData(INVENTORY, inventory); 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="save", method = RequestMethod.POST) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentInventory inventory, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> response; Long userId = loggedInUserId(request); inventory.setCreatedBy(userId); inventory.setModifiedBy(userId); service.save(inventory); service.updateNonFunctionalEquipments(); response = OpenLmisResponse.success(messageService.message("message.equipment.inventory.saved")); response.getBody().addData(INVENTORY, inventory); 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; }