@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; }