@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
  public void branch_comes_from_AnalysisMetadataHolder_when_set() {
    analysisMetadataHolder.setBranch(new Branch() {
      @Override
      public BranchType getType() {
        return BranchType.BRANCH;
      }

      @Override
      public boolean isMain() {
        return false;
      }

      @Override
      public String getReferenceBranchUuid() {
        throw new UnsupportedOperationException();
      }

      @Override
      public String getName() {
        return "feature/foo";
      }

      @Override
      public boolean supportsCrossProjectCpd() {
        throw new UnsupportedOperationException();
      }

      @Override
      public String getPullRequestKey() {
        throw new UnsupportedOperationException();
      }

      @Override
      public String getTargetBranchName() {
        throw new UnsupportedOperationException();
      }

      @Override
      public String generateKey(String projectKey, @Nullable String fileOrDirPath) {
        throw new UnsupportedOperationException();
      }
    });

    underTest.finished(true);

    verify(postProjectAnalysisTask).finished(taskContextCaptor.capture());

    org.sonar.api.ce.posttask.Branch branch = taskContextCaptor.getValue().getProjectAnalysis().getBranch().get();
    assertThat(branch.isMain()).isFalse();
    assertThat(branch.getName()).hasValue("feature/foo");
    assertThat(branch.getType()).isEqualTo(BranchImpl.Type.BRANCH);
  }