StockCard extends BaseModel implements Comparable<StockCard> { public Date getLastStockMovementDate() { if (getStockMovementItemsWrapper().isEmpty()) { return null; } return Collections.max(getStockMovementItemsWrapper(), (lhs, rhs) -> lhs.getMovementDate().compareTo(rhs.getMovementDate())).getMovementDate(); }  @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 shouldGetLatestMovementDate() throws Exception { item1.setMovementDate(DateUtil.parseString("2016-02-19", DateUtil.DB_DATE_FORMAT)); item2.setMovementDate(DateUtil.parseString("2016-03-19", DateUtil.DB_DATE_FORMAT)); item3.setMovementDate(DateUtil.parseString("2016-03-18", DateUtil.DB_DATE_FORMAT)); assertEquals(item2.getMovementDate(), stockCard.getLastStockMovementDate()); }