@Test public void shouldReturnTrueIfFacilityInGeographicZone() { GeographicZone district = new GeographicZone(); district.setCode("District"); district.setLevel(new GeographicLevel(1L, FacilityProductsReportDataProvider.DISTRICT_CODE, "District", 5)); GeographicZone province = new GeographicZone(); province.setCode("Maputo"); province.setLevel(new GeographicLevel(2L, FacilityProductsReportDataProvider.PROVINCE_CODE, "Province", 6)); district.setParent(province); Facility facility = new Facility(); facility.setGeographicZone(district); assertThat(FacilityProductsReportDataProvider.inGeographicZone(district, facility), is(true)); assertThat(FacilityProductsReportDataProvider.inGeographicZone(province, facility), is(true)); }
protected static boolean inGeographicZone(GeographicZone geographicZone, Facility facility) { if (DISTRICT_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getCode()); } else if (PROVINCE_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getParent().getCode()); } return false; }
FacilityProductsReportDataProvider { protected static boolean inGeographicZone(GeographicZone geographicZone, Facility facility) { if (DISTRICT_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getCode()); } else if (PROVINCE_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getParent().getCode()); } return false; } }
FacilityProductsReportDataProvider { protected static boolean inGeographicZone(GeographicZone geographicZone, Facility facility) { if (DISTRICT_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getCode()); } else if (PROVINCE_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getParent().getCode()); } return false; }  }
FacilityProductsReportDataProvider { protected static boolean inGeographicZone(GeographicZone geographicZone, Facility facility) { if (DISTRICT_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getCode()); } else if (PROVINCE_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getParent().getCode()); } return false; }  List<FacilityProductReportEntry> getReportDataForSingleProduct(final Long geographicZoneId, final Long productId, final Date endTime); List<FacilityProductReportEntry> getReportDataForAllProducts(Long facilityId, final Date endTime); }
FacilityProductsReportDataProvider { protected static boolean inGeographicZone(GeographicZone geographicZone, Facility facility) { if (DISTRICT_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getCode()); } else if (PROVINCE_CODE.equalsIgnoreCase(geographicZone.getLevel().getCode())) { return geographicZone.getCode().equals(facility.getGeographicZone().getParent().getCode()); } return false; }  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; }