public void testOfficialPluginsHelpSorted() throws Exception {
    MockTerminal terminal = new MockTerminal();
    new InstallPluginCommand().main(new String[] {"--help"}, terminal);
    try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) {
      String line = reader.readLine();

      // first find the beginning of our list of official plugins
      while (line.endsWith("may be installed by name:") == false) {
        line = reader.readLine();
      }

      // now check each line compares greater than the last, until we reach an empty line
      String prev = reader.readLine();
      line = reader.readLine();
      while (line != null && line.trim().isEmpty() == false) {
        assertTrue(prev + " < " + line, prev.compareTo(line) < 0);
        prev = line;
        line = reader.readLine();
      }
    }
  }
 public void testQuietFlagEnabled() throws Exception {
   MockTerminal terminal = new MockTerminal();
   terminal.setVerbosity(Terminal.Verbosity.SILENT);
   installPlugin(terminal, false);
   assertThat(terminal.getOutput(), not(containsString("100%")));
 }
 public void testQuietFlagDisabled() throws Exception {
   MockTerminal terminal = new MockTerminal();
   terminal.setVerbosity(randomFrom(Terminal.Verbosity.NORMAL, Terminal.Verbosity.VERBOSE));
   installPlugin(terminal, false);
   assertThat(terminal.getOutput(), containsString("100%"));
 }
 public void testBatchFlag() throws Exception {
   MockTerminal terminal = new MockTerminal();
   installPlugin(terminal, true);
   assertThat(
       terminal.getOutput(), containsString("WARNING: plugin requires additional permissions"));
 }
 public void testOfficialPluginsIncludesXpack() throws Exception {
   MockTerminal terminal = new MockTerminal();
   new InstallPluginCommand().main(new String[] {"--help"}, terminal);
   assertTrue(terminal.getOutput(), terminal.getOutput().contains("x-pack"));
 }