Search in sources :

Example 31 with StockEventDto

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);
}
Also used : StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto) StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) Test(org.junit.Test)

Example 32 with StockEventDto

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);
}
Also used : StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto) StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) Test(org.junit.Test)

Example 33 with StockEventDto

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);
}
Also used : StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto) StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) Test(org.junit.Test)

Example 34 with StockEventDto

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;
}
Also used : StockEventLineItemDto(org.openlmis.stockmanagement.dto.StockEventLineItemDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID)

Example 35 with StockEventDto

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);
}
Also used : StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) Test(org.junit.Test)

Aggregations

StockEventDto (org.openlmis.stockmanagement.dto.StockEventDto)72 Test (org.junit.Test)65 StockEventDtoDataBuilder.createStockEventDto (org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto)44 UUID (java.util.UUID)24 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto (org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto)14 BaseIntegrationTest (org.openlmis.stockmanagement.BaseIntegrationTest)13 StockCard (org.openlmis.stockmanagement.domain.card.StockCard)11 UUID.randomUUID (java.util.UUID.randomUUID)10 StockEventLineItemDto (org.openlmis.stockmanagement.dto.StockEventLineItemDto)8 StockCardLineItem (org.openlmis.stockmanagement.domain.card.StockCardLineItem)7 Message (org.openlmis.stockmanagement.util.Message)7 LocalDate (java.time.LocalDate)6 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)5 OrderableLotIdentity (org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity)4 StockCardDto (org.openlmis.stockmanagement.dto.StockCardDto)4 ValidationMessageException (org.openlmis.stockmanagement.exception.ValidationMessageException)4 StockEventProcessContext (org.openlmis.stockmanagement.util.StockEventProcessContext)4 StockCardLineItemReason (org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason)3 OrderableDto (org.openlmis.stockmanagement.dto.referencedata.OrderableDto)3