use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method newInventoryForSubmit.
private PhysicalInventoryDto newInventoryForSubmit() {
PhysicalInventoryDto inventory = new PhysicalInventoryDto();
inventory.setId(randomUUID());
inventory.setProgramId(randomUUID());
inventory.setFacilityId(randomUUID());
inventory.setIsDraft(true);
lineItemDto = generateLineItem();
inventory.setLineItems(Collections.singletonList(lineItemDto));
return inventory;
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldCreateNewDraft.
@Test
public void shouldCreateNewDraft() throws Exception {
// given
UUID programId = UUID.randomUUID();
UUID facilityId = UUID.randomUUID();
PhysicalInventoryDto piDto = createInventoryDto(programId, facilityId);
when(physicalInventoryRepository.save(any(PhysicalInventory.class))).thenAnswer(new SaveAnswer<PhysicalInventory>());
// when
PhysicalInventoryDto newDraft = physicalInventoryService.createNewDraft(piDto);
// then
assertNotNull(newDraft.getId());
verify(physicalInventoryRepository, times(1)).save(inventoryArgumentCaptor.capture());
PhysicalInventory captured = inventoryArgumentCaptor.getValue();
assertEquals(programId, captured.getProgramId());
assertEquals(facilityId, captured.getFacilityId());
assertEquals(true, captured.getIsDraft());
assertEquals(null, captured.getLineItems());
verify(homeFacilityPermissionService, times(1)).checkProgramSupported(programId);
verify(permissionService, times(1)).canEditPhysicalInventory(programId, facilityId);
verify(validator, times(1)).validateEmptyDraft(piDto);
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldSaveDraftWhenPassValidations.
@Test
public void shouldSaveDraftWhenPassValidations() throws Exception {
// given
UUID programId = UUID.randomUUID();
UUID facilityId = UUID.randomUUID();
PhysicalInventoryDto piDto = createInventoryDto(programId, facilityId);
UUID physicalInventoryId = randomUUID();
// when
physicalInventoryService.saveDraft(piDto, physicalInventoryId);
// then
verify(physicalInventoryRepository, times(1)).save(inventoryArgumentCaptor.capture());
PhysicalInventory captured = inventoryArgumentCaptor.getValue();
verifyLineItems(piDto.getLineItems(), captured.getLineItems());
assertEquals(programId, captured.getProgramId());
assertEquals(facilityId, captured.getFacilityId());
assertEquals(true, captured.getIsDraft());
verify(homeFacilityPermissionService, times(1)).checkProgramSupported(programId);
verify(permissionService, times(1)).canEditPhysicalInventory(programId, facilityId);
verify(validator, times(1)).validateDraft(piDto, physicalInventoryId);
}
Aggregations