Search in sources :

Example 11 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnNegativeIfFirstOccurredDateIsEarlier.

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

Example 12 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnPositiveIfSecondReasonIsNull.

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

Example 13 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnPositiveIfFirstReasonIsNull.

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

Example 14 with StockCardLineItemDataBuilder

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

the class StockCardTest method shouldReorderLineItemsWhenCalculateSoh.

@Test
public void shouldReorderLineItemsWhenCalculateSoh() throws Exception {
    // given
    StockCardLineItem lineItem1 = new StockCardLineItemDataBuilder().withProcessedDateNextDay().withQuantity(10).withDebitReason().build();
    StockCardLineItem lineItem2 = new StockCardLineItemDataBuilder().withProcessedDateNextDay().withQuantity(20).withCreditReason().build();
    StockCardLineItem lineItem3 = new StockCardLineItemDataBuilder().withProcessedDateHourEarlier().withCreditReason().build();
    StockCardLineItem lineItem4 = new StockCardLineItemDataBuilder().withOccurredDatePreviousDay().withProcessedDateHourEarlier().withCreditReason().build();
    StockCard stockCard = StockCard.builder().lineItems(asList(lineItem1, lineItem2, lineItem3, lineItem4)).build();
    // when
    stockCard.calculateStockOnHand();
    // then
    assertThat(stockCard.getLineItems().get(0), is(lineItem4));
    assertThat(stockCard.getLineItems().get(1), is(lineItem3));
    assertThat(stockCard.getLineItems().get(2), is(lineItem2));
    assertThat(stockCard.getLineItems().get(3), is(lineItem1));
}
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