StockCard extends BaseModel implements Comparable<StockCard> { public List<LotOnHand> getNonEmptyLotOnHandList() { return FluentIterable.from(getLotOnHandListWrapper()).filter(lotOnHand -> lotOnHand.getQuantityOnHand() > 0).toList(); }  @Override int compareTo(@NonNull StockCard another); @Override boolean equals(Object o); @Override int hashCode(); StockMovementItem generateInitialStockMovementItem(); List<StockMovementItem> getStockMovementItemsWrapper(); float getCMM(); boolean isOverStock(); boolean isLowStock(); long calculateSOHFromLots(); List<LotOnHand> getLotOnHandListWrapper(); Date getEarliestLotExpiryDate(); Date getLastStockMovementDate(); Date getLastStockMovementCreatedTime(); List<LotOnHand> getNonEmptyLotOnHandList(); List<LotOnHand> getNoneExpiredLotOnHandList(); @Override String toString(); static final String DIVIDER; }
@Test public void shouldGetNonEmptyLotOnHandList() throws Exception { Lot lot1 = new Lot(); lot1.setExpirationDate(DateUtil.parseString("Sep 2014", DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR)); LotOnHand lotOnHand1 = new LotOnHand(); lotOnHand1.setLot(lot1); lotOnHand1.setQuantityOnHand(1L); Lot lot2 = new Lot(); lot2.setExpirationDate(DateUtil.parseString("Jan 2013", DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR)); LotOnHand lotOnHand2 = new LotOnHand(); lotOnHand2.setLot(lot2); lotOnHand2.setQuantityOnHand(0L); Lot lot3 = new Lot(); lot3.setExpirationDate(DateUtil.parseString("Feb 2014", DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR)); LotOnHand lotOnHand3 = new LotOnHand(); lotOnHand3.setLot(lot3); lotOnHand3.setQuantityOnHand(1L); stockCard.setLotOnHandListWrapper(Arrays.asList(lotOnHand1, lotOnHand2, lotOnHand3)); assertThat(stockCard.getNonEmptyLotOnHandList().size(), is(2)); assertThat(stockCard.getNonEmptyLotOnHandList().get(0), is(lotOnHand1)); assertThat(stockCard.getNonEmptyLotOnHandList().get(1), is(lotOnHand3)); }