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_whenNoTasksLeft_shouldReturnCompleted() {
    IssueSyncProgress issueSyncProgress = underTest.getIssueSyncProgress(db.getSession());
    assertThat(issueSyncProgress.getCompletedCount()).isZero();
    assertThat(issueSyncProgress.getTotal()).isZero();
    assertThat(issueSyncProgress.isCompleted()).isTrue();
    assertThat(issueSyncProgress.hasFailures()).isFalse();
  }