コード例 #1
0
  static {
    ProductMatcher toothBrushProductMatcher = new SingleProductMatcher(toothBrush);
    DiscountElement toothBrushFirstTwo = new DiscountElement(noDiscount, 2);
    DiscountElement toothBrushFreeOne = new DiscountElement(freeDiscount, 1);

    toothBrushPromotionElement = new PromotionElement();
    toothBrushPromotionElement.setDiscountElements(
        Lists.newArrayList(toothBrushFirstTwo, toothBrushFreeOne));
    toothBrushPromotionElement.setMatcher(toothBrushProductMatcher);
    toothBrushPromotionElement.setTotalRequired(3);

    ProductMatcher chipsProductMatcher = new SingleProductMatcher(chips);
    DiscountElement chipsDiscount = new DiscountElement(fixed200Discount, 1);
    chipsPromotionElement = new PromotionElement();
    chipsPromotionElement.setDiscountElements(Lists.newArrayList(chipsDiscount));
    chipsPromotionElement.setMatcher(chipsProductMatcher);
    chipsPromotionElement.setTotalRequired(1);

    ProductMatcher salsaProductMatcher = new SingleProductMatcher(salsa);
    DiscountElement salsaDiscount = new DiscountElement(fixed299Discount, 1);
    salsaPromotionElement = new PromotionElement();
    salsaPromotionElement.setDiscountElements(Lists.newArrayList(salsaDiscount));
    salsaPromotionElement.setMatcher(salsaProductMatcher);
    salsaPromotionElement.setTotalRequired(1);
  }
コード例 #2
0
 @Before
 public void setup() {
   promotionElement = new PromotionElement();
   promotionElement.setDiscountElements(Lists.newArrayList(firstTwo, nextOne));
   promotionElement.setMatcher(productMatcher);
   promotionElement.setTotalRequired(3);
 }