Search in sources :

Example 61 with StockEventDto

use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.

the class ReceiveIssueReasonValidatorTest method eventThatHasSourceAndA_reasonOfNonAdhocCategoryShouldNotPass.

@Test
public void eventThatHasSourceAndA_reasonOfNonAdhocCategoryShouldNotPass() throws Exception {
    StockEventDto stockEventDto = createStockEventDto();
    stockEventDto.getLineItems().get(0).setSourceId(UUID.randomUUID());
    stockEventDto.getLineItems().get(0).setDestinationId(null);
    stockEventDto.getLineItems().get(0).setReasonId(UUID.randomUUID());
    testErrorCase(ERROR_EVENT_RECEIVE_REASON_CATEGORY_INVALID, stockEventDto, creditNonAdhocReason);
}
Also used : StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) Test(org.junit.Test)

Example 62 with StockEventDto

use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.

the class ReceiveIssueReasonValidatorTest method eventThatHasDestinationAndA_reasonOfNonAdhocCategoryShouldNotPass.

@Test
public void eventThatHasDestinationAndA_reasonOfNonAdhocCategoryShouldNotPass() throws Exception {
    StockEventDto stockEventDto = createStockEventDto();
    stockEventDto.getLineItems().get(0).setDestinationId(UUID.randomUUID());
    stockEventDto.getLineItems().get(0).setSourceId(null);
    stockEventDto.getLineItems().get(0).setReasonId(UUID.randomUUID());
    testErrorCase(ERROR_EVENT_ISSUE_REASON_CATEGORY_INVALID, stockEventDto, debitNonAdhocReason);
}
Also used : StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) Test(org.junit.Test)

Example 63 with StockEventDto

use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.

the class SourceDestinationAssignmentValidatorTest method shouldPassIfProgramMissing.

@Test
public // that is handled in other validators
void shouldPassIfProgramMissing() throws Exception {
    // given
    StockEventDto eventDto = createStockEventDto();
    createContextWithFacility(eventDto);
    eventDto.setProgramId(null);
    eventDto.getLineItems().get(0).setDestinationId(node.getId());
    eventDto.getLineItems().get(0).setSourceId(null);
    // when
    sourceDestinationAssignmentValidator.validate(eventDto);
// then: no error
}
Also used : StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) Test(org.junit.Test)

Example 64 with StockEventDto

use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.

the class SourceDestinationAssignmentValidatorTest method shouldPassIfFacilityNotFoundInRefData.

@Test
public // that is handled in other validators
void shouldPassIfFacilityNotFoundInRefData() throws Exception {
    // given
    StockEventDto eventDto = createStockEventDto();
    createContextWithFacility(eventDto);
    eventDto.setFacilityId(null);
    eventDto.getLineItems().get(0).setDestinationId(node.getId());
    eventDto.getLineItems().get(0).setSourceId(null);
    // when
    sourceDestinationAssignmentValidator.validate(eventDto);
// then: no error
}
Also used : StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) Test(org.junit.Test)

Example 65 with StockEventDto

use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.

the class SourceDestinationAssignmentValidatorTest method shouldNotPassWhenEventHasBothSourceAndDestination.

@Test
public void shouldNotPassWhenEventHasBothSourceAndDestination() throws Exception {
    // given
    StockEventDto eventDto = createStockEventDto();
    createContextWithFacility(eventDto);
    eventDto.getLineItems().get(0).setSourceId(UUID.randomUUID());
    eventDto.getLineItems().get(0).setDestinationId(UUID.randomUUID());
    expectedEx.expect(ValidationMessageException.class);
    expectedEx.expectMessage(containsString(ERROR_SOURCE_DESTINATION_BOTH_PRESENT));
    // when
    sourceDestinationAssignmentValidator.validate(eventDto);
}
Also used : StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) 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