Search in sources :

Example 6 with StockCardLineItemDataBuilder

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

the class StockCardRepositoryIntegrationTest method generateInstance.

private StockCard generateInstance(UUID facility, UUID program, UUID product, UUID lot) {
    StockEvent event = new StockEventDataBuilder().withoutId().withFacility(facility).withProgram(program).build();
    event = stockEventsRepository.save(event);
    StockCardLineItem lineItem = new StockCardLineItemDataBuilder().withoutId().withOriginEvent(event).build();
    StockCard stockCard = new StockCardDataBuilder(event).withoutId().withOrderable(product).withLot(lot).withLineItem(lineItem).build();
    lineItem.setStockCard(stockCard);
    return stockCard;
}
Also used : StockEvent(org.openlmis.stockmanagement.domain.event.StockEvent) StockCardDataBuilder(org.openlmis.stockmanagement.testutils.StockCardDataBuilder) StockEventDataBuilder(org.openlmis.stockmanagement.testutils.StockEventDataBuilder) StockCardLineItem(org.openlmis.stockmanagement.domain.card.StockCardLineItem) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) StockCardLineItemDataBuilder(org.openlmis.stockmanagement.testutils.StockCardLineItemDataBuilder)

Example 7 with StockCardLineItemDataBuilder

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

the class StockCardSummariesV2DtoBuilderTest method before.

@Before
public void before() {
    ReflectionTestUtils.setField(builder, "serviceUrl", "https://openlmis/");
    orderable1 = new OrderableDtoDataBuilder().build();
    orderable2 = new OrderableDtoDataBuilder().build();
    orderable3 = new OrderableDtoDataBuilder().build();
    StockEvent event = new StockEventDataBuilder().withFacility(facilityId).withProgram(programId).build();
    stockCard = new StockCardDataBuilder(event).buildWithStockOnHandAndLineItemAndOrderableId(12, new StockCardLineItemDataBuilder().buildWithStockOnHand(16), orderable1.getId());
    stockCard1 = new StockCardDataBuilder(event).buildWithStockOnHandAndLineItemAndOrderableId(26, new StockCardLineItemDataBuilder().buildWithStockOnHand(30), orderable3.getId());
    stockCard2 = new StockCardDataBuilder(event).withLot(UUID.randomUUID()).buildWithStockOnHandAndLineItemAndOrderableId(22, new StockCardLineItemDataBuilder().buildWithStockOnHand(10), orderable3.getId());
    fulfillMap = new HashMap<>();
    fulfillMap.put(orderable1.getId(), new OrderableFulfillDtoDataBuilder().withCanFulfillForMe(asList(orderable2.getId(), orderable3.getId())).build());
    fulfillMap.put(orderable2.getId(), new OrderableFulfillDtoDataBuilder().withCanFulfillForMe(Collections.singletonList(orderable1.getId())).build());
}
Also used : StockEvent(org.openlmis.stockmanagement.domain.event.StockEvent) OrderableDtoDataBuilder(org.openlmis.stockmanagement.testutils.OrderableDtoDataBuilder) StockCardDataBuilder(org.openlmis.stockmanagement.testutils.StockCardDataBuilder) StockEventDataBuilder(org.openlmis.stockmanagement.testutils.StockEventDataBuilder) OrderableFulfillDtoDataBuilder(org.openlmis.stockmanagement.testutils.OrderableFulfillDtoDataBuilder) StockCardLineItemDataBuilder(org.openlmis.stockmanagement.testutils.StockCardLineItemDataBuilder) Before(org.junit.Before)

Example 8 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnZeroIfOccurredDatesAreSame.

@Test
public void shouldReturnZeroIfOccurredDatesAreSame() throws Exception {
    // when
    StockCardLineItem left = new StockCardLineItemDataBuilder().build();
    StockCardLineItem right = new StockCardLineItemDataBuilder().build();
    // then
    assertThat(byOccurredDate().compare(left, right), is(0));
}
Also used : StockCardLineItemDataBuilder(org.openlmis.stockmanagement.testutils.StockCardLineItemDataBuilder) Test(org.junit.Test)

Example 9 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnPositiveIfFirstOccurredDateIsLater.

@Test
public void shouldReturnPositiveIfFirstOccurredDateIsLater() throws Exception {
    // when
    StockCardLineItem left = new StockCardLineItemDataBuilder().build();
    StockCardLineItem right = new StockCardLineItemDataBuilder().withOccurredDatePreviousDay().build();
    // then
    assertThat(byOccurredDate().compare(left, right), greaterThan(0));
}
Also used : StockCardLineItemDataBuilder(org.openlmis.stockmanagement.testutils.StockCardLineItemDataBuilder) Test(org.junit.Test)

Example 10 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnZeroIfReasonPrioritiesAreNull.

@Test
public void shouldReturnZeroIfReasonPrioritiesAreNull() throws Exception {
    // when
    StockCardLineItem left = new StockCardLineItemDataBuilder().build();
    StockCardLineItem right = new StockCardLineItemDataBuilder().build();
    // then
    assertThat(byReasonPriority().compare(left, right), is(0));
}
Also used : StockCardLineItemDataBuilder(org.openlmis.stockmanagement.testutils.StockCardLineItemDataBuilder) Test(org.junit.Test)

Aggregations

StockCardLineItemDataBuilder (org.openlmis.stockmanagement.testutils.StockCardLineItemDataBuilder)14 Test (org.junit.Test)12 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)2 StockCardDataBuilder (org.openlmis.stockmanagement.testutils.StockCardDataBuilder)2 StockEventDataBuilder (org.openlmis.stockmanagement.testutils.StockEventDataBuilder)2 Before (org.junit.Before)1 StockCard (org.openlmis.stockmanagement.domain.card.StockCard)1 StockCardLineItem (org.openlmis.stockmanagement.domain.card.StockCardLineItem)1 OrderableDtoDataBuilder (org.openlmis.stockmanagement.testutils.OrderableDtoDataBuilder)1 OrderableFulfillDtoDataBuilder (org.openlmis.stockmanagement.testutils.OrderableFulfillDtoDataBuilder)1