@Test public void testRemapCommandChainEmpty() throws Exception { final List<ConfigurableShoppingCartCommand> commands = Collections.EMPTY_LIST; final ShoppingCartCommand[] chain = new ShoppingCartCommandFactoryImpl(null).remapCommandChain(commands); assertNotNull(chain); assertEquals(0, chain.length); }
ConfigurableShoppingCartCommand[] remapCommandChain(final Collection<ConfigurableShoppingCartCommand> commands) { final List<ConfigurableShoppingCartCommand> ordered = new ArrayList<>(commands); ordered.sort((cmd1, cmd2) -> cmd1.getPriority() - cmd2.getPriority()); return ordered.toArray(new ConfigurableShoppingCartCommand[ordered.size()]); }
ShoppingCartCommandFactoryImpl implements ShoppingCartCommandFactory, ShoppingCartCommandRegistry { ConfigurableShoppingCartCommand[] remapCommandChain(final Collection<ConfigurableShoppingCartCommand> commands) { final List<ConfigurableShoppingCartCommand> ordered = new ArrayList<>(commands); ordered.sort((cmd1, cmd2) -> cmd1.getPriority() - cmd2.getPriority()); return ordered.toArray(new ConfigurableShoppingCartCommand[ordered.size()]); } }
ShoppingCartCommandFactoryImpl implements ShoppingCartCommandFactory, ShoppingCartCommandRegistry { ConfigurableShoppingCartCommand[] remapCommandChain(final Collection<ConfigurableShoppingCartCommand> commands) { final List<ConfigurableShoppingCartCommand> ordered = new ArrayList<>(commands); ordered.sort((cmd1, cmd2) -> cmd1.getPriority() - cmd2.getPriority()); return ordered.toArray(new ConfigurableShoppingCartCommand[ordered.size()]); } ShoppingCartCommandFactoryImpl(final ShoppingCartCommandConfigurationProvider configurationProvider); }
ShoppingCartCommandFactoryImpl implements ShoppingCartCommandFactory, ShoppingCartCommandRegistry { ConfigurableShoppingCartCommand[] remapCommandChain(final Collection<ConfigurableShoppingCartCommand> commands) { final List<ConfigurableShoppingCartCommand> ordered = new ArrayList<>(commands); ordered.sort((cmd1, cmd2) -> cmd1.getPriority() - cmd2.getPriority()); return ordered.toArray(new ConfigurableShoppingCartCommand[ordered.size()]); } ShoppingCartCommandFactoryImpl(final ShoppingCartCommandConfigurationProvider configurationProvider); @Override void registerCommand(final ConfigurableShoppingCartCommand command); @Override void execute(final ShoppingCart shoppingCart, final Map<String, Object> parameters); @Override void execute(final String key, final ShoppingCart shoppingCart, final Map<String, Object> parameters); @Override String getCmdKey(); @Override int getPriority(); }
ShoppingCartCommandFactoryImpl implements ShoppingCartCommandFactory, ShoppingCartCommandRegistry { ConfigurableShoppingCartCommand[] remapCommandChain(final Collection<ConfigurableShoppingCartCommand> commands) { final List<ConfigurableShoppingCartCommand> ordered = new ArrayList<>(commands); ordered.sort((cmd1, cmd2) -> cmd1.getPriority() - cmd2.getPriority()); return ordered.toArray(new ConfigurableShoppingCartCommand[ordered.size()]); } ShoppingCartCommandFactoryImpl(final ShoppingCartCommandConfigurationProvider configurationProvider); @Override void registerCommand(final ConfigurableShoppingCartCommand command); @Override void execute(final ShoppingCart shoppingCart, final Map<String, Object> parameters); @Override void execute(final String key, final ShoppingCart shoppingCart, final Map<String, Object> parameters); @Override String getCmdKey(); @Override int getPriority();  }