@Test public void shouldGetStockCardDataForOneFacility() { setupOneFacilityStockCardListWithOneCardOneEntry(); setupSecondStockCardOneEntry(); stockCards.add(secondStockCard); when(stockCardMapper.getAllByFacility(facility.getId())).thenReturn(stockCards); when(facilityMapper.getById(facility.getId())).thenReturn(facility); when(stockCardMapper.getLastUpdatedTimeforStockDataByFacility(facility.getId())).thenReturn(DateUtil.parseDate("2011-11-11 11:11:11")); List<FacilityProductReportEntry> entryList = facilityProductsReportDataProvider.getReportDataForAllProducts(facility.getId(), DateUtil.parseDate("2012-12-12 12:12:12")); assertThat(entryList.size(), is(2)); assertThat(entryList.get(0).getProductQuantity(), is(100L)); assertThat(entryList.get(1).getProductQuantity(), is(200L)); assertThat(entryList.get(0).getCode(), is(product.getCode())); assertThat(entryList.get(1).getCode(), is(secondProduct.getCode())); assertThat(DateUtil.formatDate(entryList.get(0).getLastSyncDate()), is("2011-11-11 11:11:11")); assertThat(DateUtil.formatDate(entryList.get(1).getLastSyncDate()), is("2011-11-11 11:11:11")); }
public List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime) { List<StockCard> stockCards = stockCardMapper.getAllByFacility(facilityId); final Date lastSyncedDate = stockCardMapper.getLastUpdatedTimeforStockDataByFacility(facilityId); final Facility facility = facilityMapper.getById(facilityId); return from(stockCards).transform(getReportEntry(endTime, lastSyncedDate)).transform(new Function<FacilityProductReportEntry, FacilityProductReportEntry>() { @Override public FacilityProductReportEntry apply(FacilityProductReportEntry input) { input.setFacilityName(facility.getName()); input.setLastSyncDate(lastSyncedDate); return input; } }).toList(); }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime) { List<StockCard> stockCards = stockCardMapper.getAllByFacility(facilityId); final Date lastSyncedDate = stockCardMapper.getLastUpdatedTimeforStockDataByFacility(facilityId); final Facility facility = facilityMapper.getById(facilityId); return from(stockCards).transform(getReportEntry(endTime, lastSyncedDate)).transform(new Function<FacilityProductReportEntry, FacilityProductReportEntry>() { @Override public FacilityProductReportEntry apply(FacilityProductReportEntry input) { input.setFacilityName(facility.getName()); input.setLastSyncDate(lastSyncedDate); return input; } }).toList(); } }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime) { List<StockCard> stockCards = stockCardMapper.getAllByFacility(facilityId); final Date lastSyncedDate = stockCardMapper.getLastUpdatedTimeforStockDataByFacility(facilityId); final Facility facility = facilityMapper.getById(facilityId); return from(stockCards).transform(getReportEntry(endTime, lastSyncedDate)).transform(new Function<FacilityProductReportEntry, FacilityProductReportEntry>() { @Override public FacilityProductReportEntry apply(FacilityProductReportEntry input) { input.setFacilityName(facility.getName()); input.setLastSyncDate(lastSyncedDate); return input; } }).toList(); }  }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime) { List<StockCard> stockCards = stockCardMapper.getAllByFacility(facilityId); final Date lastSyncedDate = stockCardMapper.getLastUpdatedTimeforStockDataByFacility(facilityId); final Facility facility = facilityMapper.getById(facilityId); return from(stockCards).transform(getReportEntry(endTime, lastSyncedDate)).transform(new Function<FacilityProductReportEntry, FacilityProductReportEntry>() { @Override public FacilityProductReportEntry apply(FacilityProductReportEntry input) { input.setFacilityName(facility.getName()); input.setLastSyncDate(lastSyncedDate); return input; } }).toList(); }  List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime); List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime); }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime) { List<StockCard> stockCards = stockCardMapper.getAllByFacility(facilityId); final Date lastSyncedDate = stockCardMapper.getLastUpdatedTimeforStockDataByFacility(facilityId); final Facility facility = facilityMapper.getById(facilityId); return from(stockCards).transform(getReportEntry(endTime, lastSyncedDate)).transform(new Function<FacilityProductReportEntry, FacilityProductReportEntry>() { @Override public FacilityProductReportEntry apply(FacilityProductReportEntry input) { input.setFacilityName(facility.getName()); input.setLastSyncDate(lastSyncedDate); return input; } }).toList(); }  List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime); List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime); static final String DISTRICT_CODE; static final String PROVINCE_CODE; }