@Test public void testGetPhysicalDeliveriesQty() throws Exception { final Map<DeliveryBucket, List<CartItem>> groups = new HashMap<>(); assertEquals(0, groups.size()); assertTrue(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).isEmpty()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP, "S001"), Collections.<CartItem>emptyList()); assertEquals(1, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(0, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.STANDARD_DELIVERY_GROUP, "S001"), Collections.<CartItem>emptyList()); assertEquals(2, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(1, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.DATE_WAIT_DELIVERY_GROUP, "S001"), Collections.<CartItem>emptyList()); assertEquals(3, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(2, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.INVENTORY_WAIT_DELIVERY_GROUP, "S001"), Collections.<CartItem>emptyList()); assertEquals(4, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(3, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.MIX_DELIVERY_GROUP, "S001"), Collections.<CartItem>emptyList()); assertEquals(5, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(4, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP, "S002"), Collections.<CartItem>emptyList()); assertEquals(6, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(4, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); assertEquals(0, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.STANDARD_DELIVERY_GROUP, "S002"), Collections.<CartItem>emptyList()); assertEquals(7, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(4, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); assertEquals(1, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.DATE_WAIT_DELIVERY_GROUP, "S002"), Collections.<CartItem>emptyList()); assertEquals(8, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(4, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); assertEquals(2, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.INVENTORY_WAIT_DELIVERY_GROUP, "S002"), Collections.<CartItem>emptyList()); assertEquals(9, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(4, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); assertEquals(3, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002").intValue()); groups.put(new DeliveryBucketImpl(CustomerOrderDelivery.MIX_DELIVERY_GROUP, "S002"), Collections.<CartItem>emptyList()); assertEquals(10, groups.size()); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001")); assertNotNull(new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002")); assertEquals(4, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S001").intValue()); assertEquals(4, new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(groups).get("S002").intValue()); }
Map<String, Integer> getPhysicalDeliveriesQty(final Map<DeliveryBucket, List<CartItem>> deliveryMap) { final Map<String, Integer> counts = new HashMap<>(); for (final DeliveryBucket bucket : deliveryMap.keySet()) { int delta = CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.NOSTOCK_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.OFFLINE_DELIVERY_GROUP.equals(bucket.getGroup()) ? 0 : 1; counts.merge(bucket.getSupplier(), delta, (a, b) -> a + b); } return counts; }
OrderSplittingStrategyImpl implements OrderSplittingStrategy { Map<String, Integer> getPhysicalDeliveriesQty(final Map<DeliveryBucket, List<CartItem>> deliveryMap) { final Map<String, Integer> counts = new HashMap<>(); for (final DeliveryBucket bucket : deliveryMap.keySet()) { int delta = CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.NOSTOCK_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.OFFLINE_DELIVERY_GROUP.equals(bucket.getGroup()) ? 0 : 1; counts.merge(bucket.getSupplier(), delta, (a, b) -> a + b); } return counts; } }
OrderSplittingStrategyImpl implements OrderSplittingStrategy { Map<String, Integer> getPhysicalDeliveriesQty(final Map<DeliveryBucket, List<CartItem>> deliveryMap) { final Map<String, Integer> counts = new HashMap<>(); for (final DeliveryBucket bucket : deliveryMap.keySet()) { int delta = CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.NOSTOCK_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.OFFLINE_DELIVERY_GROUP.equals(bucket.getGroup()) ? 0 : 1; counts.merge(bucket.getSupplier(), delta, (a, b) -> a + b); } return counts; } OrderSplittingStrategyImpl(final ShopService shopService,
                                      final ProductService productService,
                                      final WarehouseService warehouseService,
                                      final InventoryResolver inventoryResolver); }
OrderSplittingStrategyImpl implements OrderSplittingStrategy { Map<String, Integer> getPhysicalDeliveriesQty(final Map<DeliveryBucket, List<CartItem>> deliveryMap) { final Map<String, Integer> counts = new HashMap<>(); for (final DeliveryBucket bucket : deliveryMap.keySet()) { int delta = CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.NOSTOCK_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.OFFLINE_DELIVERY_GROUP.equals(bucket.getGroup()) ? 0 : 1; counts.merge(bucket.getSupplier(), delta, (a, b) -> a + b); } return counts; } OrderSplittingStrategyImpl(final ShopService shopService,
                                      final ProductService productService,
                                      final WarehouseService warehouseService,
                                      final InventoryResolver inventoryResolver); @Override DeliveryBucket determineDeliveryBucket(final CartItem item,
                                                  final ShoppingCart cart); @Override Map<DeliveryBucket, List<CartItem>> determineDeliveryBuckets(final long shopId,
                                                                        final Collection<CartItem> items,
                                                                        final Map<String, Boolean> onePhysicalDelivery); @Override Map<String, Boolean> isMultipleDeliveriesAllowed(final long shopId, final Collection<CartItem> items); }
OrderSplittingStrategyImpl implements OrderSplittingStrategy { Map<String, Integer> getPhysicalDeliveriesQty(final Map<DeliveryBucket, List<CartItem>> deliveryMap) { final Map<String, Integer> counts = new HashMap<>(); for (final DeliveryBucket bucket : deliveryMap.keySet()) { int delta = CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.NOSTOCK_DELIVERY_GROUP.equals(bucket.getGroup()) || CustomerOrderDelivery.OFFLINE_DELIVERY_GROUP.equals(bucket.getGroup()) ? 0 : 1; counts.merge(bucket.getSupplier(), delta, (a, b) -> a + b); } return counts; } OrderSplittingStrategyImpl(final ShopService shopService,
                                      final ProductService productService,
                                      final WarehouseService warehouseService,
                                      final InventoryResolver inventoryResolver); @Override DeliveryBucket determineDeliveryBucket(final CartItem item,
                                                  final ShoppingCart cart); @Override Map<DeliveryBucket, List<CartItem>> determineDeliveryBuckets(final long shopId,
                                                                        final Collection<CartItem> items,
                                                                        final Map<String, Boolean> onePhysicalDelivery); @Override Map<String, Boolean> isMultipleDeliveriesAllowed(final long shopId, final Collection<CartItem> items);  }