@Test public void testExecute() { MutableShoppingCart shoppingCart = new ShoppingCartImpl(); shoppingCart.initialise(ctx().getBean("amountCalculationStrategy", AmountCalculationStrategy.class)); final ShoppingCartCommandFactory commands = ctx().getBean("shoppingCartCommandFactory", ShoppingCartCommandFactory.class); commands.execute(shoppingCart, (Map) singletonMap(ShoppingCartCommand.CMD_CHANGELOCALE, "en")); assertEquals("en", shoppingCart.getCurrentLocale()); commands.execute(shoppingCart, (Map) singletonMap(ShoppingCartCommand.CMD_CHANGELOCALE, "uk")); assertEquals("uk", shoppingCart.getCurrentLocale()); }
@Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String locale = (String) parameters.get(getCmdKey()); if (locale != null && !locale.equals(shoppingCart.getCurrentLocale())) { final List<String> supported = languageService.getSupportedLanguages(shoppingCart.getShoppingContext().getShopCode()); if (supported.contains(locale)) { shoppingCart.setCurrentLocale(locale); markDirty(shoppingCart); } } } }
ChangeLocaleCartCommandImpl extends AbstractCartCommandImpl { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String locale = (String) parameters.get(getCmdKey()); if (locale != null && !locale.equals(shoppingCart.getCurrentLocale())) { final List<String> supported = languageService.getSupportedLanguages(shoppingCart.getShoppingContext().getShopCode()); if (supported.contains(locale)) { shoppingCart.setCurrentLocale(locale); markDirty(shoppingCart); } } } } }
ChangeLocaleCartCommandImpl extends AbstractCartCommandImpl { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String locale = (String) parameters.get(getCmdKey()); if (locale != null && !locale.equals(shoppingCart.getCurrentLocale())) { final List<String> supported = languageService.getSupportedLanguages(shoppingCart.getShoppingContext().getShopCode()); if (supported.contains(locale)) { shoppingCart.setCurrentLocale(locale); markDirty(shoppingCart); } } } } ChangeLocaleCartCommandImpl(final ShoppingCartCommandRegistry registry,
                                       final LanguageService languageService); }
ChangeLocaleCartCommandImpl extends AbstractCartCommandImpl { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String locale = (String) parameters.get(getCmdKey()); if (locale != null && !locale.equals(shoppingCart.getCurrentLocale())) { final List<String> supported = languageService.getSupportedLanguages(shoppingCart.getShoppingContext().getShopCode()); if (supported.contains(locale)) { shoppingCart.setCurrentLocale(locale); markDirty(shoppingCart); } } } } ChangeLocaleCartCommandImpl(final ShoppingCartCommandRegistry registry,
                                       final LanguageService languageService); @Override String getCmdKey(); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters); }
ChangeLocaleCartCommandImpl extends AbstractCartCommandImpl { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String locale = (String) parameters.get(getCmdKey()); if (locale != null && !locale.equals(shoppingCart.getCurrentLocale())) { final List<String> supported = languageService.getSupportedLanguages(shoppingCart.getShoppingContext().getShopCode()); if (supported.contains(locale)) { shoppingCart.setCurrentLocale(locale); markDirty(shoppingCart); } } } } ChangeLocaleCartCommandImpl(final ShoppingCartCommandRegistry registry,
                                       final LanguageService languageService); @Override String getCmdKey(); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters);  }