static Command createCommand(String name, Anchor anchor) { return createCommand(name, anchor, null); }
@Test public void testSortByAnchor_BeforeAndLast_2() { List<Command> commands = toList(createCommand("a", BEFORE, "b"), createCommand("b", LAST, null)); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_BeforeAndLast_3() { List<Command> commands = toList(createCommand("a", BEFORE, "c"), createCommand("b", BEFORE, "c"), createCommand("c", LAST)); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); assertEquals("c", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_NoneAndAfter_2() { List<Command> commands = toList(createCommand("a"), createCommand("b", AFTER, "a")); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); }
static Command createCommand(String name) { return createCommand(name, null, null); }
@Test public void testSortByAnchor_FirstAndLast_2() { List<Command> commands = toList(createCommand("a", FIRST), createCommand("b", LAST)); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_FirstAndAfter_3() { List<Command> commands = toList(createCommand("a", FIRST), createCommand("b", AFTER, "a"), createCommand("c", AFTER, "a")); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); assertEquals("c", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_NoneAndAfter_3() { List<Command> commands = toList(createCommand("a"), createCommand("b", AFTER, "a"), createCommand("c", AFTER, "b")); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); assertEquals("c", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_FirstOnly_3() { List<Command> commands = toList(createCommand("a", FIRST), createCommand("b", FIRST), createCommand("c", FIRST)); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); assertEquals("c", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_LastOnly_3() { List<Command> commands = toList(createCommand("a", LAST), createCommand("b", LAST), createCommand("c", LAST)); reverseList(commands); sortCommandsByAnchor(commands); int index = 0; assertEquals("a", commands.get(index++).getCommandID()); assertEquals("b", commands.get(index++).getCommandID()); assertEquals("c", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_AllKinds_4() { List<Command> commands = toList(createCommand("a", FIRST), createCommand("b", AFTER, "a"), createCommand("c", BEFORE, "d"), createCommand("d", LAST, null)); reverseList(commands); sortCommandsByAnchor(commands); int 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()); }
@Test public void testSortByAnchor_NoneAndAfter_5() { List<Command> commands = toList(createCommand("a"), createCommand("b", AFTER, "a"), createCommand("c", AFTER, "b"), createCommand("d", AFTER, "c"), createCommand("e", AFTER, "d")); reverseList(commands); sortCommandsByAnchor(commands); int 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()); assertEquals("e", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_FirstAndLast_6() { List<Command> commands = toList(createCommand("a", FIRST), createCommand("b", FIRST), createCommand("c", FIRST), createCommand("d", LAST), createCommand("e", LAST), createCommand("f", LAST)); reverseList(commands); sortCommandsByAnchor(commands); int 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()); assertEquals("e", commands.get(index++).getCommandID()); assertEquals("f", commands.get(index++).getCommandID()); }
@Test public void testSortByAnchor_AllKinds_12() { List<Command> commands = toList(createCommand("a", FIRST), createCommand("b", FIRST), createCommand("c", FIRST), createCommand("d", AFTER, "c"), createCommand("e", AFTER, "c"), createCommand("f", AFTER, "c"), createCommand("g", BEFORE, "j"), createCommand("h", BEFORE, "j"), createCommand("i", BEFORE, "j"), createCommand("j", LAST), createCommand("k", LAST), createCommand("l", LAST)); reverseList(commands); sortCommandsByAnchor(commands); int 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()); assertEquals("e", commands.get(index++).getCommandID()); assertEquals("f", commands.get(index++).getCommandID()); assertEquals("g", commands.get(index++).getCommandID()); assertEquals("h", commands.get(index++).getCommandID()); assertEquals("i", commands.get(index++).getCommandID()); assertEquals("j", commands.get(index++).getCommandID()); assertEquals("k", commands.get(index++).getCommandID()); assertEquals("l", commands.get(index++).getCommandID()); }
@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()); }