Search in sources :

Example 1 with PromotableItemFactoryImpl

use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl in project BroadleafCommerce by BroadleafCommerce.

the class CandidateItemOfferTest method setUp.

@Override
protected void setUp() throws Exception {
    OfferDataItemProvider dataProvider = new OfferDataItemProvider();
    CandidateItemOfferImpl candidate = new CandidateItemOfferImpl();
    Category category1 = new CategoryImpl();
    category1.setName("test1");
    category1.setId(1L);
    Product product1 = new ProductImpl();
    Sku sku1 = new SkuImpl();
    sku1.setName("test1");
    sku1.setDiscountable(true);
    sku1.setRetailPrice(new Money(19.99D));
    product1.setDefaultSku(sku1);
    CategoryProductXref xref1 = new CategoryProductXrefImpl();
    xref1.setProduct(product1);
    xref1.setCategory(category1);
    category1.getAllProductXrefs().add(xref1);
    Category category2 = new CategoryImpl();
    category2.setName("test2");
    category2.setId(2L);
    Product product2 = new ProductImpl();
    Sku sku2 = new SkuImpl();
    sku2.setName("test2");
    sku2.setDiscountable(true);
    sku2.setRetailPrice(new Money(29.99D));
    product2.setDefaultSku(sku2);
    CategoryProductXref xref2 = new CategoryProductXrefImpl();
    xref2.setProduct(product2);
    xref2.setCategory(category2);
    category2.getAllProductXrefs().add(xref2);
    DiscreteOrderItemImpl orderItem1 = new DiscreteOrderItemImpl();
    orderItem1.setCategory(category1);
    orderItem1.setName("test1");
    orderItem1.setOrderItemType(OrderItemType.DISCRETE);
    orderItem1.setProduct(product1);
    orderItem1.setQuantity(2);
    orderItem1.setSku(sku1);
    Order order = new OrderImpl();
    orderItem1.setOrder(order);
    promotableOrder = new PromotableOrderImpl(order, new PromotableItemFactoryImpl(), false);
    offer = dataProvider.createItemBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))", "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))").get(0);
    candidateOffer = new PromotableCandidateItemOfferImpl(promotableOrder, offer);
    promotableOrderItem = new PromotableOrderItemImpl(orderItem1, null, new PromotableItemFactoryImpl(), false);
    OrderItemPriceDetail pdetail = new OrderItemPriceDetailImpl();
    pdetail.setOrderItem(orderItem1);
    pdetail.setQuantity(2);
    priceDetail = new PromotableOrderItemPriceDetailImpl(promotableOrderItem, 2);
    List<PromotableOrderItem> items = new ArrayList<PromotableOrderItem>();
    items.add(promotableOrderItem);
    promotableCandidate = new PromotableCandidateItemOfferImpl(promotableOrder, offer);
    OfferTargetCriteriaXref xref = offer.getTargetItemCriteriaXref().iterator().next();
    promotableCandidate.getCandidateTargetsMap().put(xref.getOfferItemCriteria(), items);
}
Also used : Category(org.broadleafcommerce.core.catalog.domain.Category) PromotableOrderImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl) CategoryProductXref(org.broadleafcommerce.core.catalog.domain.CategoryProductXref) DiscreteOrderItemImpl(org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl) OrderItemPriceDetailImpl(org.broadleafcommerce.core.order.domain.OrderItemPriceDetailImpl) PromotableOrderItemPriceDetailImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetailImpl) ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) PromotableCandidateItemOfferImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOfferImpl) PromotableOrderItem(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem) Money(org.broadleafcommerce.common.money.Money) PromotableItemFactoryImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl) CategoryProductXrefImpl(org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl) PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) Order(org.broadleafcommerce.core.order.domain.Order) PromotableOrderItemImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemImpl) CategoryImpl(org.broadleafcommerce.core.catalog.domain.CategoryImpl) SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) ProductImpl(org.broadleafcommerce.core.catalog.domain.ProductImpl) PromotableOrderImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl) OrderImpl(org.broadleafcommerce.core.order.domain.OrderImpl) PromotableCandidateItemOfferImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOfferImpl) OfferDataItemProvider(org.broadleafcommerce.core.offer.service.OfferDataItemProvider) OrderItemPriceDetail(org.broadleafcommerce.core.order.domain.OrderItemPriceDetail) PromotableOrderItemPriceDetail(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetail) Sku(org.broadleafcommerce.core.catalog.domain.Sku) PromotableOrderItemPriceDetailImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetailImpl)

Example 2 with PromotableItemFactoryImpl

use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl in project BroadleafCommerce by BroadleafCommerce.

the class OfferServiceTest method setUp.

@Override
protected void setUp() throws Exception {
    offerService = new OfferServiceImpl() {

        @Override
        protected List<OfferCode> refreshOfferCodesIfApplicable(Order order) {
            return order.getAddedOfferCodes();
        }
    };
    customerOfferDaoMock = EasyMock.createMock(CustomerOfferDao.class);
    orderServiceMock = EasyMock.createMock(OrderService.class);
    offerCodeDaoMock = EasyMock.createMock(OfferCodeDao.class);
    offerDaoMock = EasyMock.createMock(OfferDao.class);
    orderItemDaoMock = EasyMock.createMock(OrderItemDao.class);
    offerService.setCustomerOfferDao(customerOfferDaoMock);
    offerService.setOfferCodeDao(offerCodeDaoMock);
    offerService.setOfferDao(offerDaoMock);
    offerService.setOrderService(orderServiceMock);
    orderItemServiceMock = EasyMock.createMock(OrderItemService.class);
    fgItemDaoMock = EasyMock.createMock(FulfillmentGroupItemDao.class);
    fgServiceMock = EasyMock.createMock(FulfillmentGroupService.class);
    multishipOptionServiceMock = EasyMock.createMock(OrderMultishipOptionService.class);
    offerTimeZoneProcessorMock = EasyMock.createMock(OfferTimeZoneProcessor.class);
    OfferServiceUtilitiesImpl offerServiceUtilities = new OfferServiceUtilitiesImpl();
    offerServiceUtilities.setOfferDao(offerDaoMock);
    offerServiceUtilities.setPromotableItemFactory(new PromotableItemFactoryImpl());
    OrderOfferProcessorImpl orderProcessor = new OrderOfferProcessorImpl();
    orderProcessor.setOfferDao(offerDaoMock);
    orderProcessor.setOrderItemDao(orderItemDaoMock);
    orderProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
    orderProcessor.setOfferTimeZoneProcessor(offerTimeZoneProcessorMock);
    orderProcessor.setOfferServiceUtilities(offerServiceUtilities);
    offerService.setOrderOfferProcessor(orderProcessor);
    ItemOfferProcessorImpl itemProcessor = new ItemOfferProcessorImpl();
    itemProcessor.setOfferDao(offerDaoMock);
    itemProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
    itemProcessor.setOfferServiceUtilities(offerServiceUtilities);
    offerService.setItemOfferProcessor(itemProcessor);
    FulfillmentGroupOfferProcessor fgProcessor = new FulfillmentGroupOfferProcessorImpl();
    fgProcessor.setOfferDao(offerDaoMock);
    fgProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
    offerService.setFulfillmentGroupOfferProcessor(fgProcessor);
    offerService.setPromotableItemFactory(new PromotableItemFactoryImpl());
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) FulfillmentGroupItemDao(org.broadleafcommerce.core.order.dao.FulfillmentGroupItemDao) ItemOfferProcessorImpl(org.broadleafcommerce.core.offer.service.processor.ItemOfferProcessorImpl) FulfillmentGroupOfferProcessorImpl(org.broadleafcommerce.core.offer.service.processor.FulfillmentGroupOfferProcessorImpl) OrderItemDao(org.broadleafcommerce.core.order.dao.OrderItemDao) CustomerOfferDao(org.broadleafcommerce.core.offer.dao.CustomerOfferDao) OrderMultishipOptionService(org.broadleafcommerce.core.order.service.OrderMultishipOptionService) FulfillmentGroupService(org.broadleafcommerce.core.order.service.FulfillmentGroupService) FulfillmentGroupOfferProcessor(org.broadleafcommerce.core.offer.service.processor.FulfillmentGroupOfferProcessor) PromotableItemFactoryImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl) OrderItemService(org.broadleafcommerce.core.order.service.OrderItemService) OfferTimeZoneProcessor(org.broadleafcommerce.core.offer.service.processor.OfferTimeZoneProcessor) List(java.util.List) ArrayList(java.util.ArrayList) OrderOfferProcessorImpl(org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessorImpl) OrderService(org.broadleafcommerce.core.order.service.OrderService) OfferCodeDao(org.broadleafcommerce.core.offer.dao.OfferCodeDao) CustomerOfferDao(org.broadleafcommerce.core.offer.dao.CustomerOfferDao) OfferDao(org.broadleafcommerce.core.offer.dao.OfferDao)

Example 3 with PromotableItemFactoryImpl

use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl in project BroadleafCommerce by BroadleafCommerce.

the class ItemOfferProcessorTest method setUp.

@Override
protected void setUp() throws Exception {
    CustomerOfferDao customerOfferDaoMock = EasyMock.createMock(CustomerOfferDao.class);
    OfferCodeDao offerCodeDaoMock = EasyMock.createMock(OfferCodeDao.class);
    offerDaoMock = EasyMock.createMock(OfferDao.class);
    orderItemDaoMock = EasyMock.createMock(OrderItemDao.class);
    orderServiceMock = EasyMock.createMock(OrderService.class);
    orderItemServiceMock = EasyMock.createMock(OrderItemService.class);
    fgItemDaoMock = EasyMock.createMock(FulfillmentGroupItemDao.class);
    fgServiceMock = EasyMock.createMock(FulfillmentGroupService.class);
    multishipOptionServiceMock = EasyMock.createMock(OrderMultishipOptionService.class);
    offerTimeZoneProcessorMock = EasyMock.createMock(OfferTimeZoneProcessor.class);
    OfferServiceUtilitiesImpl offerServiceUtilities = new OfferServiceUtilitiesImpl();
    offerServiceUtilities.setOfferDao(offerDaoMock);
    offerServiceUtilities.setPromotableItemFactory(new PromotableItemFactoryImpl());
    itemProcessor = new ItemOfferProcessorImpl();
    itemProcessor.setOfferDao(offerDaoMock);
    itemProcessor.setOrderItemDao(orderItemDaoMock);
    itemProcessor.setOfferTimeZoneProcessor(offerTimeZoneProcessorMock);
    itemProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
    itemProcessor.setOfferServiceUtilities(offerServiceUtilities);
    offerService = new OfferServiceImpl();
    OrderOfferProcessorImpl orderProcessor = new OrderOfferProcessorImpl();
    orderProcessor.setOfferDao(offerDaoMock);
    orderProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
    orderProcessor.setOfferTimeZoneProcessor(offerTimeZoneProcessorMock);
    orderProcessor.setOrderItemDao(orderItemDaoMock);
    orderProcessor.setOfferServiceUtilities(offerServiceUtilities);
    offerService.setCustomerOfferDao(customerOfferDaoMock);
    offerService.setOfferCodeDao(offerCodeDaoMock);
    offerService.setOfferDao(offerDaoMock);
    offerService.setOrderOfferProcessor(orderProcessor);
    offerService.setItemOfferProcessor(itemProcessor);
    offerService.setPromotableItemFactory(new PromotableItemFactoryImpl());
    offerService.setOrderService(orderServiceMock);
}
Also used : FulfillmentGroupItemDao(org.broadleafcommerce.core.order.dao.FulfillmentGroupItemDao) OrderItemDao(org.broadleafcommerce.core.order.dao.OrderItemDao) CustomerOfferDao(org.broadleafcommerce.core.offer.dao.CustomerOfferDao) OrderMultishipOptionService(org.broadleafcommerce.core.order.service.OrderMultishipOptionService) FulfillmentGroupService(org.broadleafcommerce.core.order.service.FulfillmentGroupService) PromotableItemFactoryImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl) OfferServiceImpl(org.broadleafcommerce.core.offer.service.OfferServiceImpl) OrderItemService(org.broadleafcommerce.core.order.service.OrderItemService) OfferCodeDao(org.broadleafcommerce.core.offer.dao.OfferCodeDao) OfferDao(org.broadleafcommerce.core.offer.dao.OfferDao) CustomerOfferDao(org.broadleafcommerce.core.offer.dao.CustomerOfferDao) OrderService(org.broadleafcommerce.core.order.service.OrderService) OfferServiceUtilitiesImpl(org.broadleafcommerce.core.offer.service.OfferServiceUtilitiesImpl)

Example 4 with PromotableItemFactoryImpl

use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl in project BroadleafCommerce by BroadleafCommerce.

the class OrderOfferProcessorTest method setUp.

@Override
protected void setUp() throws Exception {
    offerDaoMock = EasyMock.createMock(OfferDao.class);
    offerTimeZoneProcessorMock = EasyMock.createMock(OfferTimeZoneProcessor.class);
    orderProcessor = new OrderOfferProcessorImpl();
    orderProcessor.setOfferDao(offerDaoMock);
    orderProcessor.setOfferTimeZoneProcessor(offerTimeZoneProcessorMock);
    orderProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
}
Also used : PromotableItemFactoryImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl) OfferDao(org.broadleafcommerce.core.offer.dao.OfferDao)

Example 5 with PromotableItemFactoryImpl

use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createBasicPromotableOrder.

public PromotableOrder createBasicPromotableOrder() {
    Order order = createBasicOrder();
    PromotableOrder promotableOrder = new PromotableOrderImpl(order, new PromotableItemFactoryImpl(), false);
    return promotableOrder;
}
Also used : PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) Order(org.broadleafcommerce.core.order.domain.Order) PromotableItemFactoryImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl) PromotableOrderImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl) PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder)

Aggregations

PromotableItemFactoryImpl (org.broadleafcommerce.core.offer.service.discount.domain.PromotableItemFactoryImpl)7 OfferDao (org.broadleafcommerce.core.offer.dao.OfferDao)4 CustomerOfferDao (org.broadleafcommerce.core.offer.dao.CustomerOfferDao)3 OfferCodeDao (org.broadleafcommerce.core.offer.dao.OfferCodeDao)3 PromotableOrder (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder)3 PromotableOrderImpl (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl)3 FulfillmentGroupItemDao (org.broadleafcommerce.core.order.dao.FulfillmentGroupItemDao)3 OrderItemDao (org.broadleafcommerce.core.order.dao.OrderItemDao)3 Order (org.broadleafcommerce.core.order.domain.Order)3 FulfillmentGroupService (org.broadleafcommerce.core.order.service.FulfillmentGroupService)3 OrderItemService (org.broadleafcommerce.core.order.service.OrderItemService)3 OrderMultishipOptionService (org.broadleafcommerce.core.order.service.OrderMultishipOptionService)3 OrderService (org.broadleafcommerce.core.order.service.OrderService)3 ArrayList (java.util.ArrayList)2 Money (org.broadleafcommerce.common.money.Money)2 OfferDataItemProvider (org.broadleafcommerce.core.offer.service.OfferDataItemProvider)2 OfferServiceImpl (org.broadleafcommerce.core.offer.service.OfferServiceImpl)2 OfferServiceUtilitiesImpl (org.broadleafcommerce.core.offer.service.OfferServiceUtilitiesImpl)2 PromotableCandidateItemOfferImpl (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOfferImpl)2 PromotableOrderItem (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem)2