Package org.broadleafcommerce.core.order.domain

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


        // Filter out orders that don't match the current locale (if one is set)
        if (BroadleafRequestContext.getBroadleafRequestContext() != null) {
            ListIterator<Order> iter = orders.listIterator();
            while (iter.hasNext()) {
                Locale locale = BroadleafRequestContext.getBroadleafRequestContext().getLocale();
                Order order = iter.next();
                if (locale != null && !locale.equals(order.getLocale())) {
                    iter.remove();
                }
            }
        }
           
View Full Code Here


    @Rollback(false)
    public void createCartForCustomer() {
        String userName = "customer1";
        Customer customer = customerService.readCustomerByUsername(userName);

        Order order = orderService.createNewCartForCustomer(customer);
        assert order != null;
        assert order.getId() != null;
        this.orderId = order.getId();
    }
View Full Code Here

    @Rollback(false)
    public void findCurrentCartForCustomer() {
        String userName = "customer1";
        Customer customer = customerService.readCustomerByUsername(userName);

        Order order = orderService.findCartForCustomer(customer);
        assert order != null;
        assert order.getId() != null;
        this.orderId = order.getId();
    }
View Full Code Here

    public void addItemToOrder() throws AddToCartException {
        numOrderItems++;
        // In the database, some Skus are inactive and some are active. This ensures that we pull back an active one
        // to test a successful cart add
        Sku sku = getFirstActiveSku();
        Order order = orderService.findOrderById(orderId);
        assert order != null;
        assert sku.getId() != null;
       
        OrderItemRequestDTO itemRequest = new OrderItemRequestDTO();
        itemRequest.setQuantity(1);
        itemRequest.setSkuId(sku.getId());
        order = orderService.addItem(orderId, itemRequest, true);
       
        DiscreteOrderItem item = (DiscreteOrderItem) orderService.findLastMatchingItem(order, sku.getId(), null);
       
        assert item != null;
        assert item.getQuantity() == numOrderItems;
        assert item.getSku() != null;
        assert item.getSku().equals(sku);
       
        assert order.getFulfillmentGroups().size() == 1;
       
        FulfillmentGroup fg = order.getFulfillmentGroups().get(0);
        assert fg.getFulfillmentGroupItems().size() == 1;
       
        FulfillmentGroupItem fgItem = fg.getFulfillmentGroupItems().get(0);
        assert fgItem.getOrderItem().equals(item);
        assert fgItem.getQuantity() == item.getQuantity();
View Full Code Here

    @Transactional
    public void addAnotherItemToOrder() throws AddToCartException {
     // In the database, some Skus are inactive and some are active. This ensures that we pull back an active one
        // to test a successful cart add
        Sku sku = getFirstActiveSku();
        Order order = orderService.findOrderById(orderId);
        assert order != null;
        assert sku.getId() != null;
        orderService.setAutomaticallyMergeLikeItems(true);
       
        OrderItemRequestDTO itemRequest = new OrderItemRequestDTO();
        itemRequest.setQuantity(1);
        itemRequest.setSkuId(sku.getId());
        // Note that we are not incrementing the numOrderItems count because it should have gotten merged
        order = orderService.addItem(orderId, itemRequest, true);
        DiscreteOrderItem item = (DiscreteOrderItem) orderService.findLastMatchingItem(order, sku.getId(), null);
       
        assert item.getSku() != null;
        assert item.getSku().equals(sku);
        assert item.getQuantity() == 2// item-was merged with prior item.

        order = orderService.findOrderById(orderId);

        assert(order.getOrderItems().size()==1);
        assert(order.getOrderItems().get(0).getQuantity()==2);
       
        assert order.getFulfillmentGroups().size() == 1;
       
        FulfillmentGroup fg = order.getFulfillmentGroups().get(0);
        assert fg.getFulfillmentGroupItems().size() == 1;
       
        FulfillmentGroupItem fgItem = fg.getFulfillmentGroupItems().get(0);
        assert fgItem.getOrderItem().equals(item);
        assert fgItem.getQuantity() == item.getQuantity();
View Full Code Here

    }
   
    @Test(groups = { "testIllegalAddScenarios" }, dependsOnGroups = { "addItemToOrder" })
    @Transactional
    public void testIllegalAddScenarios() throws AddToCartException {
        Order order = orderService.findOrderById(orderId);
        assert order != null;
       
        Product activeProduct = addTestProduct("mug", "cups", true);
        Product inactiveProduct = addTestProduct("cup", "cups", false);
       
View Full Code Here

    }
   
    @Test(groups = { "testIllegalUpdateScenarios" }, dependsOnGroups = { "addItemToOrder" })
    @Transactional
    public void testIllegalUpdateScenarios() throws UpdateCartException, AddToCartException, RemoveFromCartException {
        Order order = orderService.findOrderById(orderId);
        assert order != null;
       
        Product activeProduct = addTestProduct("mug", "cups", true);
        Product inactiveProduct = addTestProduct("cup", "cups", false);
       
View Full Code Here

    @Rollback(false)
    @Transactional
    public void addBundleToOrder() throws AddToCartException {
        numOrderItems++;
        Sku sku = skuDao.readFirstSku();
        Order order = orderService.findOrderById(orderId);
        assert order != null;
        assert sku.getId() != null;
       
        ProductBundle bundleItem = addProductBundle();
        OrderItemRequestDTO orderItemRequestDTO = new OrderItemRequestDTO();
        orderItemRequestDTO.setProductId(bundleItem.getId());
        orderItemRequestDTO.setSkuId(bundleItem.getDefaultSku().getId());
        orderItemRequestDTO.setQuantity(1);
       
        order = orderService.addItem(order.getId(), orderItemRequestDTO, true);
        BundleOrderItem item = (BundleOrderItem) orderService.findLastMatchingItem(order, bundleItem.getDefaultSku().getId(), null);
        bundleOrderItemId = item.getId();
        assert item != null;
        assert item.getQuantity() == 1;
        assert item.getDiscreteOrderItems().size() == 1;
View Full Code Here

   
    @Test(groups = { "removeBundleFromOrder" }, dependsOnGroups = { "addBundleToOrder" })
    @Rollback(false)
    @Transactional
    public void removeBundleFromOrder() throws RemoveFromCartException {
        Order order = orderService.findOrderById(orderId);
        List<OrderItem> orderItems = order.getOrderItems();
        assert orderItems.size() == numOrderItems;
        int startingSize = orderItems.size();
        BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItemService.readOrderItemById(bundleOrderItemId);
        assert bundleOrderItem != null;
        assert bundleOrderItem.getDiscreteOrderItems() != null;
        assert bundleOrderItem.getDiscreteOrderItems().size() == 1;
        order = orderService.removeItem(order.getId(), bundleOrderItem.getId(), true);
        List<OrderItem> items = order.getOrderItems();
        assert items != null;
        assert items.size() == startingSize - 1;
    }
View Full Code Here

    }
   
    @Test(groups = { "getItemsForOrder" }, dependsOnGroups = { "removeBundleFromOrder" })
    @Transactional
    public void getItemsForOrder() {
        Order order = orderService.findOrderById(orderId);
        List<OrderItem> orderItems = order.getOrderItems();
        assert orderItems != null;
        assert orderItems.size() == numOrderItems - 1;
    }
View Full Code Here

TOP

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

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.