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));
}
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));
}
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));
}
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)));
}
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));
}
Aggregations