public IssueSyncProgress getIssueSyncProgress(DbSession dbSession) {
    int completedCount = dbClient.projectDao().countIndexedProjects(dbSession);
    int total = dbClient.projectDao().countProjects(dbSession);
    boolean hasFailures = dbClient.ceActivityDao().hasAnyFailedOrCancelledIssueSyncTask(dbSession);
    boolean isCompleted = !dbClient.ceQueueDao().hasAnyIssueSyncTaskPendingOrInProgress(dbSession);
    return new IssueSyncProgress(isCompleted, completedCount, total, hasFailures);
  }
@Test
  public void getIssueSyncProgress_whenTasksExist_shouldReturnFailures() {
    assertThat(underTest.getIssueSyncProgress(db.getSession()).hasFailures()).isFalse();

    ProjectData projectData1 = insertProjectWithBranches(false, 0);
    insertCeActivity("TASK_1", projectData1, SUCCESS);

    ProjectData projectData2 = insertProjectWithBranches(false, 0);
    insertCeActivity("TASK_2", projectData2, SUCCESS);

    assertThat(underTest.getIssueSyncProgress(db.getSession()).hasFailures()).isFalse();

    ProjectData projectData3 = insertProjectWithBranches(true, 0);
    insertCeActivity("TASK_3", projectData3, FAILED);

    assertThat(underTest.getIssueSyncProgress(db.getSession()).hasFailures()).isTrue();
  }