@Test
  public void testInitTask() throws Exception {
    pipelineStoreTask.create("user", "aaaa", "blah", false);
    pipelineStateStore.saveState(
        "user",
        "aaaa",
        "0",
        PipelineStatus.CONNECTING,
        "blah",
        null,
        ExecutionMode.STANDALONE,
        null,
        0,
        0);
    pipelineManager.stop();
    pipelineStoreTask.stop();

    setUpManager(StandaloneAndClusterPipelineManager.DEFAULT_RUNNER_EXPIRY_INTERVAL, false);

    await().atMost(Duration.FIVE_SECONDS).until(numPipelinesEqualTo(pipelineManager, 1));

    List<PipelineState> pipelineStates = pipelineManager.getPipelines();
    assertEquals(1, pipelineStates.size());
    assertTrue(
        ((StandaloneAndClusterPipelineManager) pipelineManager).isRunnerPresent("aaaa", "0"));

    pipelineManager.stop();
    pipelineStoreTask.stop();
    pipelineStateStore.saveState(
        "user",
        "aaaa",
        "0",
        PipelineStatus.FINISHING,
        "blah",
        null,
        ExecutionMode.STANDALONE,
        null,
        0,
        0);

    setUpManager(StandaloneAndClusterPipelineManager.DEFAULT_RUNNER_EXPIRY_INTERVAL, false);
    await().atMost(Duration.FIVE_SECONDS).until(numPipelinesEqualTo(pipelineManager, 1));

    pipelineStates = pipelineManager.getPipelines();
    assertEquals(1, pipelineStates.size());
    // no runner is created
    assertFalse(
        ((StandaloneAndClusterPipelineManager) pipelineManager).isRunnerPresent("aaaa", "0"));
  }
  @Test
  public void testGetPipelineStates() throws Exception {
    pipelineStoreTask.create("user", "aaaa", "blah", false);
    List<PipelineState> pipelineStates = pipelineManager.getPipelines();

    assertEquals("aaaa", pipelineStates.get(0).getName());
    assertEquals("0", pipelineStates.get(0).getRev());

    pipelineStoreTask.create("user", "bbbb", "blah", false);
    pipelineStates = pipelineManager.getPipelines();
    assertEquals(2, pipelineStates.size());

    pipelineStoreTask.delete("aaaa");
    pipelineStates = pipelineManager.getPipelines();
    assertEquals(1, pipelineStates.size());
    pipelineStoreTask.delete("bbbb");
    pipelineStates = pipelineManager.getPipelines();
    assertEquals(0, pipelineStates.size());
  }