@Override
  public void finished(boolean allStepsExecuted) {
    if (postProjectAnalysisTasks.length == 0) {
      return;
    }

    ProjectAnalysisImpl projectAnalysis = createProjectAnalysis(allStepsExecuted ? SUCCESS : FAILED);
    for (PostProjectAnalysisTask postProjectAnalysisTask : postProjectAnalysisTasks) {
      executeTask(projectAnalysis, postProjectAnalysisTask);
    }
  }
@Test
  @UseDataProvider("booleanValues")
  public void finished_does_not_fail_if_listener_throws_exception_and_execute_subsequent_listeners(boolean allStepsExecuted) {
    PostProjectAnalysisTask postProjectAnalysisTask1 = newPostProjectAnalysisTask("PT1");
    PostProjectAnalysisTask postProjectAnalysisTask2 = newPostProjectAnalysisTask("PT2");
    PostProjectAnalysisTask postProjectAnalysisTask3 = newPostProjectAnalysisTask("PT3");
    InOrder inOrder = inOrder(postProjectAnalysisTask1, postProjectAnalysisTask2, postProjectAnalysisTask3);

    doThrow(new RuntimeException("Faking a listener throws an exception"))
      .when(postProjectAnalysisTask2)
      .finished(any(PostProjectAnalysisTask.Context.class));

    new PostProjectAnalysisTasksExecutor(
      ceTask, analysisMetadataHolder, qualityGateHolder, qualityGateStatusHolder, reportReader,
      new PostProjectAnalysisTask[] {postProjectAnalysisTask1, postProjectAnalysisTask2, postProjectAnalysisTask3})
        .finished(allStepsExecuted);

    inOrder.verify(postProjectAnalysisTask1).finished(taskContextCaptor.capture());
    inOrder.verify(postProjectAnalysisTask1).getDescription();
    inOrder.verify(postProjectAnalysisTask2).finished(taskContextCaptor.capture());
    inOrder.verify(postProjectAnalysisTask2).getDescription();
    inOrder.verify(postProjectAnalysisTask3).finished(taskContextCaptor.capture());
    inOrder.verify(postProjectAnalysisTask3).getDescription();
    inOrder.verifyNoMoreInteractions();

    assertThat(logTester.logs()).hasSize(4);
    List<String> logs = logTester.logs(Level.INFO);
    assertThat(logs).hasSize(3);
    assertThat(logs.get(0)).matches("^PT1 \\| status=SUCCESS \\| time=\\d+ms$");
    assertThat(logs.get(1)).matches("^PT2 \\| status=FAILED \\| time=\\d+ms$");
    assertThat(logs.get(2)).matches("^PT3 \\| status=SUCCESS \\| time=\\d+ms$");
  }