OrderAssemblerImpl implements OrderAssembler, ConfigurationRegistry<String, OrderAssemblerPostProcessor> { @Override public CustomerOrder assembleCustomerOrder(final ShoppingCart shoppingCart, final String orderNumber) throws OrderAssemblyException { return assembleCustomerOrder(shoppingCart, orderNumber, false); } OrderAssemblerImpl(final GenericDAO genericDAO,
                              final CustomerService customerService,
                              final ShopService shopService,
                              final ProductService productService,
                              final ProductSkuService productSkuService,
                              final PriceResolver priceResolver,
                              final InventoryResolver inventoryResolver,
                              final OrderAddressFormatter addressFormatter,
                              final PromotionCouponService promotionCouponService,
                              final AddressService addressService,
                              final AttributeService attributeService,
                              final WarehouseService warehouseService); @Override CustomerOrder assembleCustomerOrder(final ShoppingCart shoppingCart, final String orderNumber); @Override CustomerOrder assembleCustomerOrder(final ShoppingCart shoppingCart, final String orderNumber, final boolean temp); @Override boolean supports(final String cfgProperty, final Object configuration); @Override void register(final String shopCode, final OrderAssemblerPostProcessor processor);  }
@Test public void testAssembleCustomerOrder() throws Exception { Customer customer = createCustomer(); ShoppingCart shoppingCart = getShoppingCart2(customer.getEmail(), false); setIPAddress(shoppingCart, "127.0.0.1"); setCustomOrderDetail(shoppingCart, "someDetail", "order detail"); setCustomItemDetail(shoppingCart, "WAREHOUSE_1", "CC_TEST1", "someDetail", "item detail"); CustomerOrder customerOrder = orderAssembler.assembleCustomerOrder(shoppingCart, RandomStringUtils.random(10)); assertNotNull(customerOrder); customerOrder = customerOrderService.create(customerOrder); assertNotNull(customerOrder); assertNotNull(customerOrder.getBillingAddress()); assertEquals("By default billing and shipping addresses the same", customerOrder.getBillingAddress(), customerOrder.getShippingAddress()); assertTrue("By Default billing address is shipping address ", customerOrder.getBillingAddress().contains("shipping addr")); assertEquals("Order must be in ORDER_STATUS_NONE state", CustomerOrder.ORDER_STATUS_NONE, customerOrder.getOrderStatus()); assertNotNull("Order num must be set", customerOrder.getOrdernum()); assertTrue("Order in pending state must not have delivery", customerOrder.getDelivery().isEmpty()); assertEquals("Shopping cart guid and order guid are equals", shoppingCart.getGuid(), customerOrder.getGuid()); assertEquals("127.0.0.1", customerOrder.getOrderIp()); assertEquals(8, customerOrder.getOrderDetail().size()); assertFalse(customerOrder.isMultipleShipmentOption()); assertEquals(new BigDecimal("5463.91"), customerOrder.getListPrice()); assertEquals(new BigDecimal("5463.91"), customerOrder.getPrice()); assertEquals(new BigDecimal("4551.88"), customerOrder.getNetPrice()); assertEquals(new BigDecimal("5463.91"), customerOrder.getGrossPrice()); final Pair<String, I18NModel> orderDetail = customerOrder.getValue(AttributeNamesKeys.Cart.ORDER_INFO_ORDER_ATTRIBUTE_ID + ":someDetail"); assertNotNull(orderDetail); assertEquals("order detail", orderDetail.getFirst()); assertEquals("someDetail: order detail", orderDetail.getSecond().getValue(I18NModel.DEFAULT)); CustomerOrderDet detCC_TEST1 = null; for (final CustomerOrderDet det : customerOrder.getOrderDetail()) { if (det.getProductSkuCode().equals("CC_TEST1")) { detCC_TEST1 = det; break; } } final Pair<String, I18NModel> orderDetCC_TEST1 = detCC_TEST1.getValue(AttributeNamesKeys.Cart.ORDER_INFO_ORDER_LINE_ATTRIBUTE_ID + ":someDetail"); assertNotNull(orderDetCC_TEST1); assertEquals("item detail", orderDetCC_TEST1.getFirst()); assertEquals("someDetail: item detail", orderDetCC_TEST1.getSecond().getValue(I18NModel.DEFAULT)); }