@Test public void shouldReturnActiveProductsOnly() { Long facilityId = 1L; Product product = new Product(); product.setActive(true); FacilityProgramProduct programProductActive = new FacilityProgramProduct(new ProgramProduct(new Program(), product, 10, true), facilityId, null); FacilityProgramProduct programProductInactive = new FacilityProgramProduct(new ProgramProduct(new Program(), product, 10, false) , facilityId, null); List<FacilityProgramProduct> activeFacilityProgramProducts = FacilityProgramProduct.filterActiveProducts(asList(programProductActive, programProductInactive)); assertThat(activeFacilityProgramProducts.size(), is(1)); }
public static List<FacilityProgramProduct> filterActiveProducts(List<FacilityProgramProduct> programProducts) { List<FacilityProgramProduct> activeProgramProducts = (List<FacilityProgramProduct>) CollectionUtils.select(programProducts, new Predicate() { @Override public boolean evaluate(Object o) { FacilityProgramProduct programProduct = (FacilityProgramProduct) o; return programProduct.getActive() && programProduct.getProduct().getActive(); } }); return activeProgramProducts; }
FacilityProgramProduct extends ProgramProduct { public static List<FacilityProgramProduct> filterActiveProducts(List<FacilityProgramProduct> programProducts) { List<FacilityProgramProduct> activeProgramProducts = (List<FacilityProgramProduct>) CollectionUtils.select(programProducts, new Predicate() { @Override public boolean evaluate(Object o) { FacilityProgramProduct programProduct = (FacilityProgramProduct) o; return programProduct.getActive() && programProduct.getProduct().getActive(); } }); return activeProgramProducts; } }
FacilityProgramProduct extends ProgramProduct { public static List<FacilityProgramProduct> filterActiveProducts(List<FacilityProgramProduct> programProducts) { List<FacilityProgramProduct> activeProgramProducts = (List<FacilityProgramProduct>) CollectionUtils.select(programProducts, new Predicate() { @Override public boolean evaluate(Object o) { FacilityProgramProduct programProduct = (FacilityProgramProduct) o; return programProduct.getActive() && programProduct.getProduct().getActive(); } }); return activeProgramProducts; } FacilityProgramProduct(ProgramProduct programProduct, Long facilityId);  FacilityProgramProduct(ProgramProduct programProduct, Long facilityId, ISA isa); }
FacilityProgramProduct extends ProgramProduct { public static List<FacilityProgramProduct> filterActiveProducts(List<FacilityProgramProduct> programProducts) { List<FacilityProgramProduct> activeProgramProducts = (List<FacilityProgramProduct>) CollectionUtils.select(programProducts, new Predicate() { @Override public boolean evaluate(Object o) { FacilityProgramProduct programProduct = (FacilityProgramProduct) o; return programProduct.getActive() && programProduct.getProduct().getActive(); } }); return activeProgramProducts; } FacilityProgramProduct(ProgramProduct programProduct, Long facilityId);  FacilityProgramProduct(ProgramProduct programProduct, Long facilityId, ISA isa); @JsonIgnore ProductGroup getActiveProductGroup(); Integer calculateIsa(Long population, Integer numberOfMonthsInPeriod); Integer calculateIsaByPackSize(Long population, Integer numberOfMonthsInPeriod); @JsonIgnore Double getWhoRatio(); static List<FacilityProgramProduct> filterActiveProducts(List<FacilityProgramProduct> programProducts); }
FacilityProgramProduct extends ProgramProduct { public static List<FacilityProgramProduct> filterActiveProducts(List<FacilityProgramProduct> programProducts) { List<FacilityProgramProduct> activeProgramProducts = (List<FacilityProgramProduct>) CollectionUtils.select(programProducts, new Predicate() { @Override public boolean evaluate(Object o) { FacilityProgramProduct programProduct = (FacilityProgramProduct) o; return programProduct.getActive() && programProduct.getProduct().getActive(); } }); return activeProgramProducts; } FacilityProgramProduct(ProgramProduct programProduct, Long facilityId);  FacilityProgramProduct(ProgramProduct programProduct, Long facilityId, ISA isa); @JsonIgnore ProductGroup getActiveProductGroup(); Integer calculateIsa(Long population, Integer numberOfMonthsInPeriod); Integer calculateIsaByPackSize(Long population, Integer numberOfMonthsInPeriod); @JsonIgnore Double getWhoRatio(); static List<FacilityProgramProduct> filterActiveProducts(List<FacilityProgramProduct> programProducts);  }