public void checkIfAnyComponentsNeedIssueSync(DbSession dbSession, List<String> componentKeys) {
    boolean isAppOrViewOrSubview = dbClient.componentDao().existAnyOfComponentsWithQualifiers(dbSession, componentKeys, APP_VIEW_OR_SUBVIEW);
    boolean needIssueSync;
    if (isAppOrViewOrSubview) {
      needIssueSync = dbClient.branchDao().hasAnyBranchWhereNeedIssueSync(dbSession, true);
    } else {
      needIssueSync = dbClient.branchDao().doAnyOfComponentsNeedIssueSync(dbSession, componentKeys);
    }
    if (needIssueSync) {
      throw new EsIndexSyncInProgressException(IssueIndexDefinition.TYPE_ISSUE.getMainType(),
          "Results are temporarily unavailable. Indexing of issues is in progress.");
    }
  }
@Test
  public void checkIfAnyComponentsNeedIssueSync_single_view_subview_or_app() {
    ProjectData projectData1 = insertProjectWithBranches(true, 0);

    ComponentDto app = db.components().insertPublicApplication().getMainBranchComponent();
    ComponentDto view = db.components().insertPrivatePortfolio();
    ComponentDto subview = db.components().insertSubView(view);

    DbSession session = db.getSession();
    List<String> appViewOrSubviewKeys = Arrays.asList(projectData1.getProjectDto().getKey(), app.getKey(), view.getKey(), subview.getKey());

    // throws if flag set to TRUE
    assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session,
      appViewOrSubviewKeys))
        .isInstanceOf(EsIndexSyncInProgressException.class)
        .hasFieldOrPropertyWithValue("httpCode", 503)
        .hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
  }