StockHistoryViewModel { public List<StockHistoryMovementItemViewModel> filter(final int days) { filteredMovementItemViewModelList.clear(); Date now = new Date(LMISApp.getInstance().getCurrentTimeMillis()); filteredMovementItemViewModelList.addAll(FluentIterable.from(allMovementItemViewModelList) .filter(stockHistoryMovementItemViewModel -> !(stockHistoryMovementItemViewModel.getStockMovementItem().getMovementDate()) .before(DateUtil.minusDayOfMonth(now, days))).toList()); return filteredMovementItemViewModelList; } StockHistoryViewModel(StockCard stockCard); List<StockHistoryMovementItemViewModel> filter(final int days); SpannableStringBuilder getStyledProductName(); SpannableStringBuilder getStyledProductUnit();  }
@Test public void shouldFilter() throws Exception { LMISTestApp.getInstance().setCurrentTimeMillis(DateUtil.parseString("2017-01-06", DateUtil.DB_DATE_FORMAT).getTime()); viewModel.filter(7); assertEquals(1, viewModel.getFilteredMovementItemViewModelList().size()); assertEquals("3", viewModel.getFilteredMovementItemViewModelList().get(0).getDocumentNumber()); viewModel.filter(365); assertEquals(2, viewModel.getFilteredMovementItemViewModelList().size()); assertEquals("2", viewModel.getFilteredMovementItemViewModelList().get(0).getDocumentNumber()); assertEquals("3", viewModel.getFilteredMovementItemViewModelList().get(1).getDocumentNumber()); }