@Test
 public void testStopAllJobExecutions() throws Exception {
   String jobName = generateJobName();
   executeJobCreate(jobName, JOB_WITH_STEP_EXECUTIONS);
   checkForJobInList(jobName, JOB_WITH_STEP_EXECUTIONS, true);
   triggerJobWithDelay(jobName, "5");
   Thread.sleep(5000);
   Table table = (Table) executeCommand("job execution list").getResult();
   assertTrue(!table.getRows().isEmpty());
   String executionId = table.getRows().get(0).getValue(1);
   String executionStatus = table.getRows().get(0).getValue(5);
   assertTrue(executionStatus.equals("STARTING") || executionStatus.equals("STARTED"));
   // Stop the execution by the given executionId.
   executeCommand("job execution all stop --force true");
   // sleep for stop() until the step2 is invoked.
   Thread.sleep(3000);
   table = (Table) executeCommand("job execution list").getResult();
   for (TableRow tr : table.getRows()) {
     // Match by above executionId
     if (tr.getValue(1).equals(executionId)) {
       executionStatus = tr.getValue(5);
       break;
     }
   }
   assertEquals("STOPPED", executionStatus);
 }
  @Test
  public void testListRuntimeModulesByContainerId() {
    logger.info("Test listing of runtime modules by containerId");
    String streamName = "foo-runtimeModulesByContainerIdTest";
    stream().create(streamName, "time | log");

    Table table = (Table) executeCommand("runtime modules").getResult();
    List<TableRow> runtimeModules = new ArrayList<TableRow>();
    for (TableRow row : table.getRows()) {
      // match by group name
      if (row.getValue(2).equals(streamName)) {
        runtimeModules.add(row);
      }
    }
    // Get containerId for a runtime module
    String containerId = runtimeModules.get(0).getValue(1);
    CommandResult cmdResult = executeCommand("runtime modules --containerId " + containerId);
    Table table1 = (Table) cmdResult.getResult();
    List<TableRow> fooStreamModules = new ArrayList<TableRow>();
    for (TableRow row : table1.getRows()) {
      // Verify all the rows have the same containerId
      assertTrue(row.getValue(1).equals(containerId));
      // match by group name
      if (row.getValue(2).equals(runtimeModules.get(0).getValue(2))) {
        fooStreamModules.add(row);
      }
    }
    // Verify the module is listed for the containerId
    assertTrue(!fooStreamModules.isEmpty());
  }
 @Test
 public void testListContainers() {
   logger.info("List runtime containers");
   CommandResult cmdResult = executeCommand("runtime containers");
   Table table = (Table) cmdResult.getResult();
   for (TableRow row : table.getRows()) {
     // Verify host name & ip address are not empty
     assertTrue(!StringUtils.isEmpty(row.getValue(2)) && !StringUtils.isEmpty(row.getValue(3)));
   }
   // Verify there should be at least one container in the list.
   assertTrue(table.getRows().size() > 0);
 }
 @Test
 public void testListRuntimeModules() {
   logger.info("List runtime modules");
   String streamName = "foo-runtimeModulesTest";
   stream().create(streamName, "time | log");
   CommandResult cmdResult = executeCommand("runtime modules");
   Table table = (Table) cmdResult.getResult();
   List<TableRow> fooStreamModules = new ArrayList<TableRow>();
   for (TableRow row : table.getRows()) {
     // match by group name
     if (row.getValue(2).equals(streamName)) {
       fooStreamModules.add(row);
     }
   }
   assertEquals(2, fooStreamModules.size());
 }
 @CliCommand(value = MODULE_INFO, help = "Get information about a module")
 public String moduleInfo(
     @CliOption(
             mandatory = true,
             key = {"name", ""},
             help = "name of the module to query, in the form 'type:name'")
         QualifiedModuleName module,
     @CliOption(
             key = "hidden",
             help = "whether to show 'hidden' options",
             specifiedDefaultValue = "true",
             unspecifiedDefaultValue = "false")
         boolean showHidden) {
   DetailedModuleDefinitionResource info = moduleOperations().info(module.name, module.type);
   List<Option> options = info.getOptions();
   StringBuilder result = new StringBuilder();
   result
       .append("Information about ")
       .append(module.type.name())
       .append(" module '")
       .append(module.name)
       .append("':\n\n");
   if (options == null) {
     result.append("Module options metadata is not available");
   } else {
     Table table =
         new Table()
             .addHeader(1, new TableHeader("Option Name"))
             .addHeader(2, new TableHeader("Description"))
             .addHeader(3, new TableHeader("Default"))
             .addHeader(4, new TableHeader("Type"));
     for (DetailedModuleDefinitionResource.Option o : options) {
       if (!showHidden && o.isHidden()) {
         continue;
       }
       final TableRow row = new TableRow();
       row.addValue(1, o.getName())
           .addValue(2, o.getDescription())
           .addValue(3, o.getDefaultValue() == null ? "<none>" : o.getDefaultValue())
           .addValue(4, o.getType() == null ? "<unknown>" : o.getType());
       table.getRows().add(row);
     }
     result.append(table.toString());
   }
   return result.toString();
 }