DefaultCommandMenuInserter implements CommandMenuInserter { static void sortCommandsByName(List<Command> commands) { Collections.sort(commands, NAME_COMPARATOR); } DefaultCommandMenuInserter(CommandManager commandManager); @Override void insertCommandIntoMenu(Command newCommand, JMenu menu);  }
@Test public void testSortByName() { List<Command> commands = toList(createCommand("a"), createCommand("b"), createCommand("c"), createCommand("d")); reverseList(commands); int index = 0; assertEquals("d", commands.get(index++).getCommandID()); assertEquals("c", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); assertEquals("a", commands.get(index++).getCommandID()); sortCommandsByName(commands); index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); assertEquals("c", commands.get(index++).getCommandID()); assertEquals("d", commands.get(index++).getCommandID()); }