]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1330 Remove qualityprofiles from api/rules/app
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 28 Sep 2017 08:23:02 +0000 (10:23 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 2 Oct 2017 15:18:15 +0000 (17:18 +0200)
server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/AppActionTest.java

index c632542e5928bc4143fee1153299376c3337d3f3..c2ffa261bbd68f80db93e8aca2393e514f17ba45 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.permission.OrganizationPermission;
-import org.sonar.db.qualityprofile.QProfileDto;
 import org.sonar.server.user.UserSession;
 
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
@@ -73,7 +72,6 @@ public class AppAction implements RulesWsAction {
       JsonWriter json = response.newJsonWriter();
       json.beginObject();
       addPermissions(organization, json);
-      addProfiles(dbSession, organization, json);
       addLanguages(json);
       addRuleRepositories(json, dbSession);
       json.endObject().close();
@@ -85,27 +83,6 @@ public class AppAction implements RulesWsAction {
     json.prop("canWrite", canWrite);
   }
 
-  private void addProfiles(DbSession dbSession, OrganizationDto organization, JsonWriter json) {
-    json.name("qualityprofiles").beginArray();
-    for (QProfileDto profile : dbClient.qualityProfileDao().selectOrderedByOrganizationUuid(dbSession, organization)) {
-      if (languageIsSupported(profile)) {
-        json
-          .beginObject()
-          .prop("key", profile.getKee())
-          .prop("name", profile.getName())
-          .prop("lang", profile.getLanguage())
-          .prop("parentKey", profile.getParentKee())
-          .prop("isBuiltIn", profile.isBuiltIn())
-          .endObject();
-      }
-    }
-    json.endArray();
-  }
-
-  private boolean languageIsSupported(QProfileDto profile) {
-    return languages.get(profile.getLanguage()) != null;
-  }
-
   private void addLanguages(JsonWriter json) {
     json.name("languages").beginObject();
     for (Language language : languages.all()) {
index 7cfeed6dcd5e82880adcf0a7baf926294d22c4f2..a1346d28df4451bb5e96004fd4f600a9d4fed73f 100644 (file)
@@ -29,13 +29,11 @@ import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.permission.OrganizationPermission;
-import org.sonar.db.qualityprofile.QProfileDto;
 import org.sonar.db.rule.RuleRepositoryDto;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.language.LanguageTesting;
 import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.organization.TestDefaultOrganizationProvider;
-import org.sonar.server.qualityprofile.QProfileTesting;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsActionTester;
 
@@ -107,56 +105,6 @@ public class AppActionTest {
       "}");
   }
 
-  @Test
-  public void response_contains_quality_profiles_of_default_organization() {
-    insertQualityProfiles(db.getDefaultOrganization());
-
-    String json = tester.newRequest().execute().getInput();
-    assertJson(json).isSimilarTo("{" +
-      "\"qualityprofiles\": [" +
-      "    {" +
-      "      \"key\": \"XOO_P1\"," +
-      "      \"name\": \"P1\"," +
-      "      \"lang\": \"xoo\"," +
-      "      \"isBuiltIn\": true" +
-      "    }," +
-      "    {" +
-      "      \"key\": \"XOO_P2\"," +
-      "      \"name\": \"P2\"," +
-      "      \"lang\": \"xoo\"," +
-      "      \"parentKey\": \"XOO_P1\"," +
-      "      \"isBuiltIn\": false" +
-      "    }" +
-      "  ]" +
-      "}");
-  }
-
-  @Test
-  public void response_contains_quality_profiles_of_specified_organization() {
-    OrganizationDto org = db.organizations().insert();
-    insertQualityProfiles(org);
-
-    String json = tester.newRequest()
-      .setParam("organization", org.getKey())
-      .execute().getInput();
-
-    assertJson(json).isSimilarTo("{" +
-      "\"qualityprofiles\": [" +
-      "    {" +
-      "      \"key\": \"XOO_P1\"," +
-      "      \"name\": \"P1\"," +
-      "      \"lang\": \"xoo\"" +
-      "    }," +
-      "    {" +
-      "      \"key\": \"XOO_P2\"," +
-      "      \"name\": \"P2\"," +
-      "      \"lang\": \"xoo\"," +
-      "      \"parentKey\": \"XOO_P1\"" +
-      "    }" +
-      "  ]" +
-      "}");
-  }
-
   @Test
   public void throw_NotFoundException_if_organization_does_not_exist() {
     expectedException.expect(NotFoundException.class);
@@ -218,11 +166,4 @@ public class AppActionTest {
     db.getSession().commit();
   }
 
-  private void insertQualityProfiles(OrganizationDto organization) {
-    QProfileDto profile1 = QProfileTesting.newXooP1(organization).setIsBuiltIn(true);
-    QProfileDto profile2 = QProfileTesting.newXooP2(organization).setParentKee(QProfileTesting.XOO_P1_KEY);
-    db.getDbClient().qualityProfileDao().insert(db.getSession(), profile1);
-    db.getDbClient().qualityProfileDao().insert(db.getSession(), profile2);
-    db.commit();
-  }
 }