@Test public void shouldGetLatestMovementDateAsThePreviousMovementDate() throws ParseException { StockCard stockCard = new StockCard(); StockMovementItem stockMovementItem1 = new StockMovementItemBuilder().withMovementDate("2015-10-10").build(); StockMovementItem stockMovementItem2 = new StockMovementItemBuilder().withMovementDate("2015-11-12").build(); StockMovementItem stockMovementItem3 = new StockMovementItemBuilder().withMovementDate("2015-09-10").build(); stockCard.setStockMovementItemsWrapper(newArrayList(stockMovementItem1, stockMovementItem2, stockMovementItem3)); Date previousMovementDate = viewHolder.getPreviousMovementDate(stockCard); assertThat(DateUtil.formatDate(previousMovementDate), is("12 Nov 2015")); }
protected Date getPreviousMovementDate(StockCard stockCard) { List<StockMovementItem> stockMovements = stockCard.getStockMovementItemsWrapper(); if (stockMovements != null) { if (!stockMovements.isEmpty()) { Collections.sort(stockMovements, (item1, item2) -> item1.getMovementDate().compareTo(item2.getMovementDate())); return stockMovements.get(stockMovements.size() - 1).getMovementDate(); } } return null; }
StockMovementViewHolder extends BaseViewHolder { protected Date getPreviousMovementDate(StockCard stockCard) { List<StockMovementItem> stockMovements = stockCard.getStockMovementItemsWrapper(); if (stockMovements != null) { if (!stockMovements.isEmpty()) { Collections.sort(stockMovements, (item1, item2) -> item1.getMovementDate().compareTo(item2.getMovementDate())); return stockMovements.get(stockMovements.size() - 1).getMovementDate(); } } return null; } }
StockMovementViewHolder extends BaseViewHolder { protected Date getPreviousMovementDate(StockCard stockCard) { List<StockMovementItem> stockMovements = stockCard.getStockMovementItemsWrapper(); if (stockMovements != null) { if (!stockMovements.isEmpty()) { Collections.sort(stockMovements, (item1, item2) -> item1.getMovementDate().compareTo(item2.getMovementDate())); return stockMovements.get(stockMovements.size() - 1).getMovementDate(); } } return null; } StockMovementViewHolder(View itemView); }
StockMovementViewHolder extends BaseViewHolder { protected Date getPreviousMovementDate(StockCard stockCard) { List<StockMovementItem> stockMovements = stockCard.getStockMovementItemsWrapper(); if (stockMovements != null) { if (!stockMovements.isEmpty()) { Collections.sort(stockMovements, (item1, item2) -> item1.getMovementDate().compareTo(item2.getMovementDate())); return stockMovements.get(stockMovements.size() - 1).getMovementDate(); } } return null; } StockMovementViewHolder(View itemView); void populate(final StockMovementViewModel model, StockCard stockCard); void highLightAndShowBottomBtn(); }
StockMovementViewHolder extends BaseViewHolder { protected Date getPreviousMovementDate(StockCard stockCard) { List<StockMovementItem> stockMovements = stockCard.getStockMovementItemsWrapper(); if (stockMovements != null) { if (!stockMovements.isEmpty()) { Collections.sort(stockMovements, (item1, item2) -> item1.getMovementDate().compareTo(item2.getMovementDate())); return stockMovements.get(stockMovements.size() - 1).getMovementDate(); } } return null; } StockMovementViewHolder(View itemView); void populate(final StockMovementViewModel model, StockCard stockCard); void highLightAndShowBottomBtn();  }