@Test public void shouldGetSpecificProductDataForAllFacilitiesInGeographicZone() { setupOneFacilityStockCardListWithOneCardOneEntry(); setupSecondFacilityWithSameFirstProduct(); when(facilityMapper.getAllReportFacilities()).thenReturn(asList(facility, secondFacility)); when(stockCardMapper.getAllByFacility(facility.getId())).thenReturn(stockCards); when(stockCardMapper.getAllByFacility(secondFacility.getId())).thenReturn(secondFacilityStockCards); when(stockCardMapper.getLastUpdatedTimeforStockDataByFacility(facility.getId())).thenReturn(DateUtil.parseDate("2011-11-11 11:11:11")); when(stockCardMapper.getLastUpdatedTimeforStockDataByFacility(secondFacility.getId())).thenReturn(DateUtil.parseDate("2013-10-13 10:13:13")); List<FacilityProductReportEntry> entryList = facilityProductsReportDataProvider.getReportDataForSingleProduct(facility.getGeographicZone().getId(), product.getId(), DateUtil.parseDate("2018-11-11 11:11:11")); assertThat(entryList.size(), is(2)); assertThat(entryList.get(0).getProductName(), containsString(product.getPrimaryName())); assertThat(DateUtil.formatDate(entryList.get(0).getLastSyncDate()), is("2011-11-11 11:11:11")); assertThat(DateUtil.formatDate(entryList.get(1).getLastSyncDate()), is("2013-10-13 10:13:13")); assertThat(entryList.get(0).getProductQuantity(), is(100L)); assertThat(entryList.get(1).getProductQuantity(), is(300L)); }
public List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime) { List<Facility> facilities = getAllHealthFacilities(); final GeographicZone geographicZone = geographicZoneMapper.getWithParentById(geographicZoneId); if (geographicZone != null) { facilities = from(facilities).filter(new Predicate<Facility>() { @Override public boolean apply(Facility facility) { return inGeographicZone(geographicZone, facility); } }).toList(); } return fillReportEntryList(productId, endTime, facilities); }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime) { List<Facility> facilities = getAllHealthFacilities(); final GeographicZone geographicZone = geographicZoneMapper.getWithParentById(geographicZoneId); if (geographicZone != null) { facilities = from(facilities).filter(new Predicate<Facility>() { @Override public boolean apply(Facility facility) { return inGeographicZone(geographicZone, facility); } }).toList(); } return fillReportEntryList(productId, endTime, facilities); } }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime) { List<Facility> facilities = getAllHealthFacilities(); final GeographicZone geographicZone = geographicZoneMapper.getWithParentById(geographicZoneId); if (geographicZone != null) { facilities = from(facilities).filter(new Predicate<Facility>() { @Override public boolean apply(Facility facility) { return inGeographicZone(geographicZone, facility); } }).toList(); } return fillReportEntryList(productId, endTime, facilities); }  }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime) { List<Facility> facilities = getAllHealthFacilities(); final GeographicZone geographicZone = geographicZoneMapper.getWithParentById(geographicZoneId); if (geographicZone != null) { facilities = from(facilities).filter(new Predicate<Facility>() { @Override public boolean apply(Facility facility) { return inGeographicZone(geographicZone, facility); } }).toList(); } return fillReportEntryList(productId, endTime, facilities); }  List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime); List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime); }
FacilityProductsReportDataProvider { public List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime) { List<Facility> facilities = getAllHealthFacilities(); final GeographicZone geographicZone = geographicZoneMapper.getWithParentById(geographicZoneId); if (geographicZone != null) { facilities = from(facilities).filter(new Predicate<Facility>() { @Override public boolean apply(Facility facility) { return inGeographicZone(geographicZone, facility); } }).toList(); } return fillReportEntryList(productId, endTime, facilities); }  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; }