Search in sources :

Example 1 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnPositiveIfFirstProcessedDateIsLater.

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

Example 2 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnZeroIfProcessedDatesAreSame.

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

Example 3 with StockCardLineItemDataBuilder

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

the class StockCardLineItemComparatorsTest method shouldReturnNegativeIfFirstProcessedDateIsEarlier.

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

Example 4 with StockCardLineItemDataBuilder

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

the class StockCardTest method shouldGetLineItemAsOfDate.

@Test
public void shouldGetLineItemAsOfDate() throws Exception {
    StockCard stockCard = ObjectGenerator.of(StockCard.class);
    stockCard.setLineItems(asList(new StockCardLineItemDataBuilder().build(), new StockCardLineItemDataBuilder().withOccurredDatePreviousDay().build(), new StockCardLineItemDataBuilder().withOccurredDateNextDay().build()));
    assertEquals(getBaseDate().plusDays(1), stockCard.getLineItemAsOfDate(getBaseDate().plusDays(1)).getOccurredDate());
    assertEquals(null, stockCard.getLineItemAsOfDate(getBaseDate().minusDays(2)));
}
Also used : StockCardLineItemDataBuilder(org.openlmis.stockmanagement.testutils.StockCardLineItemDataBuilder) Test(org.junit.Test)

Example 5 with StockCardLineItemDataBuilder

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

the class StockCardTest method shouldGetSohByCalculatingSohOfEachLineItem.

@Test
public void shouldGetSohByCalculatingSohOfEachLineItem() throws Exception {
    // given
    StockCardLineItem lineItem1 = new StockCardLineItemDataBuilder().withStockOnHand(123).buildMock();
    StockCardLineItem lineItem2 = new StockCardLineItemDataBuilder().withOccurredDateNextDay().withStockOnHand(456).buildMock();
    StockCard card = new StockCard();
    card.setLineItems(asList(lineItem1, lineItem2));
    // when
    card.calculateStockOnHand();
    // then
    verify(lineItem1).calculateStockOnHand(0);
    verify(lineItem2).calculateStockOnHand(123);
    assertThat(card.getStockOnHand(), is(456));
}
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