@VisibleForTesting
  void checkNoPendingTasks(DbSession dbSession, EntityDto entityDto) {
    //This check likely can be removed when we remove the column 'private' from components table in SONAR-20126.
    checkState(countPendingTask(dbSession, entityDto.getKey()) == 0, "Component visibility can't be changed as long as it has background task(s) pending or in progress");
  }
@Test
  void checkNoPendingTasks_whenAnyOtherTaskInQueue_throws() {
    EntityDto entityDto = mockEntityDto();
    when(dbClient.entityDao().selectByKey(dbSession, entityDto.getKey())).thenReturn(Optional.of(entityDto));

    mockCeQueueDto("ANYTHING", entityDto.getUuid());

    assertThatIllegalStateException()
      .isThrownBy(() -> visibilityService.checkNoPendingTasks(dbSession, entityDto))
      .withMessage("Component visibility can't be changed as long as it has background task(s) pending or in progress");
  }