@Test
  public void testJobDeployUndeployFlow() throws InterruptedException {
    logger.info("Create batch job");
    JobParametersHolder.reset();
    final JobParametersHolder jobParametersHolder = new JobParametersHolder();
    String jobName = generateJobName();
    executeJobCreate(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, false);

    checkForJobInList(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, false);
    CommandResult cr = deployJob(jobName);
    checkForSuccess(cr);
    checkDeployedJobMessage(cr, jobName);
    triggerJob(jobName);
    assertTrue("Job did not complete within time alotted", jobParametersHolder.isDone());

    checkForJobInList(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, true);

    cr = undeployJob(jobName);
    checkForSuccess(cr);
    checkUndeployedJobMessage(cr, jobName);

    cr = deployJob(jobName);
    checkForSuccess(cr);
    assertEquals("Deployed job '" + jobName + "'", cr.getResult());

    checkForJobInList(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, true);
  }
  @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 testListRuntimeModulesByInvalidContainerId() {
   logger.info("Test listing of runtime modules by invalid containerId");
   String streamName = "foo-runtimeModulesByInvalidContainerIdTest";
   stream().create(streamName, "time | log");
   CommandResult cmdResult = executeCommand("runtime modules --containerId 10000");
   Table table = (Table) cmdResult.getResult();
   assertEquals(0, table.getRows().size());
 }
  @Test
  public void testSimple() {
    Bootstrap bootstrap = new Bootstrap();

    JLineShellComponent shell = bootstrap.getJLineShellComponent();

    CommandResult cr = shell.executeCommand("hw simple --message hello");
    assertEquals(true, cr.isSuccess());
    assertEquals("Message = [hello] Location = [null]", cr.getResult());
  }
 @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());
 }