ExpireCartCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { shoppingCart.getShoppingContext().clearContext(); shoppingCart.getOrderInfo().clearInfo(); setCustomerOptions(shoppingCart); setDefaultAddressesIfPossible(shoppingCart); setTaxOptions(shoppingCart, null, null, null); if (shoppingCart.removeItemOffers()) { recalculate(shoppingCart); } markDirty(shoppingCart); } } ExpireCartCommandImpl(final ShoppingCartCommandRegistry registry); @Override String getCmdKey(); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters);  }
@Test public void testExecute() { ShopService shopService = (ShopService) ctx().getBean(ServiceSpringKeys.SHOP_SERVICE); Shop shop10 = shopService.getById(10L); final Customer customer = createCustomer(); 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); Map<String, String> params = new HashMap<>(); params.put(ShoppingCartCommand.CMD_LOGIN_P_EMAIL, customer.getEmail()); params.put(ShoppingCartCommand.CMD_LOGIN_P_PASS, "rawpassword"); params.put(ShoppingCartCommand.CMD_LOGIN, ShoppingCartCommand.CMD_LOGIN); commands.execute(shoppingCart, (Map) params); assertNotNull(shoppingCart.getCustomerEmail()); assertNotNull(shoppingCart.getCustomerName()); commands.execute(shoppingCart, (Map) Collections.singletonMap(ShoppingCartCommand.CMD_EXPIRE, null)); assertNull(shoppingCart.getCustomerEmail()); assertNull(shoppingCart.getCustomerName()); }