@Test public void isEligible_WhenDiscountHasNullTriggerValue_shouldReturnTrue_() throws Exception{ Discount discount = new Discount("discount1", "a discount", ORDER, DISCOUNT_RATE, AMOUNT, null, 0.1, null, 1, true,null,null, false); assertThat(discount.isEligible(2.0)).isTrue(); }
public boolean isEligible(Double itemsPrice){ if (triggerRule != null) { switch (triggerRule) { case AMOUNT: if (triggerValue != null && itemsPrice < triggerValue) { return false; } break; } } return true; }
Discount extends CatalogItem { public boolean isEligible(Double itemsPrice){ if (triggerRule != null) { switch (triggerRule) { case AMOUNT: if (triggerValue != null && itemsPrice < triggerValue) { return false; } break; } } return true; } }
Discount extends CatalogItem { public boolean isEligible(Double itemsPrice){ if (triggerRule != null) { switch (triggerRule) { case AMOUNT: if (triggerValue != null && itemsPrice < triggerValue) { return false; } break; } } return true; } Discount();  Discount(Long id);  Discount(String name, String description, ApplicableTo applicableTo, Type type, Trigger triggerRule, String voucherCode, Double discountValue, Double triggerValue, Integer usesPerCustomer, Boolean uniqueUse, Date startDate, Date endDate, Boolean disabled); }
Discount extends CatalogItem { public boolean isEligible(Double itemsPrice){ if (triggerRule != null) { switch (triggerRule) { case AMOUNT: if (triggerValue != null && itemsPrice < triggerValue) { return false; } break; } } return true; } Discount();  Discount(Long id);  Discount(String name, String description, ApplicableTo applicableTo, Type type, Trigger triggerRule, String voucherCode, Double discountValue, Double triggerValue, Integer usesPerCustomer, Boolean uniqueUse, Date startDate, Date endDate, Boolean disabled); boolean isEligible(Double itemsPrice); Double processDiscount(Double currentPrice, Double originItemsPrice); Type getType(); void setType(Type type); Trigger getTrigger(); void setTrigger(Trigger triggerRule); String getVoucherCode(); void setVoucherCode(String voucherCode); List<SKU> getSkus(); void setSkus(List<SKU> skus); List<Product> getProducts(); void setProducts(List<Product> products); Integer getUsesPerCustomer(); void setUsesPerCustomer(Integer usesPerCustomer); Boolean getUniqueUse(); void setUniqueUse(Boolean uniqueUse); Trigger getTriggerRule(); void setTriggerRule(Trigger triggerRule); ApplicableTo getApplicableTo(); void setApplicableTo(ApplicableTo applicableTo); Double getDiscountValue(); void setDiscountValue(Double discountValue); Boolean getRateType(); @Override boolean equals(Object o); @Override int hashCode(); }
Discount extends CatalogItem { public boolean isEligible(Double itemsPrice){ if (triggerRule != null) { switch (triggerRule) { case AMOUNT: if (triggerValue != null && itemsPrice < triggerValue) { return false; } break; } } return true; } Discount();  Discount(Long id);  Discount(String name, String description, ApplicableTo applicableTo, Type type, Trigger triggerRule, String voucherCode, Double discountValue, Double triggerValue, Integer usesPerCustomer, Boolean uniqueUse, Date startDate, Date endDate, Boolean disabled); boolean isEligible(Double itemsPrice); Double processDiscount(Double currentPrice, Double originItemsPrice); Type getType(); void setType(Type type); Trigger getTrigger(); void setTrigger(Trigger triggerRule); String getVoucherCode(); void setVoucherCode(String voucherCode); List<SKU> getSkus(); void setSkus(List<SKU> skus); List<Product> getProducts(); void setProducts(List<Product> products); Integer getUsesPerCustomer(); void setUsesPerCustomer(Integer usesPerCustomer); Boolean getUniqueUse(); void setUniqueUse(Boolean uniqueUse); Trigger getTriggerRule(); void setTriggerRule(Trigger triggerRule); ApplicableTo getApplicableTo(); void setApplicableTo(ApplicableTo applicableTo); Double getDiscountValue(); void setDiscountValue(Double discountValue); Boolean getRateType(); @Override boolean equals(Object o); @Override int hashCode();  }