@Test public void testExecute() { ShopService shopService = (ShopService) ctx().getBean(ServiceSpringKeys.SHOP_SERVICE); Shop shop10 = shopService.getById(10L); MutableShoppingCart shoppingCart = new ShoppingCartImpl(); shoppingCart.getShoppingContext().setShopCode(shop10.getCode()); shoppingCart.getShoppingContext().setShopId(shop10.getShopId()); shoppingCart.initialise(ctx().getBean("amountCalculationStrategy", AmountCalculationStrategy.class)); final ShoppingCartCommandFactory commands = ctx().getBean("shoppingCartCommandFactory", ShoppingCartCommandFactory.class); shoppingCart.addProductSkuToCart("Main", "ABC", "ABC", BigDecimal.ONE, null, false, false); shoppingCart.getOrderInfo().setOrderMessage("hi, I'm a cart"); String oldGuid = shoppingCart.getGuid(); commands.execute(shoppingCart, (Map) Collections.singletonMap(ShoppingCartCommand.CMD_CLEAN, ShoppingCartCommand.CMD_CLEAN)); assertNull(shoppingCart.getOrderMessage()); assertNotNull(shoppingCart.getModifiedTimestamp()); assertTrue(shoppingCart.getCartItemList().isEmpty()); assertNotSame(oldGuid, shoppingCart.getGuid()); }
@Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { shoppingCart.clean(); setCustomerOptions(shoppingCart); setDefaultAddressesIfPossible(shoppingCart); setTaxOptions(shoppingCart, null, null, null); markDirty(shoppingCart); } }
CleanCartCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { shoppingCart.clean(); setCustomerOptions(shoppingCart); setDefaultAddressesIfPossible(shoppingCart); setTaxOptions(shoppingCart, null, null, null); markDirty(shoppingCart); } } }
CleanCartCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { shoppingCart.clean(); setCustomerOptions(shoppingCart); setDefaultAddressesIfPossible(shoppingCart); setTaxOptions(shoppingCart, null, null, null); markDirty(shoppingCart); } } CleanCartCommandImpl(final ShoppingCartCommandRegistry registry); }
CleanCartCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { shoppingCart.clean(); setCustomerOptions(shoppingCart); setDefaultAddressesIfPossible(shoppingCart); setTaxOptions(shoppingCart, null, null, null); markDirty(shoppingCart); } } CleanCartCommandImpl(final ShoppingCartCommandRegistry registry); @Override String getCmdKey(); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters); }
CleanCartCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { shoppingCart.clean(); setCustomerOptions(shoppingCart); setDefaultAddressesIfPossible(shoppingCart); setTaxOptions(shoppingCart, null, null, null); markDirty(shoppingCart); } } CleanCartCommandImpl(final ShoppingCartCommandRegistry registry); @Override String getCmdKey(); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters);  }