SetBillingSeparateFromShippingAddressCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final Boolean value = shoppingCart.getOrderInfo().isSeparateBillingAddressEnabled() ? Boolean.TRUE : Boolean.valueOf((String) parameters.get(getCmdKey())); if (!value.equals(shoppingCart.getOrderInfo().isSeparateBillingAddress())) { shoppingCart.getOrderInfo().setSeparateBillingAddress(value); markDirty(shoppingCart); } } } SetBillingSeparateFromShippingAddressCommandImpl(final ShoppingCartCommandRegistry registry); @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.isSeparateBillingAddress()); Map params = new HashMap(); params.put(SetBillingSeparateFromShippingAddressCommandImpl.CMD_SEPARATEBILLING, "true"); commands.execute(shoppingCart, (Map) params); assertTrue(shoppingCart.isSeparateBillingAddress()); params.put(SetBillingSeparateFromShippingAddressCommandImpl.CMD_SEPARATEBILLING, "false"); commands.execute(shoppingCart, (Map) params); assertFalse(shoppingCart.isSeparateBillingAddress()); }