use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class ActiveStockCardsValidatorTest method shouldThrowExceptionIfExistingCardLotNotCovered.
@Test
public void shouldThrowExceptionIfExistingCardLotNotCovered() throws Exception {
expectedEx.expectMessage(ERROR_PHYSICAL_INVENTORY_NOT_INCLUDE_ACTIVE_STOCK_CARD);
// given
StockEventDto stockEventDto = createNoSourceDestinationStockEventDto();
stockEventDto.getLineItems().get(0).setReasonId(null);
stockEventDto.getLineItems().get(0).setLotId(randomUUID());
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 stockEventWithOrderableIdNotInApprovedListShouldNotPassValidation.
@Test(expected = ValidationMessageException.class)
public void stockEventWithOrderableIdNotInApprovedListShouldNotPassValidation() throws Exception {
// given:
StockEventDto stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
OrderableDto orderableDto = new OrderableDto();
orderableDto.setId(UUID.randomUUID());
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 FreeTextValidatorTest method shouldFailWhenDestinationNodeIsRefdataWithFreeText.
@Test
public void shouldFailWhenDestinationNodeIsRefdataWithFreeText() throws Exception {
UUID destinationId = fromString("0bd28568-43f1-4836-934d-ec5fb11398e8");
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
eventDto.getLineItems().get(0).setDestinationId(destinationId);
eventDto.getLineItems().get(0).setDestinationFreeText("destination free text");
setContext(eventDto);
mockNode(destinationId, eventDto);
exception.expect(ValidationMessageException.class);
exception.expectMessage(containsString(ERROR_DESTINATION_FREE_TEXT_NOT_ALLOWED));
freeTextValidator.validate(eventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class FreeTextValidatorTest method shouldFailWhenReasonFreeTextNotAllowedButExist.
@Test
public void shouldFailWhenReasonFreeTextNotAllowedButExist() throws Exception {
StockCardLineItemReason mockReason = mock(StockCardLineItemReason.class);
when(reasonRepository.findOne(any(UUID.class))).thenReturn(mockReason);
when(mockReason.getIsFreeTextAllowed()).thenReturn(false);
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
eventDto.getLineItems().get(0).setReasonId(fromString("e3fc3cf3-da18-44b0-a220-77c985202e06"));
eventDto.getLineItems().get(0).setReasonFreeText("reason free text");
setContext(eventDto);
exception.expect(ValidationMessageException.class);
exception.expectMessage(containsString(ERROR_REASON_FREE_TEXT_NOT_ALLOWED));
freeTextValidator.validate(eventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class OrderableLotDuplicationValidatorTest method physicalInventoryEventWithSameOrderableAndLotAppearTwiceShouldNotPass.
@Test
public void physicalInventoryEventWithSameOrderableAndLotAppearTwiceShouldNotPass() throws Exception {
// expect: exception
expectedEx.expectMessage(ERROR_EVENT_ORDERABLE_LOT_DUPLICATION);
StockEventDto eventDto = createStockEventDtoWithDuplicateOrderableLot(null);
// when
orderableLotDuplicationValidator.validate(eventDto);
}
Aggregations