Search in sources :

Example 1 with StockEventDtoDataBuilder.createStockEventDto

use of org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardServiceIntegrationTest method shouldGetStockCardWithCalculatedSohWhenFindStockCard.

@Test
public void shouldGetStockCardWithCalculatedSohWhenFindStockCard() throws Exception {
    // given
    StockEventDto stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
    stockEventDto.getLineItems().get(0).setSourceId(null);
    stockEventDto.getLineItems().get(0).setDestinationId(null);
    StockEvent savedEvent = save(stockEventDto, randomUUID());
    // when
    UUID cardId = stockCardRepository.findByOriginEvent(savedEvent).getId();
    StockCardDto card = stockCardService.findStockCardById(cardId);
    // then
    assertThat(card.getStockOnHand(), is(stockEventDto.getLineItems().get(0).getQuantity()));
}
Also used : StockEvent(org.openlmis.stockmanagement.domain.event.StockEvent) StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) StockCardDto(org.openlmis.stockmanagement.dto.StockCardDto) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) BaseIntegrationTest(org.openlmis.stockmanagement.BaseIntegrationTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with StockEventDtoDataBuilder.createStockEventDto

use of org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardServiceIntegrationTest method shouldReassignPhysicalInventoryReasonNames.

@Test
public void shouldReassignPhysicalInventoryReasonNames() throws Exception {
    // given
    StockEventDto stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
    stockEventDto.getLineItems().get(0).setSourceId(null);
    stockEventDto.getLineItems().get(0).setDestinationId(null);
    stockEventDto.getLineItems().get(0).setReasonId(null);
    StockEvent savedEvent = save(stockEventDto, randomUUID());
    // when
    UUID cardId = stockCardRepository.findByOriginEvent(savedEvent).getId();
    StockCardDto card = stockCardService.findStockCardById(cardId);
    // then
    String reasonName = card.getLineItems().get(0).getLineItem().getReason().getName();
    assertThat(reasonName, is("Overstock"));
}
Also used : StockEvent(org.openlmis.stockmanagement.domain.event.StockEvent) StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) StockCardDto(org.openlmis.stockmanagement.dto.StockCardDto) UUID.fromString(java.util.UUID.fromString) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) BaseIntegrationTest(org.openlmis.stockmanagement.BaseIntegrationTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

UUID (java.util.UUID)2 UUID.randomUUID (java.util.UUID.randomUUID)2 Test (org.junit.Test)2 BaseIntegrationTest (org.openlmis.stockmanagement.BaseIntegrationTest)2 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)2 StockCardDto (org.openlmis.stockmanagement.dto.StockCardDto)2 StockEventDto (org.openlmis.stockmanagement.dto.StockEventDto)2 StockEventDtoDataBuilder.createStockEventDto (org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 UUID.fromString (java.util.UUID.fromString)1