use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class ActiveStockCardsValidatorTest method shouldThrowExceptionIfExistingCardOrderableNotCovered.
@Test
public void shouldThrowExceptionIfExistingCardOrderableNotCovered() throws Exception {
expectedEx.expectMessage(ERROR_PHYSICAL_INVENTORY_NOT_INCLUDE_ACTIVE_STOCK_CARD);
// given
StockEventDto stockEventDto = createNoSourceDestinationStockEventDto();
stockEventDto.getLineItems().get(0).setReasonId(null);
when(stockCardRepository.getIdentitiesBy(stockEventDto.getProgramId(), stockEventDto.getFacilityId())).thenReturn(singletonList(new OrderableLotIdentity(randomUUID(), randomUUID())));
// when
activeStockCardsValidator.validate(stockEventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class ApprovedOrderableValidatorTest method stockEventWithOrderableIdInApprovedListShouldPass.
@Test
public void stockEventWithOrderableIdInApprovedListShouldPass() throws Exception {
// given:
String orderableIdString = "d8290082-f9fa-4a37-aefb-a3d76ff805a8";
UUID orderableId = UUID.fromString(orderableIdString);
StockEventDto stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
stockEventDto.getLineItems().get(0).setOrderableId(orderableId);
OrderableDto orderableDto = new OrderableDto();
orderableDto.setId(UUID.fromString(orderableIdString));
StockEventProcessContext context = new StockEventProcessContext();
context.setAllApprovedProducts(new LazyList<>(() -> singletonList(orderableDto)));
stockEventDto.setContext(context);
// when:
approvedOrderableValidator.validate(stockEventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class ApprovedOrderableValidatorTest method shouldNotThrowValidationExceptionIfEventHasNoProgramAndFacilityId.
@Test
public void shouldNotThrowValidationExceptionIfEventHasNoProgramAndFacilityId() throws Exception {
// given
StockEventDto stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
stockEventDto.setProgramId(null);
// when
approvedOrderableValidator.validate(stockEventDto);
// given
stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
stockEventDto.setFacilityId(null);
// when
approvedOrderableValidator.validate(stockEventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class FreeTextValidatorTest method shouldFailWhenEventHasBothSourceAndDestinationFreeText.
@Test
public void shouldFailWhenEventHasBothSourceAndDestinationFreeText() throws Exception {
StockEventDto eventDto = createStockEventDto();
eventDto.getLineItems().get(0).setReasonId(randomUUID());
eventDto.getLineItems().get(0).setDestinationId(randomUUID());
eventDto.getLineItems().get(0).setSourceFreeText("source free text");
eventDto.getLineItems().get(0).setDestinationFreeText("destination free text");
setContext(eventDto);
exception.expect(ValidationMessageException.class);
exception.expectMessage(containsString(ERROR_SOURCE_DESTINATION_FREE_TEXT_BOTH_PRESENT));
freeTextValidator.validate(eventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class FreeTextValidatorTest method shouldFailWhenDestinationNotExistButDestinationFreeTextExist.
@Test
public void shouldFailWhenDestinationNotExistButDestinationFreeTextExist() throws Exception {
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
eventDto.getLineItems().get(0).setDestinationFreeText("destination free text");
setContext(eventDto);
exception.expect(ValidationMessageException.class);
exception.expectMessage(containsString(ERROR_DESTINATION_FREE_TEXT_NOT_ALLOWED));
freeTextValidator.validate(eventDto);
}
Aggregations