use of org.openlmis.stockmanagement.dto.PhysicalInventoryLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldReturnAllSavedInventories.
@Test
public void shouldReturnAllSavedInventories() throws Exception {
PhysicalInventory inventory = createInventoryDraft(orderableId, programId, facilityId);
// given
when(physicalInventoryRepository.findByProgramIdAndFacilityId(programId, facilityId)).thenReturn(Collections.singletonList(inventory));
// when
List<PhysicalInventoryDto> foundDraft = physicalInventoryService.findPhysicalInventory(programId, facilityId, null);
// then
assertEquals(1, foundDraft.size());
assertEquals(programId, foundDraft.get(0).getProgramId());
assertEquals(facilityId, foundDraft.get(0).getFacilityId());
PhysicalInventoryLineItemDto lineItemDto = foundDraft.get(0).getLineItems().get(0);
assertEquals(orderableId, lineItemDto.getOrderableId());
assertEquals(null, lineItemDto.getQuantity());
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldSearchBasedOnIsDraft.
private void shouldSearchBasedOnIsDraft(PhysicalInventory inventory, boolean isDraft) {
// given
inventory.setIsDraft(isDraft);
when(physicalInventoryRepository.findByProgramIdAndFacilityIdAndIsDraft(programId, facilityId, isDraft)).thenReturn(Collections.singletonList(inventory));
// when
List<PhysicalInventoryDto> foundDraft = physicalInventoryService.findPhysicalInventory(programId, facilityId, isDraft);
// then
assertEquals(1, foundDraft.size());
assertEquals(programId, foundDraft.get(0).getProgramId());
assertEquals(facilityId, foundDraft.get(0).getFacilityId());
assertEquals(isDraft, foundDraft.get(0).getIsDraft());
PhysicalInventoryLineItemDto lineItemDto = foundDraft.get(0).getLineItems().get(0);
assertEquals(orderableId, lineItemDto.getOrderableId());
assertEquals(null, lineItemDto.getQuantity());
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidator method validateDraft.
/**
* Check for physical inventory dto's validity.
* Throws {@link ValidationMessageException} if an error found.
* @param inventory physical inventory to validate.
*/
public void validateDraft(PhysicalInventoryDto inventory, UUID id) {
if (!inventory.getId().equals(id)) {
throw new ValidationMessageException(ERROR_PHYSICAL_INVENTORY_ID_MISMATCH);
}
PhysicalInventory foundInventory = physicalInventoriesRepository.findOne(id);
if (foundInventory != null && !foundInventory.getIsDraft()) {
throw new ValidationMessageException(ERROR_PHYSICAL_INVENTORY_IS_SUBMITTED);
}
List<PhysicalInventoryLineItemDto> lineItems = inventory.getLineItems();
validateLineItems(lineItems);
vvmValidator.validate(lineItems, ERROR_PHYSICAL_INVENTORY_ORDERABLE_DISABLED_VVM, false);
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryControllerIntegrationTest method generatePhysicalInventoryLineItem.
private PhysicalInventoryLineItemDto generatePhysicalInventoryLineItem() {
PhysicalInventoryLineItemDto item = new PhysicalInventoryLineItemDto();
item.setQuantity(10);
item.setStockOnHand(5);
item.setOrderableId(UUID.randomUUID());
item.setStockAdjustments(new ArrayList<>());
item.setLotId(UUID.randomUUID());
item.setExtraData(new HashMap<>());
return item;
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class VvmValidatorTest method generateVvmApplicable.
private VvmApplicable generateVvmApplicable(OrderableDto orderable) {
PhysicalInventoryLineItemDto lineItem = new PhysicalInventoryLineItemDto();
lineItem.setOrderableId(orderable.getId());
return lineItem;
}
Aggregations