]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9302 Add IT to test built-in Quality Profiles
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 30 May 2017 07:52:06 +0000 (09:52 +0200)
committerEric Hartmann <hartmann.eric@gmail.com>
Wed, 14 Jun 2017 13:43:12 +0000 (15:43 +0200)
it/it-tests/src/test/java/it/Category6Suite.java
it/it-tests/src/test/java/it/qualityProfile/QualityProfilesBuiltInTest.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java
server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-inheritance.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/inheritance-example.json [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/rule/ws/app-example.json
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/AppActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/InheritanceActionTest/inheritance-buWide.json
sonar-ws/src/main/protobuf/ws-qualityprofiles.proto

index 23383060fd29a3441096474c6c40e9ebb1972dcc..d3ee5e44e755b70a13740ab7bea01895bc18aa0b 100644 (file)
@@ -28,6 +28,7 @@ import it.organization.OrganizationTest;
 import it.projectSearch.LeakProjectsPageTest;
 import it.projectSearch.SearchProjectsTest;
 import it.qualityProfile.OrganizationQualityProfilesPageTest;
+import it.qualityProfile.QualityProfilesBuiltInTest;
 import it.uiExtension.OrganizationUiExtensionsTest;
 import it.user.OrganizationIdentityProviderTest;
 import org.junit.BeforeClass;
@@ -50,6 +51,7 @@ import static util.ItUtils.xooPlugin;
   OrganizationQualityProfilesPageTest.class,
   OrganizationTest.class,
   OrganizationUiExtensionsTest.class,
+  QualityProfilesBuiltInTest.class,
   BillingTest.class,
   IssueTagsTest.class,
   LeakProjectsPageTest.class,
diff --git a/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesBuiltInTest.java b/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesBuiltInTest.java
new file mode 100644 (file)
index 0000000..74c7498
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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 it.qualityProfile;
+
+import com.sonar.orchestrator.Orchestrator;
+import it.Category6Suite;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.QualityProfiles.SearchWsResponse;
+import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.organization.CreateWsRequest;
+import org.sonarqube.ws.client.qualityprofile.SearchWsRequest;
+
+import static it.Category6Suite.enableOrganizationsSupport;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.newOrganizationKey;
+
+public class QualityProfilesBuiltInTest {
+
+  private static final String ANOTHER_ORGANIZATION = newOrganizationKey();
+  @ClassRule
+  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+  private static WsClient adminWsClient;
+
+  @BeforeClass
+  public static void setUp() {
+    enableOrganizationsSupport();
+    adminWsClient = newAdminWsClient(orchestrator);
+  }
+
+  @Test
+  public void xoo_profiles_provided() {
+    SearchWsResponse result = adminWsClient.qualityProfiles().search(new SearchWsRequest());
+
+    assertThat(result.getProfilesList())
+      .extracting(QualityProfile::getOrganization, QualityProfile::getName, QualityProfile::getLanguage, QualityProfile::getIsBuiltIn, QualityProfile::getIsDefault)
+      .containsExactlyInAnyOrder(
+        tuple("default-organization", "Basic", "xoo", true, true),
+        tuple("default-organization", "empty", "xoo", true, false),
+        tuple("default-organization", "Basic", "xoo2", true, true));
+  }
+
+  @Test
+  public void xoo_profiles_provided_copied_to_new_organization() {
+    adminWsClient.organizations().create(new CreateWsRequest.Builder()
+      .setKey(ANOTHER_ORGANIZATION)
+      .setName(ANOTHER_ORGANIZATION).build());
+    SearchWsResponse result = adminWsClient.qualityProfiles().search(new SearchWsRequest()
+      .setOrganizationKey(ANOTHER_ORGANIZATION));
+
+    assertThat(result.getProfilesList())
+      .extracting(QualityProfile::getOrganization, QualityProfile::getName, QualityProfile::getLanguage, QualityProfile::getIsBuiltIn, QualityProfile::getIsDefault)
+      .containsExactlyInAnyOrder(
+        tuple(ANOTHER_ORGANIZATION, "Basic", "xoo", true, true),
+        tuple(ANOTHER_ORGANIZATION, "empty", "xoo", true, false),
+        tuple(ANOTHER_ORGANIZATION, "Basic", "xoo2", true, true));
+  }
+}
index bfd5374d9b05e3494e4b2fa822ad5a831701a08c..f5637e27de9b6b112b8681eddf4e41df46174fbf 100644 (file)
@@ -22,13 +22,11 @@ package org.sonar.server.qualityprofile.ws;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
-import javax.annotation.Nullable;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService.NewAction;
 import org.sonar.api.server.ws.WebService.NewController;
-import org.sonar.core.util.Protobuf;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.organization.OrganizationDto;
@@ -39,6 +37,7 @@ import org.sonar.server.qualityprofile.QProfileLookup;
 import org.sonarqube.ws.QualityProfiles.InheritanceWsResponse;
 import org.sonarqube.ws.QualityProfiles.InheritanceWsResponse.QualityProfile;
 
+import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
 public class InheritanceAction implements QProfileWsAction {
@@ -61,7 +60,7 @@ public class InheritanceAction implements QProfileWsAction {
       .setSince("5.2")
       .setDescription("Show a quality profile's ancestors and children.")
       .setHandler(this)
-      .setResponseExample(getClass().getResource("example-inheritance.json"));
+      .setResponseExample(getClass().getResource("inheritance-example.json"));
 
     QProfileWsSupport.createOrganizationParam(inheritance)
       .setSince("6.4");
@@ -92,29 +91,27 @@ public class InheritanceAction implements QProfileWsAction {
       .build();
   }
 
-  private static QualityProfile buildProfile(RulesProfileDto profile, Statistics statistics) {
-    return buildProfile(profile.getKey(), profile.getName(), profile.getParentKee(), statistics);
-  }
-
   private static Iterable<QualityProfile> buildAncestors(List<RulesProfileDto> ancestors, Statistics statistics) {
     return ancestors.stream()
-      .map(ancestor -> buildProfile(ancestor.getKey(), ancestor.getName(), ancestor.getParentKee(), statistics))
+      .map(ancestor -> buildProfile(ancestor, statistics))
       .collect(Collectors.toList());
   }
 
   private static Iterable<QualityProfile> buildChildren(List<RulesProfileDto> children, Statistics statistics) {
     return children.stream()
-      .map(child -> buildProfile(child.getKey(), child.getName(), null, statistics))
+      .map(child -> buildProfile(child, statistics))
       .collect(Collectors.toList());
   }
 
-  private static QualityProfile buildProfile(String key, String name, @Nullable String parentKey, Statistics statistics) {
+  private static QualityProfile buildProfile(RulesProfileDto qualityProfile, Statistics statistics) {
+    String key = qualityProfile.getKey();
     QualityProfile.Builder builder = QualityProfile.newBuilder()
       .setKey(key)
-      .setName(name)
+      .setName(qualityProfile.getName())
       .setActiveRuleCount(statistics.countRulesByProfileKey.getOrDefault(key, 0L))
-      .setOverridingRuleCount(statistics.countOverridingRulesByProfileKey.getOrDefault(key, 0L));
-    Protobuf.setNullable(parentKey, builder::setParent);
+      .setOverridingRuleCount(statistics.countOverridingRulesByProfileKey.getOrDefault(key, 0L))
+      .setIsBuiltIn(qualityProfile.isBuiltIn());
+    setNullable(qualityProfile.getParentKee(), builder::setParent);
     return builder.build();
   }
 
index 9be8848e4d666900b50dce620180918068d63fa8..961a7558b0be7130a2d396214c7d7794bc28e439 100644 (file)
@@ -95,6 +95,7 @@ public class AppAction implements RulesWsAction {
           .prop("name", profile.getName())
           .prop("lang", profile.getLanguage())
           .prop("parentKey", profile.getParentKee())
+          .prop("isBuiltIn", profile.isBuiltIn())
           .endObject();
       }
     }
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-inheritance.json b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-inheritance.json
deleted file mode 100644 (file)
index 82a75e7..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-  "profile": {
-    "key": "AU-TpxcA-iU5OvuD2FL5",
-    "name": "My BU Profile",
-    "parent": "AU-TpxcA-iU5OvuD2FL2",
-    "activeRuleCount": 3,
-    "overridingRuleCount": 1
-  },
-  "ancestors": [
-    {
-      "key": "AU-TpxcA-iU5OvuD2FL1",
-      "name": "My Company Profile",
-      "parent": "xoo-my-group-profile-01234",
-      "activeRuleCount": 3
-    },
-    {
-      "key": "AU-TpxcA-iU5OvuD2FL0",
-      "name": "My Group Profile",
-      "activeRuleCount": 2
-    }
-  ],
-  "children": [
-    {
-      "key": "AU-TpxcB-iU5OvuD2FL6",
-      "name": "For Project One",
-      "activeRuleCount": 5
-    },
-    {
-      "key": "AU-TpxcB-iU5OvuD2FL7",
-      "name": "For Project Two",
-      "activeRuleCount": 4,
-      "overridingRuleCount": 1
-    }
-  ]
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/inheritance-example.json b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/inheritance-example.json
new file mode 100644 (file)
index 0000000..7bc9289
--- /dev/null
@@ -0,0 +1,40 @@
+{
+  "profile": {
+    "key": "AU-TpxcA-iU5OvuD2FL5",
+    "name": "My BU Profile",
+    "parent": "AU-TpxcA-iU5OvuD2FL2",
+    "activeRuleCount": 3,
+    "overridingRuleCount": 1,
+    "isBuiltIn": false
+  },
+  "ancestors": [
+    {
+      "key": "AU-TpxcA-iU5OvuD2FL1",
+      "name": "My Company Profile",
+      "parent": "xoo-my-group-profile-01234",
+      "activeRuleCount": 3,
+      "isBuiltIn": false
+    },
+    {
+      "key": "AU-TpxcA-iU5OvuD2FL0",
+      "name": "Sonar way",
+      "activeRuleCount": 2,
+      "isBuiltIn": true
+    }
+  ],
+  "children": [
+    {
+      "key": "AU-TpxcB-iU5OvuD2FL6",
+      "name": "For Project One",
+      "activeRuleCount": 5,
+      "isBuiltIn": false
+    },
+    {
+      "key": "AU-TpxcB-iU5OvuD2FL7",
+      "name": "For Project Two",
+      "activeRuleCount": 4,
+      "overridingRuleCount": 1,
+      "isBuiltIn": false
+    }
+  ]
+}
index 3fbf7c3b693dff973307347fc9e47e6aaf43ea8e..cbd432356679a79d866ef3c78481757519f07f33 100644 (file)
 {
   "canWrite": false,
   "qualityprofiles": [
-    {
-      "key": "cs-c-qp-for-sonarsource-73109",
-      "name": "C# QP for SonarSource",
-      "lang": "cs"
-    },
-    {
-      "key": "java-default-with-mojo-conventions-49307",
-      "name": "Default - Maven Conventions",
-      "lang": "java",
-      "parentKey": "java-top-profile-without-formatting-conventions-50037"
-    },
-    {
-      "key": "java-default-with-sonarsource-conventions-27339",
-      "name": "Default - SonarSource conventions",
-      "lang": "java",
-      "parentKey": "java-top-profile-without-formatting-conventions-50037"
-    },
     {
       "key": "java-top-profile-without-formatting-conventions-50037",
       "name": "Default - Top",
-      "lang": "java"
-    },
-    {
-      "key": "php-drupal-15274",
-      "name": "Drupal",
-      "lang": "php"
-    },
-    {
-      "key": "java-findbugs-14954",
-      "name": "FindBugs",
-      "lang": "java"
-    },
-    {
-      "key": "java-findbugs-security-audit-88783",
-      "name": "FindBugs Security Audit",
-      "lang": "java"
-    },
-    {
-      "key": "java-findbugs-security-minimal-21735",
-      "name": "FindBugs Security Minimal",
-      "lang": "java"
-    },
-    {
-      "key": "java-for-sq-java-plugin-only-92289",
-      "name": "For Java and JavaScript Plugins",
       "lang": "java",
-      "parentKey": "java-default-with-sonarsource-conventions-27339"
-    },
-    {
-      "key": "java-for-sq-only-95381",
-      "name": "For SQ Only",
-      "lang": "java",
-      "parentKey": "java-default-with-sonarsource-conventions-27339"
-    },
-    {
-      "key": "php-psr-2-06315",
-      "name": "PSR-2",
-      "lang": "php"
-    },
-    {
-      "key": "js-sonarsource-javascript-conventions-62984",
-      "name": "SonarSource JavaScript Conventions",
-      "lang": "js",
-      "parentKey": "js-sonar-way"
-    },
-    {
-      "key": "c-sonar-way",
-      "name": "Sonar way",
-      "lang": "c"
-    },
-    {
-      "key": "cpp-sonar-way",
-      "name": "Sonar way",
-      "lang": "cpp"
-    },
-    {
-      "key": "cs-sonar-way-94087",
-      "name": "Sonar way",
-      "lang": "cs"
-    },
-    {
-      "key": "grvy-sonar-way-06443",
-      "name": "Sonar way",
-      "lang": "grvy"
+      "isBuiltIn": false
     },
     {
       "key": "java-sonar-way-80423",
       "name": "Sonar way",
-      "lang": "java"
+      "lang": "java",
+      "isBuiltIn": true
     },
     {
       "key": "js-sonar-way",
       "name": "Sonar way",
-      "lang": "js"
-    },
-    {
-      "key": "objc-sonar-way-10164",
-      "name": "Sonar way",
-      "lang": "objc"
+      "lang": "js",
+      "isBuiltIn": true
     },
     {
       "key": "php-sonar-way-05548",
       "name": "Sonar way",
-      "lang": "php"
-    },
-    {
-      "key": "java-without-findbugs",
-      "name": "Without Findbugs",
-      "lang": "java"
+      "lang": "php",
+      "isBuiltIn": true
     }
   ],
   "languages": {
-    "c": "C",
-    "cpp": "C++",
-    "objc": "Objective-C",
     "js": "JavaScript",
-    "cs": "C#",
-    "grvy": "Groovy",
     "java": "Java",
     "php": "PHP"
   },
       "name": "Clirr",
       "language": "java"
     },
-    {
-      "key": "grvy",
-      "name": "CodeNarc",
-      "language": "grvy"
-    },
-    {
-      "key": "common-c",
-      "name": "Common SonarQube",
-      "language": "c"
-    },
-    {
-      "key": "common-cpp",
-      "name": "Common SonarQube",
-      "language": "cpp"
-    },
-    {
-      "key": "common-cs",
-      "name": "Common SonarQube",
-      "language": "cs"
-    },
-    {
-      "key": "common-grvy",
-      "name": "Common SonarQube",
-      "language": "grvy"
-    },
     {
       "key": "common-java",
       "name": "Common SonarQube",
       "name": "Common SonarQube",
       "language": "js"
     },
-    {
-      "key": "common-objc",
-      "name": "Common SonarQube",
-      "language": "objc"
-    },
     {
       "key": "common-php",
       "name": "Common SonarQube",
       "language": "php"
     },
-    {
-      "key": "c-cppcheck",
-      "name": "Cppcheck",
-      "language": "c"
-    },
-    {
-      "key": "cpp-cppcheck",
-      "name": "Cppcheck",
-      "language": "cpp"
-    },
-    {
-      "key": "fxcop",
-      "name": "FxCop / Code Analysis",
-      "language": "cs"
-    },
-    {
-      "key": "resharper-cs",
-      "name": "ReSharper",
-      "language": "cs"
-    },
-    {
-      "key": "resharper-vbnet",
-      "name": "ReSharper",
-      "language": "vbnet"
-    },
-    {
-      "key": "c",
-      "name": "SonarQube",
-      "language": "c"
-    },
-    {
-      "key": "cpp",
-      "name": "SonarQube",
-      "language": "cpp"
-    },
-    {
-      "key": "csharpsquid",
-      "name": "SonarQube",
-      "language": "cs"
-    },
     {
       "key": "javascript",
       "name": "SonarQube",
       "language": "js"
     },
-    {
-      "key": "objc",
-      "name": "SonarQube",
-      "language": "objc"
-    },
     {
       "key": "php",
       "name": "SonarQube",
       "key": "squid",
       "name": "SonarQube",
       "language": "java"
-    },
-    {
-      "key": "stylecop",
-      "name": "StyleCop",
-      "language": "cs"
     }
   ],
   "statuses": {
       "key": "TRANSPORTABILITY",
       "name": "Transportability",
       "parent": "REUSABILITY"
-    },
-    {
-      "key": "PORTABILITY",
-      "name": "Portability"
-    },
-    {
-      "key": "COMPILER_RELATED_PORTABILITY",
-      "name": "Compiler",
-      "parent": "PORTABILITY"
-    },
-    {
-      "key": "HARDWARE_RELATED_PORTABILITY",
-      "name": "Hardware",
-      "parent": "PORTABILITY"
-    },
-    {
-      "key": "LANGUAGE_RELATED_PORTABILITY",
-      "name": "Language",
-      "parent": "PORTABILITY"
-    },
-    {
-      "key": "OS_RELATED_PORTABILITY",
-      "name": "OS",
-      "parent": "PORTABILITY"
-    },
-    {
-      "key": "PORTABILITY_COMPLIANCE",
-      "name": "Portability Compliance",
-      "parent": "PORTABILITY"
-    },
-    {
-      "key": "SOFTWARE_RELATED_PORTABILITY",
-      "name": "Software",
-      "parent": "PORTABILITY"
-    },
-    {
-      "key": "TIME_ZONE_RELATED_PORTABILITY",
-      "name": "Time zone",
-      "parent": "PORTABILITY"
-    },
-    {
-      "key": "MAINTAINABILITY",
-      "name": "Maintainability"
-    },
-    {
-      "key": "MAINTAINABILITY_COMPLIANCE",
-      "name": "Maintainability Compliance",
-      "parent": "MAINTAINABILITY"
-    },
-    {
-      "key": "READABILITY",
-      "name": "Readability",
-      "parent": "MAINTAINABILITY"
-    },
-    {
-      "key": "UNDERSTANDABILITY",
-      "name": "Understandability",
-      "parent": "MAINTAINABILITY"
-    },
-    {
-      "key": "SECURITY",
-      "name": "Security"
-    },
-    {
-      "key": "API_ABUSE",
-      "name": "API abuse",
-      "parent": "SECURITY"
-    },
-    {
-      "key": "ERRORS",
-      "name": "Errors",
-      "parent": "SECURITY"
-    },
-    {
-      "key": "INPUT_VALIDATION_AND_REPRESENTATION",
-      "name": "Input validation and representation",
-      "parent": "SECURITY"
-    },
-    {
-      "key": "SECURITY_COMPLIANCE",
-      "name": "Security Compliance",
-      "parent": "SECURITY"
-    },
-    {
-      "key": "SECURITY_FEATURES",
-      "name": "Security features",
-      "parent": "SECURITY"
-    },
-    {
-      "key": "USABILITY",
-      "name": "Usability"
-    },
-    {
-      "key": "USABILITY_ACCESSIBILITY",
-      "name": "Accessibility",
-      "parent": "USABILITY"
-    },
-    {
-      "key": "USABILITY_EASE_OF_USE",
-      "name": "Ease of Use",
-      "parent": "USABILITY"
-    },
-    {
-      "key": "USABILITY_COMPLIANCE",
-      "name": "Usability Compliance",
-      "parent": "USABILITY"
-    },
-    {
-      "key": "EFFICIENCY",
-      "name": "Efficiency"
-    },
-    {
-      "key": "EFFICIENCY_COMPLIANCE",
-      "name": "Efficiency Compliance",
-      "parent": "EFFICIENCY"
-    },
-    {
-      "key": "MEMORY_EFFICIENCY",
-      "name": "Memory use",
-      "parent": "EFFICIENCY"
-    },
-    {
-      "key": "NETWORK_USE",
-      "name": "Network use",
-      "parent": "EFFICIENCY"
-    },
-    {
-      "key": "CPU_EFFICIENCY",
-      "name": "Processor use",
-      "parent": "EFFICIENCY"
-    },
-    {
-      "key": "CHANGEABILITY",
-      "name": "Changeability"
-    },
-    {
-      "key": "ARCHITECTURE_CHANGEABILITY",
-      "name": "Architecture",
-      "parent": "CHANGEABILITY"
-    },
-    {
-      "key": "CHANGEABILITY_COMPLIANCE",
-      "name": "Changeability Compliance",
-      "parent": "CHANGEABILITY"
-    },
-    {
-      "key": "DATA_CHANGEABILITY",
-      "name": "Data",
-      "parent": "CHANGEABILITY"
-    },
-    {
-      "key": "LOGIC_CHANGEABILITY",
-      "name": "Logic",
-      "parent": "CHANGEABILITY"
-    },
-    {
-      "key": "RELIABILITY",
-      "name": "Reliability"
-    },
-    {
-      "key": "ARCHITECTURE_RELIABILITY",
-      "name": "Architecture",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "DATA_RELIABILITY",
-      "name": "Data",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "EXCEPTION_HANDLING",
-      "name": "Exception handling",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "FAULT_TOLERANCE",
-      "name": "Fault tolerance",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "INSTRUCTION_RELIABILITY",
-      "name": "Instruction",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "LOGIC_RELIABILITY",
-      "name": "Logic",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "RELIABILITY_COMPLIANCE",
-      "name": "Reliability Compliance",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "RESOURCE_RELIABILITY",
-      "name": "Resource",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "SYNCHRONIZATION_RELIABILITY",
-      "name": "Synchronization",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "UNIT_TESTS",
-      "name": "Unit tests coverage",
-      "parent": "RELIABILITY"
-    },
-    {
-      "key": "TESTABILITY",
-      "name": "Testability"
-    },
-    {
-      "key": "INTEGRATION_TESTABILITY",
-      "name": "Integration level",
-      "parent": "TESTABILITY"
-    },
-    {
-      "key": "TESTABILITY_COMPLIANCE",
-      "name": "Testability Compliance",
-      "parent": "TESTABILITY"
-    },
-    {
-      "key": "UNIT_TESTABILITY",
-      "name": "Unit level",
-      "parent": "TESTABILITY"
     }
   ]
 }
index a87f9c8ef52cf8af0662a8cc4d8fc47a01a2670f..05ce1723d4bf5606eae427aab7d050f050894980 100644 (file)
@@ -45,7 +45,6 @@ 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.QProfileTesting;
 import org.sonar.server.qualityprofile.RuleActivation;
 import org.sonar.server.qualityprofile.RuleActivator;
 import org.sonar.server.qualityprofile.RuleActivatorContextFactory;
@@ -60,6 +59,7 @@ import org.sonar.test.JsonAssert;
 import org.sonarqube.ws.QualityProfiles.InheritanceWsResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.server.qualityprofile.QProfileTesting.newQProfileDto;
 import static org.sonarqube.ws.MediaTypes.PROTOBUF;
 
 public class InheritanceActionTest {
@@ -113,17 +113,18 @@ public class InheritanceActionTest {
     RuleDefinitionDto rule3 = createRule("xoo", "rule3");
 
     /*
-     * groupWide (2) <- companyWide (2) <- buWide (2, 1 overriding) <- (forProject1 (2), forProject2 (2))
+     * sonar way (2) <- companyWide (2) <- buWide (2, 1 overriding) <- (forProject1 (2), forProject2 (2))
      */
-    RulesProfileDto groupWide = createProfile("xoo", "My Group Profile", "xoo-my-group-profile-01234");
-    createActiveRule(rule1, groupWide);
-    createActiveRule(rule2, groupWide);
+    RulesProfileDto sonarway = dbTester.qualityProfiles().insertQualityProfile(
+      newQProfileDto(organization, QProfileName.createFor("xoo", "Sonar way"), "xoo-sonar-way").setIsBuiltIn(true));
+    createActiveRule(rule1, sonarway);
+    createActiveRule(rule2, sonarway);
 
     dbSession.commit();
     activeRuleIndexer.index();
 
     RulesProfileDto companyWide = createProfile("xoo", "My Company Profile", "xoo-my-company-profile-12345");
-    setParent(groupWide, companyWide);
+    setParent(sonarway, companyWide);
 
     RulesProfileDto buWide = createProfile("xoo", "My BU Profile", "xoo-my-bu-profile-23456");
     setParent(companyWide, buWide);
@@ -230,7 +231,7 @@ public class InheritanceActionTest {
   }
 
   private RulesProfileDto createProfile(String lang, String name, String key) {
-    RulesProfileDto profile = QProfileTesting.newQProfileDto(organization, new QProfileName(lang, name), key);
+    RulesProfileDto profile = newQProfileDto(organization, new QProfileName(lang, name), key);
     dbClient.qualityProfileDao().insert(dbSession, profile);
     dbSession.commit();
     return profile;
index 825c6caec93aa319a1844376c95610da9558fa6e..59fe1de45160d2766a4bf1e184417952def912e6 100644 (file)
@@ -117,13 +117,15 @@ public class AppActionTest {
       "    {" +
       "      \"key\": \"XOO_P1\"," +
       "      \"name\": \"P1\"," +
-      "      \"lang\": \"xoo\"" +
+      "      \"lang\": \"xoo\"," +
+      "      \"isBuiltIn\": true" +
       "    }," +
       "    {" +
       "      \"key\": \"XOO_P2\"," +
       "      \"name\": \"P2\"," +
       "      \"lang\": \"xoo\"," +
-      "      \"parentKey\": \"XOO_P1\"" +
+      "      \"parentKey\": \"XOO_P1\"," +
+      "      \"isBuiltIn\": false" +
       "    }" +
       "  ]" +
       "}");
@@ -217,7 +219,7 @@ public class AppActionTest {
   }
 
   private void insertQualityProfiles(OrganizationDto organization) {
-    RulesProfileDto profile1 = QProfileTesting.newXooP1(organization);
+    RulesProfileDto profile1 = QProfileTesting.newXooP1(organization).setIsBuiltIn(true);
     RulesProfileDto profile2 = QProfileTesting.newXooP2(organization).setParentKee(QProfileTesting.XOO_P1_KEY);
     db.getDbClient().qualityProfileDao().insert(db.getSession(), profile1);
     db.getDbClient().qualityProfileDao().insert(db.getSession(), profile2);
index 9e3707e5d3f84f3045f87cc74b9db647e3520e4b..3e71ac9ebc7259cd67def14d47716fb669f8c20c 100644 (file)
@@ -1,14 +1,40 @@
 {
   "profile": {
-    "key": "xoo-my-bu-profile-23456", "name": "My BU Profile", "parent": "xoo-my-company-profile-12345",
-    "activeRuleCount": 2, "overridingRuleCount": 1
+    "key": "xoo-my-bu-profile-23456",
+    "name": "My BU Profile",
+    "parent": "xoo-my-company-profile-12345",
+    "activeRuleCount": 2,
+    "overridingRuleCount": 1,
+    "isBuiltIn": false
   },
   "ancestors": [
-    {"key": "xoo-my-company-profile-12345", "name": "My Company Profile", "parent": "xoo-my-group-profile-01234", "activeRuleCount": 2},
-    {"key": "xoo-my-group-profile-01234", "name": "My Group Profile", "activeRuleCount": 2}
+    {
+      "key": "xoo-my-company-profile-12345",
+      "name": "My Company Profile",
+      "parent": "xoo-sonar-way",
+      "activeRuleCount": 2,
+      "isBuiltIn": false
+    },
+    {
+      "key": "xoo-sonar-way",
+      "name": "Sonar way",
+      "activeRuleCount": 2,
+      "isBuiltIn": true
+    }
   ],
   "children": [
-    {"key": "xoo-for-project-one-34567", "name": "For Project One", "activeRuleCount": 3},
-    {"key": "xoo-for-project-two-45678", "name": "For Project Two", "activeRuleCount": 2, "overridingRuleCount": 1}
+    {
+      "key": "xoo-for-project-one-34567",
+      "name": "For Project One",
+      "activeRuleCount": 3,
+      "isBuiltIn": false
+    },
+    {
+      "key": "xoo-for-project-two-45678",
+      "name": "For Project Two",
+      "activeRuleCount": 2,
+      "overridingRuleCount": 1,
+      "isBuiltIn": false
+    }
   ]
 }
index 12938d67cb79ddb94c07e229ed1be12ee3e8f9f9..9c5c9acaeb0ecb994b9b39c00a0f7a12364e95ee 100644 (file)
@@ -62,7 +62,6 @@ message CreateWsResponse {
     optional Infos infos = 7;
     optional Warnings warnings = 8;
     optional string organization = 9;
-    optional bool isBuiltIn = 10;
 
     message Infos {
       repeated string infos = 1;
@@ -86,5 +85,6 @@ message InheritanceWsResponse {
     optional string parent = 3;
     optional int64 activeRuleCount = 4;
     optional int64 overridingRuleCount = 5;
+    optional bool isBuiltIn = 6;
   }
 }