]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8918 Drop QProfileLookup
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 27 Jun 2017 09:58:11 +0000 (11:58 +0200)
committerTeryk Bellahsene <teryk@users.noreply.github.com>
Wed, 28 Jun 2017 13:46:36 +0000 (15:46 +0200)
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchDataLoaderTest.java [deleted file]

index abf786f89c0e1bb4d932ec89df2085a5a47b361e..8321a4ba0ffcc1147cb32e83dd73380a100abb54 100644 (file)
@@ -47,9 +47,9 @@ import org.sonar.server.component.ws.ComponentsWsModule;
 import org.sonar.server.debt.DebtModelPluginRepository;
 import org.sonar.server.debt.DebtModelXMLExporter;
 import org.sonar.server.debt.DebtRulesXMLImporter;
-import org.sonar.server.duplication.ws.ShowResponseBuilder;
 import org.sonar.server.duplication.ws.DuplicationsParser;
 import org.sonar.server.duplication.ws.DuplicationsWs;
+import org.sonar.server.duplication.ws.ShowResponseBuilder;
 import org.sonar.server.email.ws.EmailsWsModule;
 import org.sonar.server.es.IndexCreator;
 import org.sonar.server.es.IndexDefinitions;
@@ -147,7 +147,6 @@ import org.sonar.server.qualityprofile.QProfileComparison;
 import org.sonar.server.qualityprofile.QProfileCopier;
 import org.sonar.server.qualityprofile.QProfileExporters;
 import org.sonar.server.qualityprofile.QProfileFactoryImpl;
-import org.sonar.server.qualityprofile.QProfileLookup;
 import org.sonar.server.qualityprofile.QProfileResetImpl;
 import org.sonar.server.qualityprofile.RuleActivator;
 import org.sonar.server.qualityprofile.RuleActivatorContextFactory;
@@ -156,7 +155,6 @@ import org.sonar.server.qualityprofile.index.ActiveRuleIteratorFactory;
 import org.sonar.server.qualityprofile.ws.OldRestoreAction;
 import org.sonar.server.qualityprofile.ws.ProfilesWs;
 import org.sonar.server.qualityprofile.ws.QProfilesWsModule;
-import org.sonar.server.qualityprofile.ws.SearchDataLoader;
 import org.sonar.server.root.ws.RootWsModule;
 import org.sonar.server.rule.CommonRuleDefinitionsImpl;
 import org.sonar.server.rule.DeprecatedRulesDefinitionLoader;
@@ -265,9 +263,7 @@ public class PlatformLevel4 extends PlatformLevel {
       XMLProfileParser.class,
       XMLProfileSerializer.class,
       AnnotationProfileParser.class,
-      QProfileLookup.class,
       QProfileComparison.class,
-      SearchDataLoader.class,
       ProfilesWs.class,
       OldRestoreAction.class,
       RuleActivator.class,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
deleted file mode 100644 (file)
index df0e398..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.qualityprofile;
-
-import java.util.Collection;
-import java.util.List;
-import org.sonar.api.server.ServerSide;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.qualityprofile.QProfileDto;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-@ServerSide
-public class QProfileLookup {
-
-  private final DbClient dbClient;
-
-  public QProfileLookup(DbClient dbClient) {
-    this.dbClient = dbClient;
-  }
-
-  public List<QProfileDto> allProfiles(DbSession dbSession, OrganizationDto organization) {
-    return dbClient.qualityProfileDao().selectOrderedByOrganizationUuid(dbSession, organization);
-  }
-
-  public Collection<QProfileDto> profiles(DbSession dbSession, String language, OrganizationDto organization) {
-    return dbClient.qualityProfileDao().selectByLanguage(dbSession, organization, language);
-  }
-
-  public List<QProfileDto> ancestors(QProfileDto profile, DbSession dbSession) {
-    List<QProfileDto> ancestors = newArrayList();
-    collectAncestors(profile, ancestors, dbSession);
-    return ancestors;
-  }
-
-  private void collectAncestors(QProfileDto profile, List<QProfileDto> ancestors, DbSession session) {
-    if (profile.getParentKee() == null) {
-      return;
-    }
-
-    QProfileDto parent = getParent(session, profile);
-    ancestors.add(parent);
-    collectAncestors(parent, ancestors, session);
-  }
-
-  private QProfileDto getParent(DbSession dbSession, QProfileDto profile) {
-    QProfileDto parent = dbClient.qualityProfileDao().selectByUuid(dbSession, profile.getParentKee());
-    if (parent == null) {
-      throw new IllegalStateException("Cannot find parent of profile: " + profile.getKee());
-    }
-    return parent;
-  }
-}
index ec7f3e408af82203e1866d83467a837db264006d..1dc37834cfc0a348a7bf6ca67d57a443a2920b32 100644 (file)
@@ -33,10 +33,10 @@ import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.qualityprofile.ActiveRuleDao;
 import org.sonar.db.qualityprofile.ActiveRuleDto;
 import org.sonar.db.qualityprofile.QProfileDto;
-import org.sonar.server.qualityprofile.QProfileLookup;
 import org.sonarqube.ws.QualityProfiles.InheritanceWsResponse;
 import org.sonarqube.ws.QualityProfiles.InheritanceWsResponse.QualityProfile;
 
+import static com.google.common.collect.Lists.newArrayList;
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.server.qualityprofile.ws.QProfileWsSupport.createOrganizationParam;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
@@ -44,13 +44,11 @@ import static org.sonar.server.ws.WsUtils.writeProtobuf;
 public class InheritanceAction implements QProfileWsAction {
 
   private final DbClient dbClient;
-  private final QProfileLookup profileLookup;
   private final QProfileWsSupport wsSupport;
   private final Languages languages;
 
-  public InheritanceAction(DbClient dbClient, QProfileLookup profileLookup, QProfileWsSupport wsSupport, Languages languages) {
+  public InheritanceAction(DbClient dbClient, QProfileWsSupport wsSupport, Languages languages) {
     this.dbClient = dbClient;
-    this.profileLookup = profileLookup;
     this.wsSupport = wsSupport;
     this.languages = languages;
   }
@@ -74,7 +72,7 @@ public class InheritanceAction implements QProfileWsAction {
     try (DbSession dbSession = dbClient.openSession(false)) {
       QProfileDto profile = wsSupport.getProfile(dbSession, reference);
       OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
-      List<QProfileDto> ancestors = profileLookup.ancestors(profile, dbSession);
+      List<QProfileDto> ancestors = ancestors(profile, dbSession);
       List<QProfileDto> children = dbClient.qualityProfileDao().selectChildren(dbSession, profile);
       Statistics statistics = new Statistics(dbSession, organization);
 
@@ -82,6 +80,30 @@ public class InheritanceAction implements QProfileWsAction {
     }
   }
 
+  public List<QProfileDto> ancestors(QProfileDto profile, DbSession dbSession) {
+    List<QProfileDto> ancestors = newArrayList();
+    collectAncestors(profile, ancestors, dbSession);
+    return ancestors;
+  }
+
+  private void collectAncestors(QProfileDto profile, List<QProfileDto> ancestors, DbSession session) {
+    if (profile.getParentKee() == null) {
+      return;
+    }
+
+    QProfileDto parent = getParent(session, profile);
+    ancestors.add(parent);
+    collectAncestors(parent, ancestors, session);
+  }
+
+  private QProfileDto getParent(DbSession dbSession, QProfileDto profile) {
+    QProfileDto parent = dbClient.qualityProfileDao().selectByUuid(dbSession, profile.getParentKee());
+    if (parent == null) {
+      throw new IllegalStateException("Cannot find parent of profile: " + profile.getKee());
+    }
+    return parent;
+  }
+
   private static InheritanceWsResponse buildResponse(QProfileDto profile, List<QProfileDto> ancestors, List<QProfileDto> children, Statistics statistics) {
     return InheritanceWsResponse.newBuilder()
       .setProfile(buildProfile(profile, statistics))
index ccb4d363021d9aa77a4e82d0ef7dca5fd8e488d6..866a33dc734ac7ac2d506409ec65db377033016c 100644 (file)
@@ -59,7 +59,6 @@ import static java.util.function.Function.identity;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
-import static org.sonar.server.ws.WsUtils.checkFoundWithOptional;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
@@ -231,14 +230,6 @@ public class SearchAction implements QProfileWsAction {
     return Arrays.stream(languages.all()).map(Language::getKey).collect(MoreCollectors.toSet());
   }
 
-  private ComponentDto getProject(String moduleKey, DbSession dbSession) {
-    ComponentDto module = checkFoundWithOptional(dbClient.componentDao().selectByKey(dbSession, moduleKey), "Component key '%s' not found", moduleKey);
-    if (module.isRootProject()) {
-      return module;
-    }
-    return dbClient.componentDao().selectOrFailByUuid(dbSession, module.projectUuid());
-  }
-
   private SearchWsResponse buildResponse(SearchData data) {
     List<QProfileDto> profiles = data.getProfiles();
     Map<String, QProfileDto> profilesByKey = profiles.stream().collect(Collectors.toMap(QProfileDto::getKee, identity()));
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java
deleted file mode 100644 (file)
index dcc7f8c..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.qualityprofile.ws;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Sets;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-import javax.annotation.Nullable;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Languages;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.qualityprofile.QProfileDto;
-import org.sonar.server.qualityprofile.QProfileLookup;
-import org.sonarqube.ws.client.qualityprofile.SearchWsRequest;
-
-import static java.lang.String.format;
-
-public class SearchDataLoader {
-
-  private static final Comparator<QProfileDto> Q_PROFILE_COMPARATOR = Comparator
-    .comparing(QProfileDto::getLanguage)
-    .thenComparing(QProfileDto::getName);
-
-  private final Languages languages;
-  private final QProfileLookup profileLookup;
-  private final DbClient dbClient;
-
-  public SearchDataLoader(Languages languages, QProfileLookup profileLookup, DbClient dbClient) {
-    this.languages = languages;
-    this.profileLookup = profileLookup;
-    this.dbClient = dbClient;
-  }
-
-  @VisibleForTesting
-  List<QProfileDto> findProfiles(DbSession dbSession, SearchWsRequest request, OrganizationDto organization, @Nullable ComponentDto project) {
-    Collection<QProfileDto> profiles;
-    if (askDefaultProfiles(request)) {
-      profiles = findDefaultProfiles(dbSession, request, organization);
-    } else if (project != null) {
-      profiles = findProjectProfiles(dbSession, request, organization, project);
-    } else {
-      profiles = findAllProfiles(dbSession, request, organization);
-    }
-
-    return profiles.stream().sorted(Q_PROFILE_COMPARATOR).collect(Collectors.toList());
-  }
-
-  private Collection<QProfileDto> findDefaultProfiles(DbSession dbSession, SearchWsRequest request, OrganizationDto organization) {
-    String profileName = request.getProfileName();
-
-    Set<String> languageKeys = getLanguageKeys();
-    Map<String, QProfileDto> qualityProfiles = new HashMap<>(languageKeys.size());
-
-    Set<String> missingLanguageKeys = lookupByProfileName(dbSession, organization, qualityProfiles, languageKeys, profileName);
-    Set<String> noDefaultProfileLanguageKeys = lookupDefaults(dbSession, organization, qualityProfiles, missingLanguageKeys);
-
-    if (!noDefaultProfileLanguageKeys.isEmpty()) {
-      throw new IllegalStateException(format("No quality profile can been found on language(s) '%s'", noDefaultProfileLanguageKeys));
-    }
-
-    return qualityProfiles.values();
-  }
-
-  private Collection<QProfileDto> findProjectProfiles(DbSession dbSession, SearchWsRequest request, OrganizationDto organization, ComponentDto project) {
-    String profileName = request.getProfileName();
-
-    Set<String> languageKeys = getLanguageKeys();
-    Map<String, QProfileDto> qualityProfiles = new HashMap<>(languageKeys.size());
-
-    // look up profiles by profileName (if any) for each language
-    Set<String> unresolvedLanguages = lookupByProfileName(dbSession, organization, qualityProfiles, languageKeys, profileName);
-    // look up profile by componentKey for each language for which we don't have one yet
-    Set<String> stillUnresolvedLanguages = lookupByModule(dbSession, qualityProfiles, unresolvedLanguages, project);
-    // look up profile by default for each language for which we don't have one yet
-    Set<String> noDefaultProfileLanguages = lookupDefaults(dbSession, organization, qualityProfiles, stillUnresolvedLanguages);
-
-    if (!noDefaultProfileLanguages.isEmpty()) {
-      throw new IllegalStateException(format("No quality profile can been found on language(s) '%s' for project '%s'", noDefaultProfileLanguages, project.getKey()));
-    }
-
-    return qualityProfiles.values();
-  }
-
-  private Collection<QProfileDto> findAllProfiles(DbSession dbSession, SearchWsRequest request, OrganizationDto organization) {
-    String language = request.getLanguage();
-
-    if (language == null) {
-      return profileLookup.allProfiles(dbSession, organization).stream().filter(qProfile -> languages.get(qProfile.getLanguage()) != null).collect(Collectors.toList());
-    }
-    return profileLookup.profiles(dbSession, language, organization);
-  }
-
-  private Set<String> lookupByProfileName(DbSession dbSession, OrganizationDto organization, Map<String, QProfileDto> qualityProfiles, Set<String> languageKeys,
-                                          @Nullable String profileName) {
-    if (languageKeys.isEmpty() || profileName == null) {
-      return languageKeys;
-    }
-
-    dbClient.qualityProfileDao().selectByNameAndLanguages(dbSession, organization, profileName, languageKeys)
-      .forEach(qualityProfile -> qualityProfiles
-        .put(qualityProfile.getLanguage(), qualityProfile));
-    return difference(languageKeys, qualityProfiles.keySet());
-  }
-
-  private Set<String> lookupByModule(DbSession dbSession, Map<String, QProfileDto> qualityProfiles, Set<String> languageKeys,
-                                     ComponentDto project) {
-    if (languageKeys.isEmpty()) {
-      return languageKeys;
-    }
-
-    dbClient.qualityProfileDao().selectAssociatedToProjectUuidAndLanguages(dbSession, project, languageKeys)
-      .forEach(qualityProfile -> qualityProfiles.put(qualityProfile.getLanguage(), qualityProfile));
-    return difference(languageKeys, qualityProfiles.keySet());
-  }
-
-  private Set<String> lookupDefaults(DbSession dbSession, OrganizationDto organization, Map<String, QProfileDto> qualityProfiles, Set<String> languageKeys) {
-    if (languageKeys.isEmpty()) {
-      return languageKeys;
-    }
-
-    addAll(qualityProfiles, findDefaultProfiles(dbSession, organization, languageKeys));
-    return difference(languageKeys, qualityProfiles.keySet());
-  }
-
-  private static <T> Set<T> difference(Set<T> languageKeys, Set<T> set2) {
-    return Sets.newHashSet(Sets.difference(languageKeys, set2));
-  }
-
-  private static void addAll(Map<String, QProfileDto> qualityProfiles, Collection<QProfileDto> list) {
-    list.forEach(qualityProfile -> qualityProfiles.put(qualityProfile.getLanguage(), qualityProfile));
-  }
-
-  private Set<String> getLanguageKeys() {
-    return Arrays.stream(languages.all()).map(Language::getKey).collect(Collectors.toSet());
-  }
-
-  private List<QProfileDto> findDefaultProfiles(final DbSession dbSession, OrganizationDto organization, Set<String> languageKeys) {
-    return dbClient.qualityProfileDao().selectDefaultProfiles(dbSession, organization, languageKeys);
-  }
-
-  private static boolean askDefaultProfiles(SearchWsRequest request) {
-    return request.getDefaults();
-  }
-}
index 89a2c524942d8d2e4c8ad4fc532ae8512e13b0d1..df88fa461d77d6403379a2d8cf1c7ea31b576347 100644 (file)
@@ -45,7 +45,6 @@ import org.sonar.server.es.EsClient;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.organization.TestDefaultOrganizationProvider;
-import org.sonar.server.qualityprofile.QProfileLookup;
 import org.sonar.server.qualityprofile.QProfileName;
 import org.sonar.server.qualityprofile.RuleActivation;
 import org.sonar.server.qualityprofile.RuleActivator;
@@ -96,7 +95,6 @@ public class InheritanceActionTest {
     TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
     underTest = new InheritanceAction(
       dbClient,
-      new QProfileLookup(dbClient),
       new QProfileWsSupport(dbClient, userSession, defaultOrganizationProvider),
       new Languages());
     ws = new WsActionTester(underTest);
index 26cd142d965c70716cd767e279f9c5b5e1684a1c..40fc22c8f41f07693905a2eaf60e25e6967f94fc 100644 (file)
@@ -68,7 +68,7 @@ public class QProfilesWsTest {
       new CompareAction(null, null, languages),
       new DeleteAction(languages, null, null, userSessionRule, wsSupport),
       new ExportersAction(),
-      new InheritanceAction(null, null, null, languages),
+      new InheritanceAction(null, null, languages),
       new RenameAction(dbClient, userSessionRule, wsSupport))).controller(QProfilesWs.API_ENDPOINT);
   }
 
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchDataLoaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchDataLoaderTest.java
deleted file mode 100644 (file)
index 55f4c18..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.qualityprofile.ws;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.resources.Languages;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.qualityprofile.QProfileLookup;
-
-import static org.mockito.Mockito.mock;
-
-public class SearchDataLoaderTest {
-
-  @Rule
-  public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  private Languages languages;
-  private QProfileLookup profileLookup;
-  private ComponentFinder componentFinder;
-  private OrganizationDto organization;
-
-  @Before
-  public void before() {
-    organization = dbTester.organizations().insert();
-    languages = new Languages();
-    DbClient dbClient = dbTester.getDbClient();
-    profileLookup = new QProfileLookup(dbClient);
-    componentFinder = mock(ComponentFinder.class);
-  }
-
-//  @Test
-//  public void find_no_profiles_if_database_is_empty() throws Exception {
-//    assertThat(findProfiles(
-//      new SearchWsRequest(),
-//      null)).isEmpty();
-//  }
-//
-//  @Test
-//  public void findAll() throws Exception {
-//    insertQualityProfile(organization);
-//    assertThat(findProfiles(
-//      new SearchWsRequest()
-//        .setOrganizationKey(organization.getKey()),
-//      null)).hasSize(1);
-//  }
-//
-//  @Test
-//  public void findDefaults() throws Exception {
-//    QProfileDto profile = insertQualityProfile(organization);
-//    dbTester.qualityProfiles().setAsDefault(profile);
-//    assertThat(findProfiles(
-//      new SearchWsRequest()
-//        .setOrganizationKey(organization.getKey())
-//        .setDefaults(true),
-//      null)).hasSize(1);
-//  }
-//
-//  @Test
-//  public void findForProject() throws Exception {
-//    QProfileDto profile = insertQualityProfile(organization);
-//    dbTester.qualityProfiles().setAsDefault(profile);
-//    ComponentDto project1 = insertProject();
-//    assertThat(findProfiles(
-//      new SearchWsRequest()
-//        .setOrganizationKey(organization.getKey()),
-//      project1)).hasSize(1);
-//  }
-//
-//  @Test
-//  public void findAllForLanguage() throws Exception {
-//    QProfileDto profile = insertQualityProfile(organization);
-//    dbTester.qualityProfiles().setAsDefault(profile);
-//    assertThat(findProfiles(
-//      new SearchWsRequest()
-//        .setOrganizationKey(organization.getKey())
-//        .setLanguage(profile.getLanguage()),
-//      null)).hasSize(1);
-//    assertThat(findProfiles(
-//      new SearchWsRequest()
-//        .setOrganizationKey(organization.getKey())
-//        .setLanguage("other language"),
-//      null)).hasSize(0);
-//  }
-//
-//  private List<QProfileDto> findProfiles(SearchWsRequest request, @Nullable ComponentDto project) {
-//    return new SearchDataLoader(languages, profileLookup, dbTester.getDbClient())
-//      .findProfiles(dbTester.getSession(), request, organization, project);
-//  }
-//
-//  private QProfileDto insertQualityProfile(OrganizationDto organization) {
-//    Language language = insertLanguage();
-//    return dbTester.qualityProfiles().insert(organization, p -> p.setLanguage(language.getKey()));
-//  }
-//
-//  private Language insertLanguage() {
-//    Language language = LanguageTesting.newLanguage(randomAlphanumeric(20));
-//    languages.add(language);
-//    return language;
-//  }
-//
-//  private ComponentDto insertProject() {
-//    ComponentDto project = dbTester.components().insertPrivateProject(organization);
-//    doReturn(project).when(componentFinder).getByKey(any(DbSession.class), eq(project.getKey()));
-//    return project;
-//  }
-}