SetMultipleDeliveryCommandImpl extends SplitCartItemsCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final Boolean value = Boolean.valueOf((String) parameters.get(getCmdKey())); if (value != null && !value.equals(shoppingCart.getOrderInfo().isMultipleDelivery())) { shoppingCart.getOrderInfo().setMultipleDelivery(value); performCartItemsSplitting(shoppingCart); recalculate(shoppingCart); markDirty(shoppingCart); } else if (!shoppingCart.isAllCartItemsBucketed()) { performCartItemsSplitting(shoppingCart); recalculate(shoppingCart); markDirty(shoppingCart); } } } SetMultipleDeliveryCommandImpl(final ShoppingCartCommandRegistry registry,
                                          final OrderSplittingStrategy orderSplittingStrategy); @Override String getCmdKey(); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters);  }
@Test public void testExecute() { MutableShoppingCart shoppingCart = new ShoppingCartImpl(); shoppingCart.initialise(ctx().getBean("amountCalculationStrategy", AmountCalculationStrategy.class)); final ShoppingCartCommandFactory commands = ctx().getBean("shoppingCartCommandFactory", ShoppingCartCommandFactory.class); assertFalse(shoppingCart.getOrderInfo().isMultipleDelivery()); Map params = new HashMap(); params.put(SetMultipleDeliveryCommandImpl.CMD_MULTIPLEDELIVERY, "true"); commands.execute(shoppingCart, params); assertTrue(shoppingCart.getOrderInfo().isMultipleDelivery()); params.put(SetMultipleDeliveryCommandImpl.CMD_MULTIPLEDELIVERY, "false"); commands.execute(shoppingCart, params); assertFalse(shoppingCart.getOrderInfo().isMultipleDelivery()); }