use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class FreeTextValidatorTest method shouldFailWhenSourceNotExistButSourceFreeTextExist.
@Test
public void shouldFailWhenSourceNotExistButSourceFreeTextExist() throws Exception {
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
eventDto.getLineItems().get(0).setSourceId(null);
eventDto.getLineItems().get(0).setSourceFreeText("source free text");
setContext(eventDto);
exception.expect(ValidationMessageException.class);
exception.expectMessage(containsString(ERROR_SOURCE_FREE_TEXT_NOT_ALLOWED));
freeTextValidator.validate(eventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class FreeTextValidatorTest method shouldFailWhenReasonNotExistButReasonFreeTextExist.
@Test
public void shouldFailWhenReasonNotExistButReasonFreeTextExist() throws Exception {
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
eventDto.getLineItems().get(0).setReasonId(null);
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 FreeTextValidatorTest method shouldFailWhenSourceNodeIsRefdataWithFreeText.
@Test
public void shouldFailWhenSourceNodeIsRefdataWithFreeText() throws Exception {
UUID sourceId = fromString("0bd28568-43f1-4836-934d-ec5fb11398e8");
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
eventDto.getLineItems().get(0).setSourceId(sourceId);
eventDto.getLineItems().get(0).setSourceFreeText("source free text");
setContext(eventDto);
mockNode(sourceId, eventDto);
exception.expect(ValidationMessageException.class);
exception.expectMessage(containsString(ERROR_SOURCE_FREE_TEXT_NOT_ALLOWED));
freeTextValidator.validate(eventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class OrderableLotDuplicationValidatorTest method createStockEventDtoWithDuplicateOrderableLot.
private StockEventDto createStockEventDtoWithDuplicateOrderableLot(UUID reasonId) {
// given: an event with orderable appear twice
StockEventLineItemDto eventLineItem1 = new StockEventLineItemDto();
StockEventLineItemDto eventLineItem2 = new StockEventLineItemDto();
eventLineItem1.setReasonId(reasonId);
eventLineItem2.setReasonId(reasonId);
UUID orderableId = randomUUID();
UUID lotId = randomUUID();
eventLineItem1.setOrderableId(orderableId);
// same uuid string, different object, make sure the code recognize them as same uuid
eventLineItem2.setOrderableId(fromString(orderableId.toString()));
eventLineItem1.setLotId(lotId);
eventLineItem2.setLotId(fromString(lotId.toString()));
StockEventDto eventDto = new StockEventDto();
eventDto.setLineItems(Arrays.asList(eventLineItem1, eventLineItem2));
return eventDto;
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class OrderableLotDuplicationValidatorTest method adjustmentEventWithSameOrderableAndLotAppearTwiceShouldPass.
@Test
public void adjustmentEventWithSameOrderableAndLotAppearTwiceShouldPass() throws Exception {
StockEventDto eventDto = createStockEventDtoWithDuplicateOrderableLot(randomUUID());
// when
orderableLotDuplicationValidator.validate(eventDto);
}
Aggregations