@Test public void shouldReturnNullIfInvalidProductCode() { Double whoRatio = 127D; String productCode = "BCG"; ProgramSupported programSupported = new ProgramSupported(); FacilityProgramProduct facilityProgramProduct = mock(FacilityProgramProduct.class); when(facilityProgramProduct.getWhoRatio()).thenReturn(whoRatio); Product product = mock(Product.class); when(product.getCode()).thenReturn(productCode); when(facilityProgramProduct.getProduct()).thenReturn(product); programSupported.setProgramProducts(asList(facilityProgramProduct)); assertThat(programSupported.getWhoRatioFor("invalidProductCode"), is(nullValue())); }
@JsonIgnore public Double getWhoRatioFor(final String productCode) { FacilityProgramProduct facilityProgramProduct = (FacilityProgramProduct) CollectionUtils.find(this.getProgramProducts(), new Predicate() { @Override public boolean evaluate(Object o) { return ((FacilityProgramProduct) o).getProduct().getCode().equals(productCode); } }); return (facilityProgramProduct == null) ? null : facilityProgramProduct.getWhoRatio(); }
ProgramSupported extends BaseModel implements Importable { @JsonIgnore public Double getWhoRatioFor(final String productCode) { FacilityProgramProduct facilityProgramProduct = (FacilityProgramProduct) CollectionUtils.find(this.getProgramProducts(), new Predicate() { @Override public boolean evaluate(Object o) { return ((FacilityProgramProduct) o).getProduct().getCode().equals(productCode); } }); return (facilityProgramProduct == null) ? null : facilityProgramProduct.getWhoRatio(); } }
ProgramSupported extends BaseModel implements Importable { @JsonIgnore public Double getWhoRatioFor(final String productCode) { FacilityProgramProduct facilityProgramProduct = (FacilityProgramProduct) CollectionUtils.find(this.getProgramProducts(), new Predicate() { @Override public boolean evaluate(Object o) { return ((FacilityProgramProduct) o).getProduct().getCode().equals(productCode); } }); return (facilityProgramProduct == null) ? null : facilityProgramProduct.getWhoRatio(); } ProgramSupported(Long programId, Boolean active, Date startDate); }
ProgramSupported extends BaseModel implements Importable { @JsonIgnore public Double getWhoRatioFor(final String productCode) { FacilityProgramProduct facilityProgramProduct = (FacilityProgramProduct) CollectionUtils.find(this.getProgramProducts(), new Predicate() { @Override public boolean evaluate(Object o) { return ((FacilityProgramProduct) o).getProduct().getCode().equals(productCode); } }); return (facilityProgramProduct == null) ? null : facilityProgramProduct.getWhoRatio(); } ProgramSupported(Long programId, Boolean active, Date startDate); void isValid(); @SuppressWarnings("unused") String getStringStartDate(); @JsonIgnore Double getWhoRatioFor(final String productCode); @JsonIgnore Integer getPackSizeFor(final String productCode); }
ProgramSupported extends BaseModel implements Importable { @JsonIgnore public Double getWhoRatioFor(final String productCode) { FacilityProgramProduct facilityProgramProduct = (FacilityProgramProduct) CollectionUtils.find(this.getProgramProducts(), new Predicate() { @Override public boolean evaluate(Object o) { return ((FacilityProgramProduct) o).getProduct().getCode().equals(productCode); } }); return (facilityProgramProduct == null) ? null : facilityProgramProduct.getWhoRatio(); } ProgramSupported(Long programId, Boolean active, Date startDate); void isValid(); @SuppressWarnings("unused") String getStringStartDate(); @JsonIgnore Double getWhoRatioFor(final String productCode); @JsonIgnore Integer getPackSizeFor(final String productCode);  }