@Test public void testGetPhysicalDeliveriesQtyOffline() throws Exception { final Map<DeliveryBucket, List<CartItem>> buckets = new HashMap<>(); final DeliveryBucket off = context.mock(DeliveryBucket.class, "off"); buckets.put(off, Collections.<CartItem>emptyList()); context.checking(new Expectations() {{ 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(0), 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);  }