OnlineCommandProcessor implements CommandProcessor { public ResultModel executeCommand(String command) { return executeCommand(command, Collections.emptyMap(), null); } OnlineCommandProcessor(); @VisibleForTesting  OnlineCommandProcessor(GfshParser gfshParser,
      SecurityService securityService,
      CommandExecutor commandExecutor); ParseResult parseCommand(String commentLessLine); ResultModel executeCommand(String command); ResultModel executeCommand(String command, Map<String, String> env,
      List<String> stagedFilePaths); @Override String executeCommandReturningJson(String command, Map<String, String> env,
      List<String> stagedFilePaths); @Override boolean init(Cache cache); @Override Class<? extends CacheService> getInterface(); @Override CacheServiceMBeanBase getMBean();  }
@Test public void executeWithNullThrowsNPE() { assertThatThrownBy(() -> onlineCommandProcessor.executeCommand(null)) .isInstanceOf(NullPointerException.class); }
@Test public void executeWithEmpty() { assertThat(onlineCommandProcessor.executeCommand("")).isNull(); }
@Test public void executeStripsComments() { Object commandResult = onlineCommandProcessor.executeCommand(""); assertThat(commandResult).isNull(); }
@Test public void executeReturnsExecutorResult() { ResultModel commandResult = onlineCommandProcessor.executeCommand("start locator"); assertThat(commandResult).isSameAs(result); }
@Test public void handlesNotAuthorizedException() { when(executor.execute(any())).thenThrow(new NotAuthorizedException("not authorized")); assertThatThrownBy(() -> onlineCommandProcessor.executeCommand("start locator")) .isInstanceOf(NotAuthorizedException.class); }
@Test public void handlesParsingError() { ResultModel commandResult = onlineCommandProcessor.executeCommand("foo --bar"); assertThat(commandResult).isInstanceOf(ResultModel.class); assertThat(commandResult.toString()) .contains("Could not parse command string. foo --bar") .contains( "The command or some options in this command may not be supported by this locator"); }