Package org.broadleafcommerce.core.order.domain

Examples of org.broadleafcommerce.core.order.domain.OrderImpl


    /**
     * Create a state, country, and customer with a basic order and some addresses
     */
    public Customer createCustomerWithBasicOrderAndAddresses() {
        Customer customer = createCustomerWithAddresses();
        Order order = new OrderImpl();
        order.setStatus(OrderStatus.IN_PROCESS);
        order.setTotal(new Money(BigDecimal.valueOf(1000)));
       
        assert order.getId() == null;
        order.setCustomer(customer);
        order = orderDao.save(order);
        assert order.getId() != null;
       
        return customer;
    }
View Full Code Here


public class OrderDataProvider {

    @DataProvider(name = "basicOrder")
    public static Object[][] provideBasicSalesOrder() {
        OrderImpl so = new OrderImpl();
        so.setStatus(OrderStatus.IN_PROCESS);
        so.setTotal(new Money(BigDecimal.valueOf(1000)));
        return new Object[][] { { so } };
    }
View Full Code Here

    /**
     * Create a state, country, and customer with a basic order and some addresses
     */
    public Customer createCustomerWithBasicOrderAndAddresses() {
        Customer customer = createCustomerWithAddresses();
        Order order = new OrderImpl();
        order.setStatus(OrderStatus.IN_PROCESS);
        order.setTotal(new Money(BigDecimal.valueOf(1000)));
       
        assert order.getId() == null;
        order.setCustomer(customer);
        order = orderDao.save(order);
        assert order.getId() != null;
       
        return customer;
    }
View Full Code Here

        PromotableOrder promotableOrder = new PromotableOrderImpl(order, new PromotableItemFactoryImpl(), false);
        return promotableOrder;
    }

    public Order createBasicOrder() {
        Order order = new OrderImpl();
        order.setId(getOrderId());
       
        Category category1 = new CategoryImpl();
        category1.setName("test1");
        category1.setId(1L);
       
        Product product1 = new ProductImpl();
       
        Sku sku1 = new SkuImpl();
        sku1.setName("test1");
        sku1.setId(1L);
        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.setId(2L);
        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);
       
        DiscreteOrderItem orderItem1 = new DiscreteOrderItemImpl();
        orderItem1.setCategory(category1);
        orderItem1.setName("test1");
        orderItem1.setOrder(order);
        orderItem1.setOrderItemType(OrderItemType.DISCRETE);
        orderItem1.setProduct(product1);
        orderItem1.setQuantity(2);
        orderItem1.setSku(sku1);
        orderItem1.setId(getOrderItemId());
        orderItem1.setOrder(order);
       
        OrderItemPriceDetail priceDetail1 = new OrderItemPriceDetailImpl();
        priceDetail1.setOrderItem(orderItem1);
        priceDetail1.setQuantity(2);
        orderItem1.getOrderItemPriceDetails().add(priceDetail1);
       
        order.getOrderItems().add(orderItem1);
       
        DiscreteOrderItem orderItem2 = new DiscreteOrderItemImpl();
        orderItem2.setCategory(category2);
        orderItem2.setName("test2");
        orderItem2.setOrder(order);
        orderItem2.setOrderItemType(OrderItemType.DISCRETE);
        orderItem2.setProduct(product2);
        orderItem2.setQuantity(3);
        orderItem2.setSku(sku2);
        orderItem2.setId(getOrderItemId());
        orderItem2.setOrder(order);
       
        OrderItemPriceDetail priceDetail2 = new OrderItemPriceDetailImpl();
        priceDetail2.setOrderItem(orderItem2);
        priceDetail2.setQuantity(3);
        orderItem2.getOrderItemPriceDetails().add(priceDetail2);
       
        order.getOrderItems().add(orderItem2);
       
        Customer customer = new CustomerImpl();
        customer.setEmailAddress("test@test.com");
        customer.setFirstName("John");
        customer.setLastName("Tester");
        customer.setReceiveEmail(true);
        customer.setRegistered(true);
       
        order.setCustomer(customer);
       
        order.setEmailAddress("test@test.com");
       
        FulfillmentGroup fg1 = new FulfillmentGroupImpl();
        fg1.setId(1L);
        Address address1 = new AddressImpl();
        address1.setAddressLine1("123 Test Road");
        address1.setCity("Dallas");
       
        Country country = new CountryImpl();
        country.setAbbreviation("US");
        country.setName("United States");
       
        address1.setCountry(country);
        address1.setDefault(true);
        address1.setFirstName("John");
        address1.setLastName("Tester");
        address1.setPostalCode("75244");

        Phone primary = new PhoneImpl();
        primary.setPhoneNumber("972-976-1234");
        address1.setPhonePrimary(primary);
       
        State state = new StateImpl();
        state.setAbbreviation("TX");
        state.setCountry(country);
        state.setName("Texas");
       
        address1.setState(state);
        fg1.setAddress(address1);
        fg1.setOrder(order);
        fg1.setPrimary(true);
        fg1.setRetailShippingPrice(new Money(10D));
        fg1.setShippingPrice(new Money(10D));
        fg1.setType(FulfillmentType.PHYSICAL_SHIP);
        fg1.setOrder(order);
       
        FulfillmentGroupItem fgItem1 = new FulfillmentGroupItemImpl();
        fgItem1.setFulfillmentGroup(fg1);
        fgItem1.setOrderItem(orderItem1);
        fgItem1.setQuantity(2);
        //fgItem1.setRetailPrice(new Money(19.99D));
        fg1.getFulfillmentGroupItems().add(fgItem1);
       
        order.getFulfillmentGroups().add(fg1);
       
        FulfillmentGroup fg2 = new FulfillmentGroupImpl();
        fg2.setId(2L);
        Address address2 = new AddressImpl();
        address2.setAddressLine1("124 Test Road");
        address2.setCity("Dallas");
       
        Country country2 = new CountryImpl();
        country2.setAbbreviation("US");
        country2.setName("United States");
       
        address2.setCountry(country2);
        address2.setDefault(true);
        address2.setFirstName("John");
        address2.setLastName("Tester");
        address2.setPostalCode("75244");

        Phone primary2 = new PhoneImpl();
        primary2.setPhoneNumber("972-976-1234");
        address2.setPhonePrimary(primary2);
       
        State state2 = new StateImpl();
        state2.setAbbreviation("TX");
        state2.setCountry(country2);
        state2.setName("Texas");
       
        address2.setState(state2);
        fg2.setAddress(address2);
        fg2.setOrder(order);
        fg2.setPrimary(true);
        fg2.setRetailShippingPrice(new Money(20D));
        fg2.setShippingPrice(new Money(20D));
        fg2.setType(FulfillmentType.PHYSICAL_SHIP);
        fg2.setOrder(order);
       
        FulfillmentGroupItem fgItem2 = new FulfillmentGroupItemImpl();
        fgItem2.setFulfillmentGroup(fg2);
        fgItem2.setOrderItem(orderItem2);
        fgItem2.setQuantity(3);
        //fgItem2.setRetailPrice(new Money(29.99D));
        fg2.getFulfillmentGroupItems().add(fgItem2);
       
        order.getFulfillmentGroups().add(fg2);
       
        order.setSubTotal(new Money((2 * 19.99D) + (3 * 29.99D)));
       
        orders.put(order.getId(), order);
        return order;
    }
View Full Code Here

     * Create order with a bundle with two items.  Bundle has a quantity of 2.  
     * Bundle item 1 has quantity of 2, bundle item 2 has quantity of 3
     * @return
     */
    public Order createOrderWithBundle() {
        Order order = new OrderImpl();
        order.setId(getOrderId());

        Category category1 = new CategoryImpl();
        category1.setName("test1");
        category1.setId(1L);

        Product product1 = new ProductImpl();

        Sku sku1 = new SkuImpl();
        sku1.setName("test1");
        sku1.setId(1L);
        sku1.setDiscountable(true);
        sku1.setRetailPrice(new Money(10D));
        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.setId(2L);
        sku2.setDiscountable(true);
        sku2.setRetailPrice(new Money(10D));
        product2.setDefaultSku(sku2);

        CategoryProductXref xref2 = new CategoryProductXrefImpl();
        xref2.setProduct(product2);
        xref2.setCategory(category2);
        category2.getAllProductXrefs().add(xref2);

        ProductBundle pb = new ProductBundleImpl();
        pb.setPricingModel(ProductBundlePricingModelType.ITEM_SUM);

        BundleOrderItem bundleOrderItem = new BundleOrderItemImpl();
        bundleOrderItem.setCategory(category1);
        bundleOrderItem.setName("test1");
        bundleOrderItem.setOrder(order);
        bundleOrderItem.setOrderItemType(OrderItemType.DISCRETE);
        bundleOrderItem.setQuantity(2);
        bundleOrderItem.setId(getOrderItemId());
        bundleOrderItem.setOrder(order);
        bundleOrderItem.setRetailPrice(new Money(10D));
        bundleOrderItem.setProductBundle(pb);

        OrderItemPriceDetail priceDetail = new OrderItemPriceDetailImpl();
        priceDetail.setOrderItem(bundleOrderItem);
        priceDetail.setQuantity(2);
        bundleOrderItem.getOrderItemPriceDetails().add(priceDetail);

        order.getOrderItems().add(bundleOrderItem);

        DiscreteOrderItem orderItem1 = new DiscreteOrderItemImpl();
        orderItem1.setCategory(category1);
        orderItem1.setName("test1");
        orderItem1.setOrder(order);
        orderItem1.setOrderItemType(OrderItemType.DISCRETE);
        orderItem1.setProduct(product1);
        orderItem1.setQuantity(2);
        orderItem1.setSku(sku1);
        orderItem1.setId(getOrderItemId());
        orderItem1.setOrder(order);

        OrderItemPriceDetail priceDetail1 = new OrderItemPriceDetailImpl();
        priceDetail1.setOrderItem(orderItem1);
        priceDetail1.setQuantity(2);
        orderItem1.getOrderItemPriceDetails().add(priceDetail1);

        bundleOrderItem.getDiscreteOrderItems().add(orderItem1);

        DiscreteOrderItem orderItem2 = new DiscreteOrderItemImpl();
        orderItem2.setCategory(category2);
        orderItem2.setName("test2");
        orderItem2.setOrder(order);
        orderItem2.setOrderItemType(OrderItemType.DISCRETE);
        orderItem2.setProduct(product2);
        orderItem2.setQuantity(3);
        orderItem2.setSku(sku2);
        orderItem2.setId(getOrderItemId());
        orderItem2.setOrder(order);

        OrderItemPriceDetail priceDetail2 = new OrderItemPriceDetailImpl();
        priceDetail2.setOrderItem(orderItem2);
        priceDetail2.setQuantity(3);
        orderItem2.getOrderItemPriceDetails().add(priceDetail2);

        bundleOrderItem.getDiscreteOrderItems().add(orderItem2);

        Customer customer = new CustomerImpl();
        customer.setEmailAddress("test@test.com");
        customer.setFirstName("John");
        customer.setLastName("Tester");
        customer.setReceiveEmail(true);
        customer.setRegistered(true);

        order.setCustomer(customer);

        order.setEmailAddress("test@test.com");

        FulfillmentGroup fg1 = new FulfillmentGroupImpl();
        fg1.setId(1L);
        Address address1 = new AddressImpl();
        address1.setAddressLine1("123 Test Road");
        address1.setCity("Dallas");

        Country country = new CountryImpl();
        country.setAbbreviation("US");
        country.setName("United States");

        address1.setCountry(country);
        address1.setDefault(true);
        address1.setFirstName("John");
        address1.setLastName("Tester");
        address1.setPostalCode("75244");

        Phone primary = new PhoneImpl();
        primary.setPhoneNumber("972-976-1234");
        address1.setPhonePrimary(primary);

        State state = new StateImpl();
        state.setAbbreviation("TX");
        state.setCountry(country);
        state.setName("Texas");

        address1.setState(state);
        fg1.setAddress(address1);
        fg1.setOrder(order);
        fg1.setPrimary(true);
        fg1.setRetailShippingPrice(new Money(10D));
        fg1.setShippingPrice(new Money(10D));
        fg1.setType(FulfillmentType.PHYSICAL_SHIP);
        fg1.setOrder(order);

        FulfillmentGroupItem fgItem1 = new FulfillmentGroupItemImpl();
        fgItem1.setFulfillmentGroup(fg1);
        fgItem1.setOrderItem(orderItem1);
        fgItem1.setQuantity(2);
        //fgItem1.setRetailPrice(new Money(19.99D));
        fg1.getFulfillmentGroupItems().add(fgItem1);

        order.getFulfillmentGroups().add(fg1);

        FulfillmentGroup fg2 = new FulfillmentGroupImpl();
        fg2.setId(2L);
        Address address2 = new AddressImpl();
        address2.setAddressLine1("124 Test Road");
        address2.setCity("Dallas");

        Country country2 = new CountryImpl();
        country2.setAbbreviation("US");
        country2.setName("United States");

        address2.setCountry(country2);
        address2.setDefault(true);
        address2.setFirstName("John");
        address2.setLastName("Tester");
        address2.setPostalCode("75244");

        Phone primary2 = new PhoneImpl();
        primary2.setPhoneNumber("972-976-1234");
        address2.setPhonePrimary(primary2);

        State state2 = new StateImpl();
        state2.setAbbreviation("TX");
        state2.setCountry(country2);
        state2.setName("Texas");

        address2.setState(state2);
        fg2.setAddress(address2);
        fg2.setOrder(order);
        fg2.setPrimary(true);
        fg2.setRetailShippingPrice(new Money(20D));
        fg2.setShippingPrice(new Money(20D));
        fg2.setType(FulfillmentType.PHYSICAL_SHIP);
        fg2.setOrder(order);

        FulfillmentGroupItem fgItem2 = new FulfillmentGroupItemImpl();
        fgItem2.setFulfillmentGroup(fg2);
        fgItem2.setOrderItem(orderItem2);
        fgItem2.setQuantity(3);
        //fgItem2.setRetailPrice(new Money(29.99D));
        fg2.getFulfillmentGroupItems().add(fgItem2);

        order.getFulfillmentGroups().add(fg2);

        order.setSubTotal(new Money((2 * 19.99D) + (3 * 29.99D)));

        orders.put(order.getId(), order);
        return order;
    }
View Full Code Here

        }
        if (quantities != null && quantities.length != orderItemsToCreate) {
            throw new IllegalStateException("Quantities for Skus should be less than or equal to the number of order items being created");
        }

        Order result = new OrderImpl();

        List<FulfillmentGroupItem> fulfillmentItems = new ArrayList<FulfillmentGroupItem>();
        for (int i = 0; i < orderItemsToCreate; i++) {
            DiscreteOrderItem orderItem = new DiscreteOrderItemImpl();
            Sku sku = new SkuImpl();
            //set the sku price to some arbitrary amount - won't matter because the test is based on order item price
            sku.setRetailPrice(new Money("1"));
            orderItem.setSku(sku);

            if (flatRates != null && i < flatRates.length) {
                sku.getFulfillmentFlatRates().put(option, new BigDecimal(flatRates[i]));
            }

            if (option instanceof BandedPriceFulfillmentOption) {
                orderItem.setPrice(new Money(total.divide(new BigDecimal(orderItemsToCreate))));
            } else if (option instanceof BandedWeightFulfillmentOption) {
                Weight weight = new Weight();
                weight.setWeight(total.divide(new BigDecimal(orderItemsToCreate)));
                weight.setWeightUnitOfMeasure(WeightUnitOfMeasureType.POUNDS);
                orderItem.getSku().setWeight(weight);
                orderItem.setPrice(new Money(BigDecimal.ZERO));
            }
            orderItem.setOrder(result);

            FulfillmentGroupItem fulfillmentItem = new FulfillmentGroupItemImpl();
            fulfillmentItem.setOrderItem(orderItem);
            if (quantities == null) {
                fulfillmentItem.setQuantity(1);
            } else {
                fulfillmentItem.setQuantity(quantities[i]);
            }

            fulfillmentItems.add(fulfillmentItem);
        }

        FulfillmentGroup group = new FulfillmentGroupImpl();
        group.setOrder(result);
        group.setFulfillmentGroupItems(fulfillmentItems);
        List<FulfillmentGroup> groups = new ArrayList<FulfillmentGroup>();
        groups.add(group);

        result.setFulfillmentGroups(groups);
        return result;
    }
View Full Code Here

        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",
View Full Code Here

    @Test
    public void testOfferAppliesToItemsInCategoryAndOrderValueGreaterThanFifty() {
        //----------------------------------------------------------------------------------------------------
        // Mock up some order data
        OrderImpl order = new OrderImpl();
        CategoryImpl category = new CategoryImpl();
        category.setName("t-shirt");
        DiscreteOrderItemImpl orderItem = new DiscreteOrderItemImpl();
        ProductImpl product = new ProductImpl();
        ArrayList<CategoryProductXref> categories = new ArrayList<CategoryProductXref>();
        CategoryProductXref categoryXref = new CategoryProductXrefImpl();
        categoryXref.setProduct(product);
        categoryXref.setCategory(category);
        categories.add(categoryXref);
        product.setAllParentCategoryXrefs(categories);
        orderItem.setProduct(product);
        order.getOrderItems().add(orderItem);
        order.setSubTotal(new Money(110D));

        //Set up MVEL Context
        ParserContext context = new ParserContext();

        //Import OfferType into the MVEL context since it may be used
View Full Code Here

    }

    //@Test
    //TODO fix this test
    public void testOfferAppliesToHatsWhenOneLawnmowerIsPurchased() {
        OrderImpl order = new OrderImpl();
        ArrayList<OrderItem> items = new ArrayList<OrderItem>();
        order.setOrderItems(items);
        DiscreteOrderItemImpl item = new DiscreteOrderItemImpl();
        Money amount = new Money(10D);
        items.add(item);
        item.setSalePrice(amount);
        ProductImpl product = new ProductImpl();
View Full Code Here

//        assert item.getMarkedForOffer() == 0;
//    }

    @Test
    public void testOfferAppliesToFulfillmentGroup() {
        OrderImpl order = new OrderImpl();
        order.setSubTotal(new Money(110D));
        FulfillmentGroupImpl group = new FulfillmentGroupImpl();
        group.setPrimary(true);

        OfferImpl offer = new OfferImpl();
        offer.setType(OfferType.FULFILLMENT_GROUP);
        order.getFulfillmentGroups().add(group);

        //Set up MVEL Context
        ParserContext context = new ParserContext();
        //Import OfferType into the MVEL context since it may be used
        context.addImport("OfferType", OfferType.class);
View Full Code Here

TOP

Related Classes of org.broadleafcommerce.core.order.domain.OrderImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.