@Test public void testGetPhysicalDeliveriesQtyMix() throws Exception { final Map<DeliveryBucket, List<CartItem>> buckets = new HashMap<>(); final DeliveryBucket d1 = context.mock(DeliveryBucket.class, "d1"); final DeliveryBucket d2 = context.mock(DeliveryBucket.class, "d2"); final DeliveryBucket d3 = context.mock(DeliveryBucket.class, "d3"); final DeliveryBucket d4 = context.mock(DeliveryBucket.class, "d4"); final DeliveryBucket oos = context.mock(DeliveryBucket.class, "oos"); final DeliveryBucket off = context.mock(DeliveryBucket.class, "off"); buckets.put(d1, Collections.<CartItem>emptyList()); buckets.put(d2, Collections.<CartItem>emptyList()); buckets.put(d3, Collections.<CartItem>emptyList()); buckets.put(d4, Collections.<CartItem>emptyList()); buckets.put(oos, Collections.<CartItem>emptyList()); buckets.put(off, Collections.<CartItem>emptyList()); context.checking(new Expectations() {{ allowing(d1).getSupplier(); will(returnValue("s1")); allowing(d1).getGroup(); will(returnValue(CustomerOrderDelivery.STANDARD_DELIVERY_GROUP)); allowing(d2).getSupplier(); will(returnValue("s1")); allowing(d2).getGroup(); will(returnValue(CustomerOrderDelivery.DATE_WAIT_DELIVERY_GROUP)); allowing(d3).getSupplier(); will(returnValue("s1")); allowing(d3).getGroup(); will(returnValue(CustomerOrderDelivery.INVENTORY_WAIT_DELIVERY_GROUP)); allowing(d4).getSupplier(); will(returnValue("s1")); allowing(d4).getGroup(); will(returnValue(CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP)); allowing(oos).getSupplier(); will(returnValue("s1")); allowing(oos).getGroup(); will(returnValue(CustomerOrderDelivery.NOSTOCK_DELIVERY_GROUP)); allowing(off).getSupplier(); will(returnValue("s1")); allowing(off).getGroup(); will(returnValue(CustomerOrderDelivery.OFFLINE_DELIVERY_GROUP)); }}); final Map<String, Integer> counts = new OrderSplittingStrategyImpl(null, null, null, null).getPhysicalDeliveriesQty(buckets); assertNotNull(counts); assertEquals(1, counts.size()); assertEquals(Integer.valueOf(3), counts.get("s1")); }
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);  }