use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method createItemBasedOfferWithItemCriteria.
public List<Offer> createItemBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String qualRule, String targetRule) {
List<Offer> offers = createItemBasedOffer(orderRule, targetRule, discountType);
if (qualRule != null) {
Offer firstOffer = offers.get(0);
OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
// qualCriteria.setQualifyingOffer(offers.get(0));
qualCriteria.setQuantity(1);
qualCriteria.setMatchRule(qualRule);
Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
xref.setOffer(firstOffer);
xref.setOfferItemCriteria(qualCriteria);
criterias.add(xref);
firstOffer.setQualifyingItemCriteriaXref(criterias);
}
return offers;
}
use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method createOrderBasedOfferWithItemCriteria.
public List<Offer> createOrderBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String orderItemMatchRule) {
List<Offer> offers = createOrderBasedOffer(orderRule, discountType);
Offer firstOffer = offers.get(0);
OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
// qualCriteria.setQualifyingOffer(offers.get(0));
qualCriteria.setQuantity(1);
qualCriteria.setMatchRule(orderItemMatchRule);
Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
xref.setOffer(firstOffer);
xref.setOfferItemCriteria(qualCriteria);
criterias.add(xref);
firstOffer.setQualifyingItemCriteriaXref(criterias);
return offers;
}
use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method createFGBasedOfferWithItemCriteria.
public List<Offer> createFGBasedOfferWithItemCriteria(String orderRule, String fgRule, OfferDiscountType discountType, String orderItemMatchRule) {
List<Offer> offers = createFGBasedOffer(orderRule, fgRule, discountType);
Offer firstOffer = offers.get(0);
OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
qualCriteria.setQuantity(1);
qualCriteria.setMatchRule(orderItemMatchRule);
Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
xref.setOffer(firstOffer);
xref.setOfferItemCriteria(qualCriteria);
criterias.add(xref);
firstOffer.setQualifyingItemCriteriaXref(criterias);
return offers;
}
use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupOfferProcessorTest method testCouldOrderItemMeetOfferRequirement.
public void testCouldOrderItemMeetOfferRequirement() {
replay();
PromotableOrder order = dataProvider.createBasicPromotableOrder();
List<Offer> offers = dataProvider.createFGBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", "fulfillmentGroup.address.postalCode==75244", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
OfferQualifyingCriteriaXref xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
boolean couldApply = fgProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
// test that the valid fg offer is included
assertTrue(couldApply);
offers = dataProvider.createFGBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", "fulfillmentGroup.address.postalCode==75244", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test5\"), MVEL.eval(\"toUpperCase()\",\"test6\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
couldApply = fgProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
// test that the invalid fg offer is excluded
assertFalse(couldApply);
verify();
}
use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.
the class OrderOfferProcessorTest method testCouldOrderItemMeetOfferRequirement.
public void testCouldOrderItemMeetOfferRequirement() throws Exception {
replay();
PromotableOrder order = dataProvider.createBasicPromotableOrder();
List<Offer> offers = dataProvider.createOrderBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
OfferQualifyingCriteriaXref xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
boolean couldApply = orderProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
// test that the valid order offer is included
assertTrue(couldApply);
offers = dataProvider.createOrderBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test5\"), MVEL.eval(\"toUpperCase()\",\"test6\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
couldApply = orderProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
// test that the invalid order offer is excluded
assertFalse(couldApply);
verify();
}
Aggregations