use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidatorTest method shouldRejectWhenEmptyDraftHasNoFacility.
@Test(expected = ValidationMessageException.class)
public void shouldRejectWhenEmptyDraftHasNoFacility() {
PhysicalInventoryDto physicalInventoryDto = new PhysicalInventoryDto();
physicalInventoryDto.setProgramId(UUID.randomUUID());
validator.validateEmptyDraft(physicalInventoryDto);
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidatorTest method shouldPassAndCallVvmValidator.
@Test
public void shouldPassAndCallVvmValidator() {
// given
PhysicalInventoryDto inventory = newInventory();
doNothing().when(vvmValidator).validate(any(), anyString(), eq(false));
// when
validator.validateDraft(inventory, UUID.fromString(inventory.getId().toString()));
// then
verify(vvmValidator, atLeastOnce()).validate(eq(inventory.getLineItems()), anyString(), eq(false));
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidatorTest method shouldRejectWhenNoLineItemsPresent.
@Test(expected = ValidationMessageException.class)
public void shouldRejectWhenNoLineItemsPresent() {
// given
PhysicalInventoryDto inventory = newInventory();
inventory.setLineItems(Collections.emptyList());
doNothing().when(vvmValidator).validate(eq(inventory.getLineItems()), anyString(), eq(false));
// when
validator.validateDraft(inventory, inventory.getId());
// then
verify(vvmValidator, atLeastOnce()).validate(eq(inventory.getLineItems()), anyString(), eq(false));
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidatorTest method newInventory.
private PhysicalInventoryDto newInventory() {
PhysicalInventoryDto inventory = new PhysicalInventoryDto();
inventory.setId(randomUUID());
inventory.setLineItems(Collections.singletonList(generateLineItem()));
return inventory;
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldNotThrowExceptionWhenSaveDraftIfExistingDraftHasSameId.
@Test
public void shouldNotThrowExceptionWhenSaveDraftIfExistingDraftHasSameId() throws Exception {
UUID programId = UUID.randomUUID();
UUID facilityId = UUID.randomUUID();
PhysicalInventoryDto piDto = createInventoryDto(programId, facilityId);
PhysicalInventory mock = mock(PhysicalInventory.class);
when(mock.getId()).thenReturn(piDto.getId());
when(physicalInventoryRepository.findByProgramIdAndFacilityIdAndIsDraft(programId, facilityId, true)).thenReturn(Collections.singletonList(mock));
physicalInventoryService.saveDraft(piDto, piDto.getId());
}
Aggregations