assertEquals(Arrays.asList("another "), complete(comp, "an"));
}
@Test
public void testGlobalCompletion() throws Exception {
Context context = new Context();
context.set("SCOPE", "*");
context.set(SessionProperties.COMPLETION_MODE, "global");
CommandSessionHolder.setSession(context.getSession());
context.addCommand("*", new SimpleSubShell("foo"), "foo");
context.addCommand("*", new SimpleCommand(ExitAction.class), "exit");
context.addCommand("foo", new SimpleCommand(MyAction.class), "my-action");
context.addCommand("foo", new SimpleCommand(MyActionTwoArguments.class), "one-action");
context.addCommand("bar", new SimpleCommand(MyAction.class), "one-action");
context.addCommand("bar", new SimpleCommand(MyActionTwoArguments.class), "another");
Completer comp = new CommandsCompleter(context.getSession());
context.execute("foo");
assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
assertEquals(Arrays.asList("*:exit", "*:foo", "another", "bar:another",
"bar:one-action", "exit", "foo",
"foo:my-action", "foo:one-action", "my-action",
"one-action", "one-action"), complete(comp, ""));
assertEquals(Arrays.asList("another "), complete(comp, "an"));
assertEquals(Arrays.asList("--check", "--foo", "--help", "--integer", "--string"),
complete(comp, "my-action --"));
assertEquals(Arrays.asList("--dummy", "--help"), complete(comp, "one-action --"));
context.execute("exit");
assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
assertEquals(Arrays.asList("*:exit", "*:foo", "another", "bar:another",
"bar:one-action", "exit", "foo",
"foo:my-action", "foo:one-action", "my-action",
"one-action", "one-action"), complete(comp, ""));