@Test public void shouldReturnFacilityListWithActiveProgramProducts() { Facility facility = new Facility(); ProgramSupported programSupported = new ProgramSupported(); List<FacilityProgramProduct> programProducts = new ArrayList<>(); programSupported.setProgramProducts(programProducts); facility.setSupportedPrograms(asList(programSupported)); List<Facility> facilities = new ArrayList<>(asList(facility)); mockStatic(FacilityProgramProduct.class); when(FacilityProgramProduct.filterActiveProducts(programProducts)).thenReturn(programProducts); List<Facility> facilitiesWithActiveProducts = Facility.filterForActiveProducts(facilities); assertThat(facilitiesWithActiveProducts.get(0).getSupportedPrograms().get(0).getProgramProducts(), is(programProducts)); }
public static List<Facility> filterForActiveProducts(List<Facility> facilities) { for (Facility facility : facilities) { for (ProgramSupported programSupported : facility.getSupportedPrograms()) { programSupported.setProgramProducts(FacilityProgramProduct.filterActiveProducts(programSupported.getProgramProducts())); } } return facilities; }
Facility extends BaseModel implements Importable { public static List<Facility> filterForActiveProducts(List<Facility> facilities) { for (Facility facility : facilities) { for (ProgramSupported programSupported : facility.getSupportedPrograms()) { programSupported.setProgramProducts(FacilityProgramProduct.filterActiveProducts(programSupported.getProgramProducts())); } } return facilities; } }
Facility extends BaseModel implements Importable { public static List<Facility> filterForActiveProducts(List<Facility> facilities) { for (Facility facility : facilities) { for (ProgramSupported programSupported : facility.getSupportedPrograms()) { programSupported.setProgramProducts(FacilityProgramProduct.filterActiveProducts(programSupported.getProgramProducts())); } } return facilities; } Facility(Long id);  Facility(Long id, String code, String name, FacilityOperator operatedBy, GeographicZone geographicZone, FacilityType facilityType, boolean virtualFacility);  Facility(Long id, boolean enabled, boolean active, Long modifiedBy); }
Facility extends BaseModel implements Importable { public static List<Facility> filterForActiveProducts(List<Facility> facilities) { for (Facility facility : facilities) { for (ProgramSupported programSupported : facility.getSupportedPrograms()) { programSupported.setProgramProducts(FacilityProgramProduct.filterActiveProducts(programSupported.getProgramProducts())); } } return facilities; } Facility(Long id);  Facility(Long id, String code, String name, FacilityOperator operatedBy, GeographicZone geographicZone, FacilityType facilityType, boolean virtualFacility);  Facility(Long id, boolean enabled, boolean active, Long modifiedBy); @Override boolean equals(Object o); @Override int hashCode(); Facility basicInformation(); static Facility createFacilityToBeDeleted(Long facilityId, Long modifiedBy); static Facility createFacilityToBeRestored(Long facilityId, Long modifiedBy); void validate(); boolean isValid(Facility parentFacility); @SuppressWarnings("unused") String getStringGoLiveDate(); @SuppressWarnings("unused") String getStringGoDownDate(); @JsonIgnore Double getWhoRatioFor(String productCode); static List<Facility> filterForActiveProducts(List<Facility> facilities); @JsonIgnore Integer getPackSizeFor(String productCode); }
Facility extends BaseModel implements Importable { public static List<Facility> filterForActiveProducts(List<Facility> facilities) { for (Facility facility : facilities) { for (ProgramSupported programSupported : facility.getSupportedPrograms()) { programSupported.setProgramProducts(FacilityProgramProduct.filterActiveProducts(programSupported.getProgramProducts())); } } return facilities; } Facility(Long id);  Facility(Long id, String code, String name, FacilityOperator operatedBy, GeographicZone geographicZone, FacilityType facilityType, boolean virtualFacility);  Facility(Long id, boolean enabled, boolean active, Long modifiedBy); @Override boolean equals(Object o); @Override int hashCode(); Facility basicInformation(); static Facility createFacilityToBeDeleted(Long facilityId, Long modifiedBy); static Facility createFacilityToBeRestored(Long facilityId, Long modifiedBy); void validate(); boolean isValid(Facility parentFacility); @SuppressWarnings("unused") String getStringGoLiveDate(); @SuppressWarnings("unused") String getStringGoDownDate(); @JsonIgnore Double getWhoRatioFor(String productCode); static List<Facility> filterForActiveProducts(List<Facility> facilities); @JsonIgnore Integer getPackSizeFor(String productCode);  }