use of org.openlmis.stockmanagement.domain.physicalinventory.PhysicalInventory in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method createInventoryDraft.
private PhysicalInventory createInventoryDraft(UUID orderableId, UUID programId, UUID facilityId) {
PhysicalInventory inventory = createInventoryDto(programId, facilityId).toPhysicalInventoryForDraft();
inventory.getLineItems().get(0).setOrderableId(orderableId);
return inventory;
}
use of org.openlmis.stockmanagement.domain.physicalinventory.PhysicalInventory in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldReturnDraftIfSavedDraftIsFound.
@Test
public void shouldReturnDraftIfSavedDraftIsFound() throws Exception {
PhysicalInventory inventory = createInventoryDraft(orderableId, programId, facilityId);
shouldSearchBasedOnIsDraft(inventory, true);
}
use of org.openlmis.stockmanagement.domain.physicalinventory.PhysicalInventory 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.domain.physicalinventory.PhysicalInventory in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method verifyPhysicalInventorySavedWithSohAndAsDraft.
private void verifyPhysicalInventorySavedWithSohAndAsDraft(int previousSoH) {
PhysicalInventory captured = inventoryArgumentCaptor.getValue();
Integer previousStockOnHand = captured.getLineItems().get(0).getPreviousStockOnHandWhenSubmitted();
assertNotNull(previousStockOnHand);
assertEquals(previousSoH, previousStockOnHand.intValue());
assertFalse(captured.getIsDraft());
}
use of org.openlmis.stockmanagement.domain.physicalinventory.PhysicalInventory in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldDeleteDraftWhenPassValidations.
@Test
public void shouldDeleteDraftWhenPassValidations() throws Exception {
// given
UUID programId = UUID.randomUUID();
UUID facilityId = UUID.randomUUID();
PhysicalInventory physicalInventory = createInventoryDraft(UUID.randomUUID(), programId, facilityId);
physicalInventory.setId(UUID.randomUUID());
when(physicalInventoryRepository.findOne(physicalInventory.getId())).thenReturn(physicalInventory);
// when
physicalInventoryService.deletePhysicalInventory(physicalInventory.getId());
// then
verify(physicalInventoryRepository, times(1)).delete(physicalInventory);
verify(homeFacilityPermissionService, times(1)).checkProgramSupported(programId);
verify(permissionService, times(1)).canEditPhysicalInventory(programId, facilityId);
}
Aggregations