@Test public void testExecute() { final Customer customer = createCustomer(); MutableShoppingCart shoppingCart = new ShoppingCartImpl(); shoppingCart.initialise(ctx().getBean("amountCalculationStrategy", AmountCalculationStrategy.class)); final ShoppingCartCommandFactory commands = ctx().getBean("shoppingCartCommandFactory", ShoppingCartCommandFactory.class); assertNull(shoppingCart.getShoppingContext().getLatestViewedSkus()); Map<String, String> params = new HashMap<>(); params.put(ShoppingCartCommand.CMD_INTERNAL_SETIP, "127.0.0.1"); commands.execute(shoppingCart, (Map) params); assertEquals("127.0.0.1", shoppingCart.getShoppingContext().getResolvedIp()); }
@Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String oldIp = shoppingCart.getShoppingContext().getResolvedIp(); final String newIp = (String) parameters.get(getCmdKey()); if (StringUtils.isNotBlank(newIp)) { if (StringUtils.isBlank(oldIp) || !oldIp.equals(newIp)) { LOG.debug("Cart {} is accessed from IP {}", shoppingCart.getGuid(), newIp); shoppingCart.getShoppingContext().setResolvedIp(newIp); shoppingCart.markDirty(); } } } }
SetIpInternalCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String oldIp = shoppingCart.getShoppingContext().getResolvedIp(); final String newIp = (String) parameters.get(getCmdKey()); if (StringUtils.isNotBlank(newIp)) { if (StringUtils.isBlank(oldIp) || !oldIp.equals(newIp)) { LOG.debug("Cart {} is accessed from IP {}", shoppingCart.getGuid(), newIp); shoppingCart.getShoppingContext().setResolvedIp(newIp); shoppingCart.markDirty(); } } } } }
SetIpInternalCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String oldIp = shoppingCart.getShoppingContext().getResolvedIp(); final String newIp = (String) parameters.get(getCmdKey()); if (StringUtils.isNotBlank(newIp)) { if (StringUtils.isBlank(oldIp) || !oldIp.equals(newIp)) { LOG.debug("Cart {} is accessed from IP {}", shoppingCart.getGuid(), newIp); shoppingCart.getShoppingContext().setResolvedIp(newIp); shoppingCart.markDirty(); } } } } SetIpInternalCommandImpl(final ShoppingCartCommandRegistry registry); }
SetIpInternalCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String oldIp = shoppingCart.getShoppingContext().getResolvedIp(); final String newIp = (String) parameters.get(getCmdKey()); if (StringUtils.isNotBlank(newIp)) { if (StringUtils.isBlank(oldIp) || !oldIp.equals(newIp)) { LOG.debug("Cart {} is accessed from IP {}", shoppingCart.getGuid(), newIp); shoppingCart.getShoppingContext().setResolvedIp(newIp); shoppingCart.markDirty(); } } } } SetIpInternalCommandImpl(final ShoppingCartCommandRegistry registry); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters); @Override String getCmdKey(); }
SetIpInternalCommandImpl extends AbstractCartCommandImpl implements ShoppingCartCommand { @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { if (parameters.containsKey(getCmdKey())) { final String oldIp = shoppingCart.getShoppingContext().getResolvedIp(); final String newIp = (String) parameters.get(getCmdKey()); if (StringUtils.isNotBlank(newIp)) { if (StringUtils.isBlank(oldIp) || !oldIp.equals(newIp)) { LOG.debug("Cart {} is accessed from IP {}", shoppingCart.getGuid(), newIp); shoppingCart.getShoppingContext().setResolvedIp(newIp); shoppingCart.markDirty(); } } } } SetIpInternalCommandImpl(final ShoppingCartCommandRegistry registry); @Override void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters); @Override String getCmdKey();  }