CommandHandler { public String[] commandDetection(@NotNull final String[] split) { return commandTree.joinArgsForKnownCommands(split); } protected  CommandHandler(@NotNull final CommandProvider commandProvider); boolean registerCommand(@NotNull Class<? extends Command> commandClass); boolean registerCommand(@NotNull CommandProvider commandProvider, @NotNull Class<? extends Command> commandClass); boolean confirmCommand(@NotNull final BasePlayer player); boolean locateAndRunCommand(@NotNull final BasePlayer player, @NotNull String[] args); String[] commandDetection(@NotNull final String[] split); List<String> tabComplete(@NotNull final BasePlayer player, @NotNull String[] args); static final Message NO_QUEUED_COMMANDS; static final Message MUST_CONFIRM; static final Message PERMISSION_DENIED; static final Message TOO_FEW_ARGUMENTS; static final Message TOO_MANY_ARGUMENTS; static final Message UNKNOWN_FLAG; static final Message USAGE_ERROR; static final Message VALUE_FLAG_ALREADY_GIVEN; static final Message NO_VALUE_FOR_VALUE_FLAG; static final Message SUB_COMMAND_LIST; }
@Test public void testCommandDetection() throws Exception { TestPlugin plugin = PowerMockito.mock(TestPlugin.class); CommandHandler ch = Mockito.spy(new CommandHandler(plugin) { { configureCommandKeys("pb"); configureCommandKeys("pb reload"); } @Override protected boolean register(CommandRegistration commandInfo, Command cmd) { return true; } }); String[] res = ch.commandDetection(new String[] {"pb"}); assertEquals(res.length, 1); assertEquals(res[0], "pb"); res = ch.commandDetection(new String[] {"pb", "reload"}); assertEquals(res.length, 1); assertEquals(res[0], "pb reload"); res = ch.commandDetection(new String[] {"pb", "reload", "poop"}); assertEquals(res.length, 2); assertEquals(res[0], "pb reload"); assertEquals(res[1], "poop"); }