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