@Test public void shouldReturnOverriddenIsaAmountIfOverriddenISANotNull() throws Exception { ProgramProduct programProduct = new ProgramProduct(); programProduct.setProduct(new Product()); programProduct.getProduct().setPackSize(7); FacilityProgramProduct facilityProgramProduct = new FacilityProgramProduct(programProduct, 3L); assertNull(facilityProgramProduct.calculateIsa(420L, 5)); facilityProgramProduct.setOverriddenIsa(ISABuilder.build()); assertNotNull(facilityProgramProduct.calculateIsa(420L, 5)); }
public Integer calculateIsa(Long population, Integer numberOfMonthsInPeriod) { if(population == null) return null; Integer idealQuantity; if (this.overriddenIsa != null) idealQuantity = this.overriddenIsa.calculate(population); else if (this.programProductIsa != null) idealQuantity = this.programProductIsa.calculate(population); else return null; idealQuantity = idealQuantity * numberOfMonthsInPeriod; return idealQuantity < 0 ? 0 : idealQuantity; }
FacilityProgramProduct extends ProgramProduct { public Integer calculateIsa(Long population, Integer numberOfMonthsInPeriod) { if(population == null) return null; Integer idealQuantity; if (this.overriddenIsa != null) idealQuantity = this.overriddenIsa.calculate(population); else if (this.programProductIsa != null) idealQuantity = this.programProductIsa.calculate(population); else return null; idealQuantity = idealQuantity * numberOfMonthsInPeriod; return idealQuantity < 0 ? 0 : idealQuantity; } }
FacilityProgramProduct extends ProgramProduct { public Integer calculateIsa(Long population, Integer numberOfMonthsInPeriod) { if(population == null) return null; Integer idealQuantity; if (this.overriddenIsa != null) idealQuantity = this.overriddenIsa.calculate(population); else if (this.programProductIsa != null) idealQuantity = this.programProductIsa.calculate(population); else return null; idealQuantity = idealQuantity * numberOfMonthsInPeriod; return idealQuantity < 0 ? 0 : idealQuantity; } FacilityProgramProduct(ProgramProduct programProduct, Long facilityId);  FacilityProgramProduct(ProgramProduct programProduct, Long facilityId, ISA isa); }
FacilityProgramProduct extends ProgramProduct { public Integer calculateIsa(Long population, Integer numberOfMonthsInPeriod) { if(population == null) return null; Integer idealQuantity; if (this.overriddenIsa != null) idealQuantity = this.overriddenIsa.calculate(population); else if (this.programProductIsa != null) idealQuantity = this.programProductIsa.calculate(population); else return null; idealQuantity = idealQuantity * numberOfMonthsInPeriod; return idealQuantity < 0 ? 0 : idealQuantity; } 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 Integer calculateIsa(Long population, Integer numberOfMonthsInPeriod) { if(population == null) return null; Integer idealQuantity; if (this.overriddenIsa != null) idealQuantity = this.overriddenIsa.calculate(population); else if (this.programProductIsa != null) idealQuantity = this.programProductIsa.calculate(population); else return null; idealQuantity = idealQuantity * numberOfMonthsInPeriod; return idealQuantity < 0 ? 0 : idealQuantity; } 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);  }