]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11154 Remove parameters deprecated before 6.7 and enforce mandatory parameters
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 14 Oct 2019 21:28:14 +0000 (16:28 -0500)
committerSonarTech <sonartech@sonarsource.com>
Wed, 30 Oct 2019 19:21:08 +0000 (20:21 +0100)
40 files changed:
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRulesAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/AddProjectAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/BackupAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRulesAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/RemoveProjectAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SetDefaultAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ShowAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfileReferenceTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsModuleTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java

index 3ab2fee8ad912ef50892dc49ba45219add0184c3..350269d4bac8795b37c66060d2fa6f8b70ae7962 100644 (file)
@@ -74,13 +74,11 @@ public class ActivateRuleAction implements QProfileWsAction {
 
     activate.createParam(PARAM_KEY)
       .setDescription("Quality Profile key. Can be obtained through <code>api/qualityprofiles/search</code>")
-      .setDeprecatedKey("profile_key", "6.5")
       .setRequired(true)
       .setExampleValue(UUID_EXAMPLE_01);
 
     activate.createParam(PARAM_RULE)
       .setDescription("Rule key")
-      .setDeprecatedKey("rule_key", "6.5")
       .setRequired(true)
       .setExampleValue("squid:AvoidCycles");
 
index 4604753938b2a986cb1f13e4fe6863c44907a9fc..fde89a3efc160a2b58605d3414ff99f3321e1f76 100644 (file)
@@ -74,13 +74,11 @@ public class ActivateRulesAction implements QProfileWsAction {
 
     activate.createParam(PARAM_TARGET_KEY)
       .setDescription("Quality Profile key on which the rule activation is done. To retrieve a quality profile key please see <code>api/qualityprofiles/search</code>")
-      .setDeprecatedKey("profile_key", "6.5")
       .setRequired(true)
       .setExampleValue(UUID_EXAMPLE_03);
 
     activate.createParam(PARAM_TARGET_SEVERITY)
       .setDescription("Severity to set on the activated rules")
-      .setDeprecatedKey("activation_severity", "6.5")
       .setPossibleValues(Severity.ALL);
   }
 
index 7bcabfd288757f65c29749f4db6d2630d2610143..1842c793228b90e4569e8d1abb15b99527d386e9 100644 (file)
@@ -33,13 +33,10 @@ import org.sonar.db.qualityprofile.QProfileDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.user.UserSession;
 
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_08;
-import static org.sonar.server.component.ComponentFinder.ParamNames.PROJECT_UUID_AND_KEY;
 import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
 import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ADD_PROJECT;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID;
 
 public class AddProjectAction implements QProfileWsAction {
 
@@ -77,13 +74,8 @@ public class AddProjectAction implements QProfileWsAction {
 
     action.createParam(PARAM_PROJECT)
       .setDescription("Project key")
-      .setDeprecatedKey("projectKey", "6.5")
+      .setRequired(true)
       .setExampleValue(KEY_PROJECT_EXAMPLE_001);
-
-    action.createParam(PARAM_PROJECT_UUID)
-      .setDescription("Project ID. Either this parameter or '%s' must be set.", PARAM_PROJECT)
-      .setDeprecatedSince("6.5")
-      .setExampleValue(UUID_EXAMPLE_08);
   }
 
   @Override
@@ -92,7 +84,7 @@ public class AddProjectAction implements QProfileWsAction {
 
     try (DbSession dbSession = dbClient.openSession(false)) {
       ComponentDto project = loadProject(dbSession, request);
-      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
       OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
       checkPermissions(dbSession, organization, profile, project);
 
@@ -115,9 +107,8 @@ public class AddProjectAction implements QProfileWsAction {
   }
 
   private ComponentDto loadProject(DbSession dbSession, Request request) {
-    String projectKey = request.param(PARAM_PROJECT);
-    String projectUuid = request.param(PARAM_PROJECT_UUID);
-    return componentFinder.getByUuidOrKey(dbSession, projectUuid, projectKey, PROJECT_UUID_AND_KEY);
+    String projectKey = request.mandatoryParam(PARAM_PROJECT);
+    return componentFinder.getByKey(dbSession, projectKey);
   }
 
   private void checkPermissions(DbSession dbSession, OrganizationDto organization, QProfileDto profile, ComponentDto project) {
index 0cd9f483237dc04ce8968fc278a41a216ad8929e..0e885835f29be56dafcb2d836d7199c6063b36a4 100644 (file)
@@ -69,7 +69,7 @@ public class BackupAction implements QProfileWsAction {
     try (OutputStreamWriter writer = new OutputStreamWriter(stream.output(), UTF_8);
       DbSession dbSession = dbClient.openSession(false)) {
 
-      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
       response.setHeader("Content-Disposition", String.format("attachment; filename=%s.xml", profile.getKee()));
       backuper.backup(dbSession, profile, writer);
     }
index c43c283b7d80f8f14086c6d35a5622c2f6a0f4e7..7a9c19744741869ada8c827300b445b615a0ac08 100644 (file)
@@ -33,9 +33,7 @@ import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters;
 
 import static org.apache.commons.lang.StringUtils.isEmpty;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY;
 
 public class ChangeParentAction implements QProfileWsAction {
 
@@ -71,36 +69,29 @@ public class ChangeParentAction implements QProfileWsAction {
       .setSince("6.4");
     QProfileReference.defineParams(inheritance, languages);
 
-    inheritance.createParam(PARAM_PARENT_KEY)
-      .setDescription("New parent profile key.<br> " +
-        "If no profile is provided, the inheritance link with current parent profile (if any) is broken, which deactivates all rules " +
-        "which come from the parent and are not overridden.")
-      .setDeprecatedSince("6.6")
-      .setExampleValue(UUID_EXAMPLE_02);
-
     inheritance.createParam(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE)
-      .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PARENT_KEY, PARAM_LANGUAGE)
+      .setDescription("New parent profile name. <br> " +
+        "If no profile is provided, the inheritance link with current parent profile (if any) is broken, which deactivates all rules " +
+          "which come from the parent and are not overridden.")
       .setExampleValue("Sonar way");
   }
 
   @Override
   public void handle(Request request, Response response) throws Exception {
     userSession.checkLoggedIn();
-    QProfileReference reference = QProfileReference.from(request);
+    QProfileReference reference = QProfileReference.fromName(request);
 
     try (DbSession dbSession = dbClient.openSession(false)) {
       QProfileDto profile = wsSupport.getProfile(dbSession, reference);
       OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
       wsSupport.checkCanEdit(dbSession, organization, profile);
 
-      String parentKey = request.param(PARAM_PARENT_KEY);
       String parentName = request.param(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE);
-      if (isEmpty(parentKey) && isEmpty(parentName)) {
+      if (isEmpty(parentName)) {
         ruleActivator.removeParentAndCommit(dbSession, profile);
       } else {
-        String parentOrganizationKey = parentKey == null ? organization.getKey() : null;
-        String parentLanguage = parentKey == null ? request.param(PARAM_LANGUAGE) : null;
-        QProfileReference parentRef = QProfileReference.from(parentKey, parentOrganizationKey, parentLanguage, parentName);
+        String parentLanguage = request.mandatoryParam(PARAM_LANGUAGE);
+        QProfileReference parentRef = QProfileReference.fromName(organization.getKey(), parentLanguage, parentName);
         QProfileDto parent = wsSupport.getProfile(dbSession, parentRef);
         ruleActivator.setParentAndCommit(dbSession, profile, parent);
       }
index 22150b14b3cb833de886b2328bc76d7f809c8e27..836091ff9a7521ae005af46037eea4e1ba88ec68 100644 (file)
@@ -93,7 +93,7 @@ public class ChangelogAction implements QProfileWsAction {
 
   @Override
   public void handle(Request request, Response response) throws Exception {
-    QProfileReference reference = QProfileReference.from(request);
+    QProfileReference reference = QProfileReference.fromName(request);
     try (DbSession dbSession = dbClient.openSession(false)) {
       QProfileDto profile = wsSupport.getProfile(dbSession, reference);
 
index 0b5ccf1df15e73ea5b1305de8768c246f4928647..b6ebcc3dc55819f8ded0bcb715c342cb4d193644 100644 (file)
@@ -97,8 +97,7 @@ public class CreateAction implements QProfileWsAction {
       .setRequired(true)
       .setMaximumLength(NAME_MAXIMUM_LENGTH)
       .setDescription("Quality profile name")
-      .setExampleValue("My Sonar way")
-      .setDeprecatedKey("profileName", "6.6");
+      .setExampleValue("My Sonar way");
 
     create.createParam(PARAM_LANGUAGE)
       .setRequired(true)
index 2475395eb02ec917730d0f88b0832164ba025806..e7ac7c6b7abfa2eb74603c0b2659b5121d4fa047 100644 (file)
@@ -66,13 +66,11 @@ public class DeactivateRuleAction implements QProfileWsAction {
 
     deactivate.createParam(PARAM_KEY)
       .setDescription("Quality Profile key. Can be obtained through <code>api/qualityprofiles/search</code>")
-      .setDeprecatedKey("profile_key", "6.5")
       .setRequired(true)
       .setExampleValue(UUID_EXAMPLE_01);
 
     deactivate.createParam(PARAM_RULE)
       .setDescription("Rule key")
-      .setDeprecatedKey("rule_key", "6.5")
       .setRequired(true)
       .setExampleValue("squid:AvoidCycles");
   }
index 661debe20fee910f69be063a23b2a416bd1663c1..7422fd85c750531a358af47b258d908670367d32 100644 (file)
@@ -71,7 +71,6 @@ public class DeactivateRulesAction implements QProfileWsAction {
 
     deactivate.createParam(PARAM_TARGET_KEY)
       .setDescription("Quality Profile key on which the rule deactivation is done. To retrieve a profile key please see <code>api/qualityprofiles/search</code>")
-      .setDeprecatedKey("profile_key", "6.5")
       .setRequired(true)
       .setExampleValue(UUID_EXAMPLE_04);
   }
index b957b37c0846d794c1fe93be67f85cc11edbad3e..b48111a1b0a207a60bf3dcedcef3e234e8266700 100644 (file)
@@ -80,7 +80,7 @@ public class DeleteAction implements QProfileWsAction {
     userSession.checkLoggedIn();
 
     try (DbSession dbSession = dbClient.openSession(false)) {
-      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
       OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
       wsSupport.checkCanEdit(dbSession, organization, profile);
 
index 110d2e8484f5c3528d458caea08d4a4f82b04eb9..f9f27c46cb81df063902863a600be9ce14825646 100644 (file)
@@ -47,12 +47,9 @@ import org.sonar.server.qualityprofile.QProfileExporters;
 import org.sonarqube.ws.MediaTypes;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
-import static org.sonar.server.exceptions.BadRequestException.checkRequest;
 import static org.sonar.server.exceptions.NotFoundException.checkFound;
 import static org.sonar.server.qualityprofile.ws.QProfileWsSupport.createOrganizationParam;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
 
@@ -82,19 +79,13 @@ public class ExportAction implements QProfileWsAction {
       .setResponseExample(getClass().getResource("export-example.xml"))
       .setHandler(this);
 
-    action.createParam(PARAM_KEY)
-      .setDescription("Quality profile key")
-      .setSince("6.5")
-      .setDeprecatedSince("6.6")
-      .setExampleValue(UUID_EXAMPLE_01);
-
     action.createParam(PARAM_QUALITY_PROFILE)
       .setDescription("Quality profile name to export. If left empty, the default profile for the language is exported.")
-      .setDeprecatedKey("name", "6.6")
       .setExampleValue("My Sonar way");
 
     action.createParam(PARAM_LANGUAGE)
       .setDescription("Quality profile language")
+      .setRequired(true)
       .setExampleValue(LanguageParamUtils.getExampleValue(languages))
       .setPossibleValues(LanguageParamUtils.getOrderedLanguageKeys(languages));
 
@@ -118,14 +109,12 @@ public class ExportAction implements QProfileWsAction {
 
   @Override
   public void handle(Request request, Response response) throws Exception {
-    String key = request.param(PARAM_KEY);
     String name = request.param(PARAM_QUALITY_PROFILE);
-    String language = request.param(PARAM_LANGUAGE);
-    checkRequest(key != null ^ language != null, "Either '%s' or '%s' must be provided.", PARAM_KEY, PARAM_LANGUAGE);
+    String language = request.mandatoryParam(PARAM_LANGUAGE);
 
     try (DbSession dbSession = dbClient.openSession(false)) {
       OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION));
-      QProfileDto profile = loadProfile(dbSession, organization, key, language, name);
+      QProfileDto profile = loadProfile(dbSession, organization, language, name);
       String exporterKey = exporters.exportersForLanguage(profile.getLanguage()).isEmpty() ? null : request.param(PARAM_EXPORTER_KEY);
       writeResponse(dbSession, profile, exporterKey, response);
     }
@@ -148,14 +137,9 @@ public class ExportAction implements QProfileWsAction {
     IOUtils.write(bufferStream.toByteArray(), output);
   }
 
-  private QProfileDto loadProfile(DbSession dbSession, OrganizationDto organization, @Nullable String key, @Nullable String language, @Nullable String name) {
+  private QProfileDto loadProfile(DbSession dbSession, OrganizationDto organization, String language, @Nullable String name) {
     QProfileDto profile;
-    if (key != null) {
-      profile = dbClient.qualityProfileDao().selectByUuid(dbSession, key);
-      return checkFound(profile, "Could not find profile with key '%s'", key);
-    }
 
-    checkRequest(language != null, "Parameter '%s' must be provided", PARAM_LANGUAGE);
     if (name == null) {
       // return the default profile
       profile = dbClient.qualityProfileDao().selectDefaultProfile(dbSession, organization, language);
index 458c6dd0aed82378a39b1bd1b66a69b1cfd06bb2..f387f3b174ad5b70644ab0318b59b75444d20ac0 100644 (file)
@@ -70,7 +70,7 @@ public class InheritanceAction implements QProfileWsAction {
 
   @Override
   public void handle(Request request, Response response) throws Exception {
-    QProfileReference reference = QProfileReference.from(request);
+    QProfileReference reference = QProfileReference.fromName(request);
     try (DbSession dbSession = dbClient.openSession(false)) {
       QProfileDto profile = wsSupport.getProfile(dbSession, reference);
       OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
index 3ded50637eaa752ee51e9b04a452f69e5acacd70..fe2815c51ea9ccdf02b7f985553897816d878d37 100644 (file)
@@ -80,11 +80,9 @@ public class ProjectsAction implements QProfileWsAction {
       .setExampleValue(UUID_EXAMPLE_01);
     action.addSelectionModeParam();
 
-    action.createSearchQuery("sonar", "projects")
-      .setDeprecatedKey("query", "6.5");
+    action.createSearchQuery("sonar", "projects");
 
-    action.createPageParam()
-      .setDeprecatedKey("page", "6.5");
+    action.createPageParam();
 
     action.createPageSize(100, MAX_PAGE_SIZE);
   }
index 4f14e90963939c72fdbfb0a880c15cf87e3eda42..2db85e0728a163560e1c25c668e1137591d1cea4 100644 (file)
@@ -28,13 +28,9 @@ import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.core.util.stream.MoreCollectors;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
-import static org.apache.commons.lang.StringUtils.isEmpty;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
 
@@ -149,22 +145,10 @@ public class QProfileReference {
     return result;
   }
 
-  public static QProfileReference from(Request request) {
-    String key = request.param(PARAM_KEY);
+  public static QProfileReference fromName(Request request) {
     String organizationKey = request.param(PARAM_ORGANIZATION);
-    String lang = request.param(PARAM_LANGUAGE);
-    String name = request.param(PARAM_QUALITY_PROFILE);
-    return from(key, organizationKey, lang, name);
-  }
-
-  public static QProfileReference from(@Nullable String key, @Nullable String organizationKey, @Nullable String lang, @Nullable String name) {
-    if (key != null) {
-      checkArgument(isEmpty(organizationKey) && isEmpty(lang) && isEmpty(name),
-        "When a quality profile key is set, '%s' '%s' and '%s' can't be set", PARAM_ORGANIZATION, PARAM_LANGUAGE, PARAM_QUALITY_PROFILE);
-      return fromKey(key);
-    }
-    checkArgument(!isEmpty(lang) && !isEmpty(name),
-      "If '%s' is not specified, '%s' and '%s' must be set", PARAM_KEY, PARAM_QUALITY_PROFILE, PARAM_LANGUAGE);
+    String lang = request.mandatoryParam(PARAM_LANGUAGE);
+    String name = request.mandatoryParam(PARAM_QUALITY_PROFILE);
     return fromName(organizationKey, lang, name);
   }
 
@@ -177,19 +161,14 @@ public class QProfileReference {
   }
 
   public static void defineParams(WebService.NewAction action, Languages languages) {
-    action.createParam(PARAM_KEY)
-      .setDescription("Quality profile key. Mandatory unless 'qualityProfile' and 'language' are specified.")
-      .setDeprecatedKey("profileKey", "6.5")
-      .setDeprecatedSince("6.6")
-      .setExampleValue(UUID_EXAMPLE_01);
-
     action.createParam(PARAM_QUALITY_PROFILE)
-      .setDescription("Quality profile name. Mandatory if 'key' is not set.")
-      .setDeprecatedKey("profileName", "6.6")
+      .setDescription("Quality profile name.")
+      .setRequired(true)
       .setExampleValue("Sonar way");
 
     action.createParam(PARAM_LANGUAGE)
-      .setDescription("Quality profile language. Mandatory if 'key' is not set.")
+      .setDescription("Quality profile language.")
+      .setRequired(true)
       .setPossibleValues(Arrays.stream(languages.all()).map(Language::getKey).collect(MoreCollectors.toSet()));
   }
 }
index 7aa34505534d9192dd6e93344bf941f4e9321d76..91429597bb32f77d9a18ed24fe4c3fcd031754de 100644 (file)
@@ -40,10 +40,10 @@ import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
 import static org.sonar.db.organization.OrganizationDto.Subscription.PAID;
-import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
+import static org.sonar.server.exceptions.BadRequestException.checkRequest;
 import static org.sonar.server.exceptions.NotFoundException.checkFound;
 import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional;
-import static org.sonar.server.exceptions.BadRequestException.checkRequest;
+import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
 
 @ServerSide
index 5fd81105995fff41456f31839d8cbb8bb46bd463..90de7e90ccbdb6e4aceacc6dc59f60fcd2d75eaf 100644 (file)
@@ -33,12 +33,10 @@ import org.sonar.db.qualityprofile.QProfileDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.user.UserSession;
 
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_09;
 import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
 import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_PROJECT;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID;
 
 public class RemoveProjectAction implements QProfileWsAction {
 
@@ -74,13 +72,8 @@ public class RemoveProjectAction implements QProfileWsAction {
 
     action.createParam(PARAM_PROJECT)
       .setDescription("Project key")
-      .setDeprecatedKey("projectKey", "6.5")
+      .setRequired(true)
       .setExampleValue(KEY_PROJECT_EXAMPLE_001);
-    
-    action.createParam(PARAM_PROJECT_UUID)
-      .setDescription("Project ID. Either this parameter, or '%s' must be set.", PARAM_PROJECT)
-      .setDeprecatedSince("6.5")
-      .setExampleValue(UUID_EXAMPLE_09);
   }
 
   @Override
@@ -89,7 +82,7 @@ public class RemoveProjectAction implements QProfileWsAction {
 
     try (DbSession dbSession = dbClient.openSession(false)) {
       ComponentDto project = loadProject(dbSession, request);
-      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+      QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
       OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
       checkPermissions(dbSession, organization, profile, project);
       if (!profile.getOrganizationUuid().equals(project.getOrganizationUuid())) {
@@ -104,9 +97,8 @@ public class RemoveProjectAction implements QProfileWsAction {
   }
 
   private ComponentDto loadProject(DbSession dbSession, Request request) {
-    String projectKey = request.param(PARAM_PROJECT);
-    String projectUuid = request.param(PARAM_PROJECT_UUID);
-    return componentFinder.getByUuidOrKey(dbSession, projectUuid, projectKey, ComponentFinder.ParamNames.PROJECT_UUID_AND_PROJECT);
+    String projectKey = request.mandatoryParam(PARAM_PROJECT);
+    return componentFinder.getByKey(dbSession, projectKey);
   }
 
   private void checkPermissions(DbSession dbSession, OrganizationDto organization, QProfileDto profile, ComponentDto project) {
index 27e7c9b27f6656dfd7d5557c7d790b1774bb6397..2c2a1be92edcfa6fbe5703130ce66346736d3a2f 100644 (file)
@@ -114,7 +114,6 @@ public class SearchAction implements QProfileWsAction {
 
     action.createParam(PARAM_PROJECT)
       .setDescription("Project key")
-      .setDeprecatedKey("projectKey", "6.5")
       .setExampleValue(KEY_PROJECT_EXAMPLE_001);
 
     action
@@ -124,7 +123,6 @@ public class SearchAction implements QProfileWsAction {
 
     action.createParam(PARAM_QUALITY_PROFILE)
       .setDescription("Quality profile name")
-      .setDeprecatedKey("profileName", "6.6")
       .setExampleValue("SonarQube Way");
   }
 
index 7832cfc51d1109a485c98278422840893acc9cb4..e346590cfc2c28447bd71db7445d53e17b49aa91 100644 (file)
@@ -64,7 +64,7 @@ public class SetDefaultAction implements QProfileWsAction {
   @Override
   public void handle(Request request, Response response) {
     userSession.checkLoggedIn();
-    QProfileReference reference = QProfileReference.from(request);
+    QProfileReference reference = QProfileReference.fromName(request);
     try (DbSession dbSession = dbClient.openSession(false)) {
       QProfileDto qualityProfile = qProfileWsSupport.getProfile(dbSession, reference);
       dbClient.organizationDao().selectByUuid(dbSession, qualityProfile.getOrganizationUuid())
index 5c4822be8f527279c47708cffebafafd2a8f39a8..234d42af69f749fedd1496251763463034728777 100644 (file)
@@ -83,7 +83,6 @@ public class ShowAction implements QProfileWsAction {
     show.createParam(PARAM_KEY)
       .setDescription("Quality profile key")
       .setExampleValue(UUID_EXAMPLE_01)
-      .setDeprecatedKey("profile", "6.6")
       .setRequired(true);
 
     show.createParam(PARAM_COMPARE_TO_SONAR_WAY)
index 5ec1ad9885cfe9f9788e8436c1696f09989ffffb..112046360011c2e11c9e83428c0ee569e9cf9fb8 100644 (file)
@@ -94,10 +94,6 @@ public class ActivateRuleActionTest {
     assertThat(definition).isNotNull();
     assertThat(definition.isPost()).isTrue();
     assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("severity", "key", "reset", "rule", "params");
-    WebService.Param profileKey = definition.param("key");
-    assertThat(profileKey.deprecatedKey()).isEqualTo("profile_key");
-    WebService.Param ruleKey = definition.param("rule");
-    assertThat(ruleKey.deprecatedKey()).isEqualTo("rule_key");
   }
 
   @Test
index 38e1f83d45626d77e0227b8a723a02514147573c..f9f30644f472ee2f01076a83511a8cefbd3a9db2 100644 (file)
@@ -107,10 +107,6 @@ public class ActivateRulesActionTest {
       "owaspTop10",
       "sansTop25",
       "sonarsourceSecurity");
-    WebService.Param targetProfile = definition.param("targetKey");
-    assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key");
-    WebService.Param targetSeverity = definition.param("targetSeverity");
-    assertThat(targetSeverity.deprecatedKey()).isEqualTo("activation_severity");
   }
 
   @Test
index 0b68c7fd08f6f5ab51c461ec336dc72e54f4b95b..ad2bbcc9ea6be291b6612c3e7941299b2d911f8a 100644 (file)
@@ -73,17 +73,12 @@ public class AddProjectActionTest {
 
     // parameters
     assertThat(definition.params()).extracting(WebService.Param::key)
-      .containsExactlyInAnyOrder("key", "qualityProfile", "project", "language", "projectUuid", "organization");
-    WebService.Param profile = definition.param("key");
-    assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
-    assertThat(profile.deprecatedSince()).isEqualTo("6.6");
+      .containsExactlyInAnyOrder("qualityProfile", "project", "language", "organization");
+    WebService.Param project = definition.param("project");
+    assertThat(project.isRequired()).isTrue();
     WebService.Param languageParam = definition.param("language");
     assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2);
     assertThat(languageParam.exampleValue()).isNull();
-    WebService.Param project = definition.param("project");
-    assertThat(project.deprecatedKey()).isEqualTo("projectKey");
-    WebService.Param projectUuid = definition.param("projectUuid");
-    assertThat(projectUuid.deprecatedSince()).isEqualTo("6.5");
     WebService.Param organizationParam = definition.param("organization");
     assertThat(organizationParam.since()).isEqualTo("6.4");
     assertThat(organizationParam.isInternal()).isTrue();
@@ -93,7 +88,7 @@ public class AddProjectActionTest {
   public void add_project_on_profile_of_default_organization() {
     logInAsProfileAdmin(db.getDefaultOrganization());
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
-    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
 
     TestResponse response = call(project, profile);
     assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
@@ -191,7 +186,7 @@ public class AddProjectActionTest {
   @Test
   public void project_administrator_can_change_profile() {
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
-    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
     userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
 
     call(project, profile);
@@ -203,7 +198,7 @@ public class AddProjectActionTest {
   public void throw_ForbiddenException_if_not_project_nor_organization_administrator() {
     userSession.logIn(db.users().insertUser());
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
-    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
 
     expectedException.expect(ForbiddenException.class);
     expectedException.expectMessage("Insufficient privileges");
@@ -229,10 +224,10 @@ public class AddProjectActionTest {
     QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Component id 'unknown' not found");
+    expectedException.expectMessage("Component key 'unknown' not found");
 
     tester.newRequest()
-      .setParam("projectUuid", "unknown")
+      .setParam("project", "unknown")
       .setParam("profileKey", profile.getKee())
       .execute();
   }
@@ -243,16 +238,17 @@ public class AddProjectActionTest {
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
 
     expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Quality Profile with key 'unknown' does not exist");
+    expectedException.expectMessage("Quality Profile for language 'xoo' and name 'unknown' does not exist");
 
     tester.newRequest()
-      .setParam("projectUuid", project.uuid())
-      .setParam("profileKey", "unknown")
+      .setParam("project", project.getKey())
+      .setParam("language", "xoo")
+      .setParam("qualityProfile", "unknown")
       .execute();
   }
 
   @Test
-  public void fail_when_using_branch_db_key() throws Exception {
+  public void fail_when_using_branch_db_key() {
     OrganizationDto organization = db.organizations().insert();
     ComponentDto project = db.components().insertMainBranch(organization);
     userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
@@ -268,23 +264,6 @@ public class AddProjectActionTest {
       .execute();
   }
 
-  @Test
-  public void fail_when_using_branch_uuid() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertMainBranch(organization);
-    userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
-    ComponentDto branch = db.components().insertProjectBranch(project);
-    QProfileDto profile = db.qualityProfiles().insert(organization);
-
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage(format("Component id '%s' not found", branch.uuid()));
-
-    tester.newRequest()
-      .setParam("projectUuid", branch.uuid())
-      .setParam("profileKey", profile.getKee())
-      .execute();
-  }
-
   private void assertProjectIsAssociatedToProfile(ComponentDto project, QProfileDto profile) {
     QProfileDto loaded = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(db.getSession(), project, profile.getLanguage());
     assertThat(loaded.getKee()).isEqualTo(profile.getKee());
@@ -301,15 +280,16 @@ public class AddProjectActionTest {
 
   private TestResponse call(ComponentDto project, QProfileDto qualityProfile) {
     TestRequest request = tester.newRequest()
-      .setParam("projectUuid", project.uuid())
-      .setParam("key", qualityProfile.getKee());
+      .setParam("project", project.getKey())
+      .setParam("language", qualityProfile.getLanguage())
+      .setParam("qualityProfile", qualityProfile.getName());
     return request.execute();
   }
 
   private TestResponse call(OrganizationDto organization, ComponentDto project, QProfileDto qualityProfile) {
     TestRequest request = tester.newRequest()
       .setParam("organization", organization.getKey())
-      .setParam("projectUuid", project.uuid())
+      .setParam("project", project.getKey())
       .setParam("language", qualityProfile.getLanguage())
       .setParam("qualityProfile", qualityProfile.getName());
     return request.execute();
index 1d9cd581d36a85b36c6976e2555d46f41dbec1ff..66b83cf7e6272e3b7bb257b311e4e03e26a5550e 100644 (file)
@@ -66,9 +66,12 @@ public class BackupActionTest {
 
   @Test
   public void returns_backup_of_profile_with_specified_key() {
-    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
 
-    TestResponse response = tester.newRequest().setParam(PARAM_KEY, profile.getKee()).execute();
+    TestResponse response = tester.newRequest()
+      .setParam("language", profile.getLanguage())
+      .setParam("qualityProfile", profile.getName())
+      .execute();
     assertThat(response.getMediaType()).isEqualTo("application/xml");
     assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile));
     assertThat(response.getHeader("Content-Disposition")).isEqualTo("attachment; filename=" + profile.getKee() + ".xml");
@@ -128,14 +131,6 @@ public class BackupActionTest {
     assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile));
   }
 
-  @Test
-  public void throws_NotFoundException_if_profile_with_specified_key_does_not_exist() {
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Quality Profile with key 'missing' does not exist");
-
-    tester.newRequest().setParam(PARAM_KEY, "missing").execute();
-  }
-
   @Test
   public void throws_NotFoundException_if_specified_organization_does_not_exist() {
     expectedException.expect(NotFoundException.class);
@@ -188,20 +183,6 @@ public class BackupActionTest {
       .execute();
   }
 
-  @Test
-  public void fail_on_paid_organization_when_not_member_using_deprecated_profile_key() {
-    OrganizationDto organization = db.organizations().insert(o -> o.setSubscription(PAID));
-    QProfileDto profile = db.qualityProfiles().insert(organization, p -> p.setLanguage(A_LANGUAGE));
-    userSession.logIn();
-
-    expectedException.expect(ForbiddenException.class);
-    expectedException.expectMessage(format("You're not member of organization '%s'", organization.getKey()));
-
-    tester.newRequest()
-      .setParam("key", profile.getKee())
-      .execute();
-  }
-
   @Test
   public void test_definition() {
     WebService.Action definition = tester.getDef();
@@ -212,13 +193,9 @@ public class BackupActionTest {
     assertThat(definition.isPost()).isFalse();
 
     // parameters
-    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "organization", "qualityProfile", "language");
-    Param key = definition.param("key");
-    assertThat(key.deprecatedKey()).isEqualTo("profileKey");
-    assertThat(key.deprecatedSince()).isEqualTo("6.6");
+    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("organization", "qualityProfile", "language");
     Param language = definition.param("language");
     assertThat(language.deprecatedSince()).isNullOrEmpty();
-    Param profileName = definition.param("qualityProfile");
     Param orgParam = definition.param("organization");
     assertThat(orgParam.since()).isEqualTo("6.4");
   }
index 8e2516b6cdc04ae264b3706a48783b1bae92721f..dd7ca435cb541600e212c5af45c79d9b0af8eb8b 100644 (file)
@@ -71,7 +71,6 @@ import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
 
@@ -128,13 +127,8 @@ public class ChangeParentActionTest {
     WebService.Action definition = ws.getDef();
     assertThat(definition.isPost()).isTrue();
     assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder(
-      "organization", "key", "qualityProfile", "language", "parentKey", "parentQualityProfile");
+      "organization", "qualityProfile", "language", "parentQualityProfile");
     assertThat(definition.param("organization").since()).isEqualTo("6.4");
-    Param profile = definition.param("key");
-    assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
-    assertThat(profile.deprecatedSince()).isEqualTo("6.6");
-    Param parentProfile = definition.param("parentKey");
-    assertThat(parentProfile.deprecatedKey()).isNullOrEmpty();
   }
 
   @Test
@@ -152,8 +146,10 @@ public class ChangeParentActionTest {
     // Set parent
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
-      .setParam(PARAM_PARENT_KEY, parent1.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName())
+      .setParam(PARAM_PARENT_QUALITY_PROFILE, parent1.getName())
       .execute();
 
     // Check rule 1 enabled
@@ -183,8 +179,10 @@ public class ChangeParentActionTest {
     // Set parent 2 through WS
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
-      .setParam(PARAM_PARENT_KEY, parent2.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName())
+      .setParam(PARAM_PARENT_QUALITY_PROFILE, parent2.getName())
       .execute();
 
     // Check rule 2 enabled
@@ -211,7 +209,9 @@ public class ChangeParentActionTest {
     // Remove parent through WS
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName())
       .execute();
 
     // Check no rule enabled
@@ -300,8 +300,10 @@ public class ChangeParentActionTest {
     // Remove parent
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
-      .setParam(PARAM_PARENT_KEY, "")
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName())
+      .setParam(PARAM_PARENT_QUALITY_PROFILE, "")
       .execute();
 
     // Check no rule enabled
@@ -329,8 +331,10 @@ public class ChangeParentActionTest {
 
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
-      .setParam(PARAM_PARENT_KEY, parent2.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName())
+      .setParam(PARAM_PARENT_QUALITY_PROFILE, parent2.getName())
       .execute();
 
     List<OrgActiveRuleDto> activeRules2 = dbClient.activeRuleDao().selectByProfile(dbSession, child);
@@ -351,49 +355,16 @@ public class ChangeParentActionTest {
 
     TestRequest request = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
-      .setParam(PARAM_PARENT_KEY, "palap");
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName())
+      .setParam(PARAM_PARENT_QUALITY_PROFILE, "palap");
 
     expectedException.expect(BadRequestException.class);
 
     request.execute();
   }
 
-  @Test
-  public void fail_if_parent_key_and_name_both_set() {
-    QProfileDto child = createProfile();
-
-    assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, child.getKee())).isEmpty();
-    assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfile(child), new SearchOptions()).getIds()).isEmpty();
-
-    TestRequest request = ws.newRequest()
-      .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
-      .setParam(PARAM_PARENT_QUALITY_PROFILE, "polop")
-      .setParam(PARAM_PARENT_KEY, "palap");
-    expectedException.expect(IllegalArgumentException.class);
-    request
-      .execute();
-  }
-
-  @Test
-  public void fail_if_profile_key_and_name_both_set() {
-    QProfileDto child = createProfile();
-
-    assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, child.getKee())).isEmpty();
-    assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfile(child), new SearchOptions()).getIds()).isEmpty();
-
-    TestRequest request = ws.newRequest()
-      .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee())
-      .setParam(PARAM_QUALITY_PROFILE, child.getName())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
-      .setParam(PARAM_PARENT_KEY, "palap");
-
-    expectedException.expect(IllegalArgumentException.class);
-    request.execute();
-  }
-
   @Test
   public void fail_if_missing_permission() {
     userSession.logIn(db.users().insertUser());
@@ -402,7 +373,9 @@ public class ChangeParentActionTest {
 
     TestRequest request = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee());
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName());
 
     expectedException.expect(ForbiddenException.class);
     expectedException.expectMessage("Insufficient privileges");
@@ -418,7 +391,9 @@ public class ChangeParentActionTest {
 
     TestRequest request = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, child.getKee());
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName());
 
     expectedException.expect(ForbiddenException.class);
     expectedException.expectMessage("Insufficient privileges");
index 7c8b2b93bcc3db9991df095ad0a33818a8b4117f..074448c81f5d187d5a4f9a386ec48dc99dea1806 100644 (file)
@@ -88,7 +88,9 @@ public class ChangelogActionTest {
       "param_bar", "bar_value"));
 
     String response = ws.newRequest()
-      .setParam(PARAM_KEY, profile.getKee())
+      .setParam(PARAM_LANGUAGE, profile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInput();
 
@@ -126,7 +128,9 @@ public class ChangelogActionTest {
         "severity", "MINOR"));
 
     String response = ws.newRequest()
-      .setParam(PARAM_KEY, profile.getKee())
+      .setParam(PARAM_LANGUAGE, profile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInput();
 
@@ -218,7 +222,9 @@ public class ChangelogActionTest {
     QProfileDto qualityProfile = db.qualityProfiles().insert(organization);
 
     String response = ws.newRequest()
-      .setParam(PARAM_KEY, qualityProfile.getKee())
+      .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInput();
 
@@ -238,7 +244,9 @@ public class ChangelogActionTest {
         "severity", "MINOR"));
 
     assertJson(ws.newRequest()
-      .setParam(PARAM_KEY, qualityProfile.getKee())
+      .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .setParam(PARAM_SINCE, "2011-04-25T01:15:42+0100")
       .execute()
       .getInput()).isSimilarTo("{\n" +
@@ -254,7 +262,9 @@ public class ChangelogActionTest {
         "}");
 
     assertJson(ws.newRequest()
-      .setParam(PARAM_KEY, qualityProfile.getKee())
+      .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .setParam(PARAM_SINCE, "2011-04-25T01:15:43+0100")
       .execute()
       .getInput()).isSimilarTo("{\n" +
@@ -279,7 +289,9 @@ public class ChangelogActionTest {
       ImmutableMap.of("ruleId", valueOf(rule2.getId())));
 
     String response = ws.newRequest()
-      .setParam(PARAM_KEY, profile.getKee())
+      .setParam(PARAM_LANGUAGE, profile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInput();
 
@@ -460,7 +472,9 @@ public class ChangelogActionTest {
 
     String response = ws.newRequest()
       .setMethod("GET")
-      .setParam(PARAM_KEY, profile.getKee())
+      .setParam(PARAM_LANGUAGE, profile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .setParam("ps", "10")
       .execute()
       .getInput();
@@ -475,7 +489,7 @@ public class ChangelogActionTest {
     assertThat(definition.isPost()).isFalse();
     assertThat(definition.responseExampleAsString()).isNotEmpty();
     assertThat(definition.params()).extracting(WebService.Param::key)
-      .containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization", "since", "to", "p", "ps");
+      .containsExactlyInAnyOrder("qualityProfile", "language", "organization", "since", "to", "p", "ps");
     WebService.Param profileName = definition.param("qualityProfile");
     assertThat(profileName.deprecatedSince()).isNullOrEmpty();
     WebService.Param language = definition.param("language");
index 7d1b67d69dcb92f3ce1a4e39cb148684b76654ae..8497ba3e01c38ddebda32489e856f9b9bbcc2899 100644 (file)
@@ -117,9 +117,6 @@ public class CreateActionTest {
     assertThat(definition.isPost()).isTrue();
     assertThat(definition.params()).extracting(Param::key)
       .containsExactlyInAnyOrder("language", "organization", "name", "backup_with_messages", "backup_with_errors", "backup_xoo_lint");
-    Param name = definition.param("name");
-    assertThat(name.deprecatedKey()).isEqualTo("profileName");
-    assertThat(name.deprecatedKeySince()).isEqualTo("6.6");
   }
 
   @Test
index 456a3a2e5cd1fff390ee56abbec383c6478373f4..24c95e78f296311efb5e2a9436af5e3722aa9c4e 100644 (file)
@@ -91,10 +91,6 @@ public class DeactivateRuleActionTest {
     assertThat(definition).isNotNull();
     assertThat(definition.isPost()).isTrue();
     assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("key", "rule");
-    WebService.Param profileKey = definition.param("key");
-    assertThat(profileKey.deprecatedKey()).isEqualTo("profile_key");
-    WebService.Param ruleKey = definition.param("rule");
-    assertThat(ruleKey.deprecatedKey()).isEqualTo("rule_key");
   }
 
   @Test
index 4f0311aff961eea332d3b2b5d039755f1bd8c9ad..892c77f883a2e3bb157d3d0cdd7cd92f0f910bc2 100644 (file)
@@ -105,8 +105,6 @@ public class DeactivateRulesActionTest {
       "owaspTop10",
       "sansTop25",
       "sonarsourceSecurity");
-    WebService.Param targetProfile = definition.param("targetKey");
-    assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key");
   }
 
   @Test
index 2b68cec4651a2e1773c18299d3ac9510511e31fe..ca8fe4c8201ae09167cec0b5b24f0e49f840e422 100644 (file)
@@ -76,26 +76,6 @@ public class DeleteActionTest {
     new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db)));
   private WsActionTester ws = new WsActionTester(underTest);
 
-  @Test
-  public void delete_profile_by_key() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
-    QProfileDto profile1 = createProfile(organization);
-    QProfileDto profile2 = createProfile(organization);
-    db.qualityProfiles().associateWithProject(project, profile1);
-
-    logInAsQProfileAdministrator(organization);
-
-    TestResponse response = ws.newRequest()
-      .setMethod("POST")
-      .setParam(PARAM_KEY, profile1.getKee())
-      .execute();
-    assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
-
-    verifyProfileDoesNotExist(profile1, organization);
-    verifyProfileExists(profile2);
-  }
-
   @Test
   public void delete_profile_by_language_and_name_in_default_organization() {
     OrganizationDto organization = db.getDefaultOrganization();
@@ -161,14 +141,16 @@ public class DeleteActionTest {
   @Test
   public void fail_if_built_in_profile() {
     OrganizationDto organization = db.organizations().insert();
-    QProfileDto profile1 = db.qualityProfiles().insert(organization, p -> p.setIsBuiltIn(true));
+    QProfileDto profile1 = db.qualityProfiles().insert(organization, p -> p.setIsBuiltIn(true).setLanguage(A_LANGUAGE));
     logInAsQProfileAdministrator(organization);
 
     expectedException.expect(BadRequestException.class);
 
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, profile1.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, profile1.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, profile1.getName())
       .execute();
   }
 
@@ -183,7 +165,9 @@ public class DeleteActionTest {
 
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, qprofile.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, qprofile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, qprofile.getName())
       .execute();
   }
 
@@ -204,7 +188,7 @@ public class DeleteActionTest {
     userSession.logIn();
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
+    expectedException.expectMessage("The 'language' parameter is missing");
 
     ws.newRequest()
       .setMethod("POST")
@@ -218,7 +202,7 @@ public class DeleteActionTest {
     logInAsQProfileAdministrator(organization);
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
+    expectedException.expectMessage("The 'language' parameter is missing");
 
     ws.newRequest()
       .setMethod("POST")
@@ -234,7 +218,7 @@ public class DeleteActionTest {
     logInAsQProfileAdministrator(organization);
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
+    expectedException.expectMessage("The 'qualityProfile' parameter is missing");
 
     ws.newRequest()
       .setMethod("POST")
@@ -243,34 +227,17 @@ public class DeleteActionTest {
       .execute();
   }
 
-  @Test
-  public void fail_if_too_many_parameters_to_reference_profile() {
-    OrganizationDto organization = db.organizations().insert();
-    QProfileDto profile = createProfile(organization);
-    logInAsQProfileAdministrator(organization);
-
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("When a quality profile key is set, 'organization' 'language' and 'qualityProfile' can't be set");
-
-    ws.newRequest()
-      .setMethod("POST")
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
-      .setParam(PARAM_LANGUAGE, profile.getLanguage())
-      .setParam("profileName", profile.getName())
-      .setParam(PARAM_KEY, profile.getKee())
-      .execute();
-  }
-
   @Test
   public void fail_if_profile_does_not_exist() {
     userSession.logIn();
 
     expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Quality Profile with key 'does_not_exist' does not exist");
+    expectedException.expectMessage("Quality Profile for language 'xoo' and name 'does_not_exist' does not exist");
 
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, "does_not_exist")
+      .setParam(PARAM_QUALITY_PROFILE, "does_not_exist")
+      .setParam(PARAM_LANGUAGE, "xoo")
       .execute();
   }
 
@@ -286,7 +253,9 @@ public class DeleteActionTest {
 
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, profile.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, profile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, profile.getName())
       .execute();
   }
 
@@ -304,7 +273,9 @@ public class DeleteActionTest {
 
     ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_KEY, parentProfile.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_LANGUAGE, parentProfile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, parentProfile.getName())
       .execute();
   }
 
@@ -313,14 +284,7 @@ public class DeleteActionTest {
     WebService.Action definition = ws.getDef();
 
     assertThat(definition.isPost()).isTrue();
-    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "organization", "key", "qualityProfile");
-    Param key = definition.param("key");
-    assertThat(key.deprecatedKey()).isEqualTo("profileKey");
-    assertThat(key.deprecatedSince()).isEqualTo("6.6");
-    Param profileName = definition.param("qualityProfile");
-    assertThat(profileName.deprecatedSince()).isNullOrEmpty();
-    Param language = definition.param("language");
-    assertThat(language.deprecatedSince()).isNullOrEmpty();
+    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "organization", "qualityProfile");
   }
 
   private void logInAsQProfileAdministrator(OrganizationDto organization) {
index 7b7fdb5db591ed2ba7fc843cba6285a1fc4312ea..9beeeb2e4d3d352e9186136d4efbe3645ad4363c 100644 (file)
@@ -72,20 +72,6 @@ public class ExportActionTest {
   private QProfileBackuper backuper = new TestBackuper();
   private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
 
-  @Test
-  public void export_profile_with_key() {
-    QProfileDto profile = createProfile(db.getDefaultOrganization(), false);
-
-    WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap"));
-    String result = tester.newRequest()
-      .setParam(PARAM_KEY, profile.getKee())
-      .setParam("exporterKey", "polop")
-      .execute()
-      .getInput();
-
-    assertThat(result).isEqualTo("Profile " + profile.getLanguage() + "/" + profile.getName() + " exported by polop");
-  }
-
   @Test
   public void export_profile_in_default_organization() {
     QProfileDto profile = createProfile(db.getDefaultOrganization(), false);
@@ -234,33 +220,6 @@ public class ExportActionTest {
       .execute();
   }
 
-  @Test
-  public void fail_if_profile_key_is_unknown() {
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Could not find profile with key 'PROFILE-KEY-404'");
-
-    WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap"));
-    ws.newRequest()
-      .setParam(PARAM_KEY, "PROFILE-KEY-404")
-      .setParam("exporterKey", "polop").execute()
-      .getInput();
-  }
-
-  @Test
-  public void fail_if_profile_key_and_language_provided() {
-    QProfileDto profile = createProfile(db.getDefaultOrganization(), false);
-
-    expectedException.expect(BadRequestException.class);
-    expectedException.expectMessage("Either 'key' or 'language' must be provided");
-
-    WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap"));
-    ws.newRequest()
-      .setParam(PARAM_KEY, profile.getKee())
-      .setParam(PARAM_LANGUAGE, profile.getLanguage())
-      .setParam("exporterKey", "polop").execute()
-      .getInput();
-  }
-
   @Test
   public void fail_on_paid_organization_when_not_member() {
     WsActionTester tester = newWsActionTester(newExporter("foo"));
@@ -284,19 +243,14 @@ public class ExportActionTest {
 
     assertThat(definition.isPost()).isFalse();
     assertThat(definition.isInternal()).isFalse();
-    assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization");
+    assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("language", "qualityProfile", "organization");
 
     WebService.Param organizationParam = definition.param("organization");
     assertThat(organizationParam.since()).isEqualTo("6.4");
     assertThat(organizationParam.isInternal()).isTrue();
 
-    WebService.Param key = definition.param("key");
-    assertThat(key.since()).isEqualTo("6.5");
-    assertThat(key.deprecatedSince()).isEqualTo("6.6");
-
     WebService.Param name = definition.param("qualityProfile");
     assertThat(name.deprecatedSince()).isNullOrEmpty();
-    assertThat(name.deprecatedKey()).isEqualTo("name");
 
     WebService.Param language = definition.param("language");
     assertThat(language.deprecatedSince()).isNullOrEmpty();
@@ -308,7 +262,7 @@ public class ExportActionTest {
 
     assertThat(definition.isPost()).isFalse();
     assertThat(definition.isInternal()).isFalse();
-    assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization", "exporterKey");
+    assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("language", "qualityProfile", "organization", "exporterKey");
     WebService.Param exportersParam = definition.param("exporterKey");
     assertThat(exportersParam.possibleValues()).containsOnly("polop", "palap");
     assertThat(exportersParam.deprecatedKey()).isEqualTo("format");
index 03eefdc608a6b6935af3607cccbdab8107d99366..3e054a4fe68e1f16497a2e2d98fff97c0103e653 100644 (file)
@@ -134,7 +134,9 @@ public class InheritanceActionTest {
     overrideActiveRuleSeverity(rule2, forProject2, Severity.CRITICAL);
 
     String response = ws.newRequest()
-      .setParam(PARAM_KEY, buWide.getKee())
+      .setParam(PARAM_LANGUAGE, buWide.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, buWide.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInput();
 
@@ -162,7 +164,9 @@ public class InheritanceActionTest {
 
     InputStream response = ws.newRequest()
       .setMediaType(PROTOBUF)
-      .setParam(PARAM_KEY, child.getKee())
+      .setParam(PARAM_LANGUAGE, child.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, child.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInputStream();
 
@@ -189,7 +193,9 @@ public class InheritanceActionTest {
 
     InputStream response = ws.newRequest()
       .setMediaType(PROTOBUF)
-      .setParam(PARAM_KEY, profile.getKee())
+      .setParam(PARAM_LANGUAGE, profile.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInputStream();
 
@@ -205,7 +211,9 @@ public class InheritanceActionTest {
     QProfileDto remi = createProfile(organization,"xoo", "Nobodys Boy", "xoo-nobody-s-boy-01234");
 
     String response = ws.newRequest()
-      .setParam(PARAM_KEY, remi.getKee())
+      .setParam(PARAM_LANGUAGE, remi.getLanguage())
+      .setParam(PARAM_QUALITY_PROFILE, remi.getName())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute()
       .getInput();
 
@@ -228,7 +236,10 @@ public class InheritanceActionTest {
 
   @Test(expected = NotFoundException.class)
   public void fail_if_not_found() {
-    ws.newRequest().setParam(PARAM_KEY, "polop").execute();
+    ws.newRequest()
+      .setParam(PARAM_LANGUAGE, "xoo")
+      .setParam(PARAM_QUALITY_PROFILE, "asd")
+      .execute();
   }
 
   @Test
@@ -251,14 +262,7 @@ public class InheritanceActionTest {
     WebService.Action definition = ws.getDef();
 
     assertThat(definition.key()).isEqualTo("inheritance");
-    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization");
-    Param key = definition.param("key");
-    assertThat(key.deprecatedKey()).isEqualTo("profileKey");
-    assertThat(key.deprecatedSince()).isEqualTo("6.6");
-    Param profileName = definition.param("qualityProfile");
-    assertThat(profileName.deprecatedSince()).isNullOrEmpty();
-    Param language = definition.param("language");
-    assertThat(language.deprecatedSince()).isNullOrEmpty();
+    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "qualityProfile", "organization");
   }
 
   private QProfileDto createProfile(OrganizationDto organization, String lang, String name, String key) {
index 1179f9edebe13019cdda80b92b1c8c82a7135866..cd61833bf630dc5c59ebfb0b8728beb0958d1671 100644 (file)
@@ -358,7 +358,6 @@ public class ProjectsActionTest {
     assertThat(definition.param("p")).isNotNull();
     assertThat(definition.param("ps")).isNotNull();
     Param query = definition.param("q");
-    assertThat(query.deprecatedKey()).isEqualTo("query");
   }
 
   private void associateProjectsWithProfile(QProfileDto profile, ComponentDto... projects) {
index 1fdb8c069ae8baa18a18e772fee9e058f8d972f3..bc64e99f0d20c56b0508802e5cf43616044570eb 100644 (file)
@@ -98,56 +98,36 @@ public class QProfileReferenceTest {
   }
 
   @Test
-  public void from_reads_request_parameters_and_creates_reference_by_key() {
-    SimpleGetRequest req = new SimpleGetRequest();
-    req.setParam("key", "foo");
-
-    QProfileReference ref = QProfileReference.from(req);
-    assertThat(ref.getKey()).isEqualTo("foo");
-  }
-
-  @Test
-  public void from_reads_request_parameters_and_creates_reference_by_name_on_default_organization() {
+  public void fromName_reads_request_parameters_and_creates_reference_by_name_on_default_organization() {
     SimpleGetRequest req = new SimpleGetRequest();
     req.setParam("language", "js");
     req.setParam("qualityProfile", "Sonar way");
 
-    QProfileReference ref = QProfileReference.from(req);
+    QProfileReference ref = QProfileReference.fromName(req);
     assertThat(ref.getOrganizationKey()).isEmpty();
     assertThat(ref.getLanguage()).isEqualTo("js");
     assertThat(ref.getName()).isEqualTo("Sonar way");
   }
 
   @Test
-  public void from_reads_request_parameters_and_creates_reference_by_name_on_specified_organization() {
+  public void fromName_reads_request_parameters_and_creates_reference_by_name_on_specified_organization() {
     SimpleGetRequest req = new SimpleGetRequest();
     req.setParam("organization", "my-org");
     req.setParam("language", "js");
     req.setParam("qualityProfile", "Sonar way");
 
-    QProfileReference ref = QProfileReference.from(req);
+    QProfileReference ref = QProfileReference.fromName(req);
     assertThat(ref.getOrganizationKey()).hasValue("my-org");
     assertThat(ref.getLanguage()).isEqualTo("js");
     assertThat(ref.getName()).isEqualTo("Sonar way");
   }
 
-  @Test
-  public void from_reads_request_parameters_and_throws_IAE_if_language_is_missing() {
-    SimpleGetRequest req = new SimpleGetRequest();
-    req.setParam("profileName", "the name");
-
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
-
-    QProfileReference.from(req);
-  }
-
   @Test
   public void throw_IAE_if_request_does_not_define_ref() {
     SimpleGetRequest req = new SimpleGetRequest();
 
     expectedException.expect(IllegalArgumentException.class);
-    QProfileReference.from(req);
+    QProfileReference.fromName(req);
   }
 
   @Test
@@ -164,7 +144,6 @@ public class QProfileReferenceTest {
     WebService.Action action = context.controller("api/qualityprofiles").action("do");
     assertThat(action.param("language")).isNotNull();
     assertThat(action.param("language").possibleValues()).containsOnly("java", "js");
-    assertThat(action.param("key")).isNotNull();
     assertThat(action.param("qualityProfile")).isNotNull();
   }
 
index 4f924f19ac2c2d4ed4edf19e09c81cfb0f501396..16bc67f44cafbdf9acf8a7c4789496967d3f4145 100644 (file)
@@ -29,6 +29,6 @@ public class QProfilesWsModuleTest {
   public void verify_count_of_added_components() {
     ComponentContainer container = new ComponentContainer();
     new QProfilesWsModule().configure(container);
-    assertThat(container.size()).isEqualTo(32 + 2);
+    assertThat(container.size()).isEqualTo(31 + 2);
   }
 }
index 9a397d0b482a01400435f173b261afda41e1e797..002c724d68e69becc2bf4bb48192f40aa2d6ec7a 100644 (file)
@@ -65,7 +65,7 @@ public class RemoveProjectActionTest {
   private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
 
   private RemoveProjectAction underTest = new RemoveProjectAction(dbClient, userSession, languages,
-      new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)), wsSupport);
+    new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)), wsSupport);
   private WsActionTester ws = new WsActionTester(underTest);
 
   @Test
@@ -76,7 +76,7 @@ public class RemoveProjectActionTest {
     assertThat(definition.isPost()).isTrue();
     assertThat(definition.key()).isEqualTo("remove_project");
 
-    assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("key", "qualityProfile", "project", "language", "projectUuid", "organization");
+    assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("qualityProfile", "project", "language", "organization");
     WebService.Param languageParam = definition.param("language");
     assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2);
     assertThat(languageParam.exampleValue()).isNull();
@@ -84,14 +84,8 @@ public class RemoveProjectActionTest {
     WebService.Param organizationParam = definition.param("organization");
     assertThat(organizationParam.since()).isEqualTo("6.4");
     assertThat(organizationParam.isInternal()).isTrue();
-    WebService.Param profile = definition.param("key");
-    assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
     WebService.Param profileName = definition.param("qualityProfile");
     assertThat(profileName.deprecatedSince()).isNullOrEmpty();
-    WebService.Param project = definition.param("project");
-    assertThat(project.deprecatedKey()).isEqualTo("projectKey");
-    WebService.Param projectUuid = definition.param("projectUuid");
-    assertThat(projectUuid.deprecatedSince()).isEqualTo("6.5");
   }
 
   @Test
@@ -116,9 +110,9 @@ public class RemoveProjectActionTest {
     logInAsProfileAdmin();
 
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
-    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
 
-    TestResponse response = call(project, profile);
+    TestResponse response = call(db.getDefaultOrganization(), project, profile);
     assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
 
     assertProjectIsNotAssociatedToProfile(project, profile);
@@ -127,11 +121,11 @@ public class RemoveProjectActionTest {
   @Test
   public void project_administrator_can_remove_profile() {
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
-    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
     db.qualityProfiles().associateWithProject(project, profile);
     userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
 
-    call(project, profile);
+    call(db.getDefaultOrganization(), project, profile);
 
     assertProjectIsNotAssociatedToProfile(project, profile);
   }
@@ -146,7 +140,7 @@ public class RemoveProjectActionTest {
     db.qualityProfiles().addUserPermission(profile, user);
     userSession.logIn(user);
 
-    call(project, profile);
+    call(organization, project, profile);
 
     assertProjectIsNotAssociatedToProfile(project, profile);
   }
@@ -155,7 +149,7 @@ public class RemoveProjectActionTest {
   public void fail_if_not_enough_permissions() {
     userSession.logIn(db.users().insertUser());
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
-    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+    QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
 
     expectedException.expect(ForbiddenException.class);
     expectedException.expectMessage("Insufficient privileges");
@@ -181,10 +175,10 @@ public class RemoveProjectActionTest {
     QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Component id 'unknown' not found");
+    expectedException.expectMessage("Component key 'unknown' not found");
 
     ws.newRequest()
-      .setParam("projectUuid", "unknown")
+      .setParam("project", "unknown")
       .setParam("profileKey", profile.getKee())
       .execute();
   }
@@ -195,11 +189,12 @@ public class RemoveProjectActionTest {
     ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
 
     expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Quality Profile with key 'unknown' does not exist");
+    expectedException.expectMessage("Quality Profile for language 'xoo' and name 'unknown' does not exist");
 
     ws.newRequest()
-      .setParam("projectUuid", project.uuid())
-      .setParam("profileKey", "unknown")
+      .setParam("project", project.getDbKey())
+      .setParam("language", "xoo")
+      .setParam("qualityProfile", "unknown")
       .execute();
   }
 
@@ -216,24 +211,8 @@ public class RemoveProjectActionTest {
 
     ws.newRequest()
       .setParam("project", branch.getDbKey())
-      .setParam("profileKey", profile.getKee())
-      .execute();
-  }
-
-  @Test
-  public void fail_when_using_branch_uuid() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertMainBranch(organization);
-    userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
-    ComponentDto branch = db.components().insertProjectBranch(project);
-    QProfileDto profile = db.qualityProfiles().insert(organization);
-
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage(format("Component id '%s' not found", branch.uuid()));
-
-    ws.newRequest()
-      .setParam("projectUuid", branch.uuid())
-      .setParam("profileKey", profile.getKee())
+      .setParam("language", profile.getLanguage())
+      .setParam("qualityProfile", profile.getName())
       .execute();
   }
 
@@ -253,8 +232,18 @@ public class RemoveProjectActionTest {
 
   private TestResponse call(ComponentDto project, QProfileDto qualityProfile) {
     TestRequest request = ws.newRequest()
-      .setParam("projectUuid", project.uuid())
-      .setParam("profileKey", qualityProfile.getKee());
+      .setParam("project", project.getDbKey())
+      .setParam("language", qualityProfile.getLanguage())
+      .setParam("qualityProfile", qualityProfile.getName());
+    return request.execute();
+  }
+
+  private TestResponse call(OrganizationDto organization, ComponentDto project, QProfileDto qualityProfile) {
+    TestRequest request = ws.newRequest()
+      .setParam("project", project.getDbKey())
+      .setParam("organization", organization.getKey())
+      .setParam("language", qualityProfile.getLanguage())
+      .setParam("qualityProfile", qualityProfile.getName());
     return request.execute();
   }
 }
index 6c2cc25845f99bf00d1ed5cbec6ea9c2ca07d176..48aaffc97a6d8b7ba225ded4878235af094e9871 100644 (file)
@@ -67,7 +67,7 @@ import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
 
 public class SearchActionTest {
@@ -229,7 +229,7 @@ public class SearchActionTest {
     db.qualityProfiles().associateWithProject(project, profileOnXoo1);
     db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
 
-    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, project.getDbKey()));
+    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT, project.getDbKey()));
 
     assertThat(result.getProfilesList())
       .extracting(QualityProfile::getKey)
@@ -247,7 +247,7 @@ public class SearchActionTest {
     db.qualityProfiles().associateWithProject(project, profileOnXoo1);
     db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
 
-    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.getDbKey()));
+    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT, module.getDbKey()));
 
     assertThat(result.getProfilesList())
       .extracting(QualityProfile::getKey)
@@ -265,7 +265,7 @@ public class SearchActionTest {
     db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
 
     SearchWsResponse result = call(ws.newRequest()
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT, project.getDbKey())
       .setParam(PARAM_DEFAULTS, "true"));
 
     assertThat(result.getProfilesList())
@@ -283,7 +283,7 @@ public class SearchActionTest {
     db.qualityProfiles().associateWithProject(project, profileOnXoo1);
 
     SearchWsResponse result = call(ws.newRequest()
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT, project.getDbKey())
       .setParam(PARAM_DEFAULTS, "true"));
 
     assertThat(result.getProfilesList()).isEmpty();
@@ -437,7 +437,7 @@ public class SearchActionTest {
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Component key 'unknown-project' not found");
 
-    call(ws.newRequest().setParam(PARAM_PROJECT_KEY, "unknown-project"));
+    call(ws.newRequest().setParam(PARAM_PROJECT, "unknown-project"));
   }
 
   @Test
@@ -448,7 +448,7 @@ public class SearchActionTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage(format("Project uuid of component uuid '%s' does not exist", module.uuid()));
 
-    call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.getDbKey()));
+    call(ws.newRequest().setParam(PARAM_PROJECT, module.getDbKey()));
   }
 
   @Test
@@ -462,7 +462,7 @@ public class SearchActionTest {
 
     call(ws.newRequest()
       .setParam(PARAM_ORGANIZATION, organization.getKey())
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey()));
+      .setParam(PARAM_PROJECT, project.getDbKey()));
   }
 
   @Test
@@ -562,7 +562,6 @@ public class SearchActionTest {
 
     WebService.Param projectKey = definition.param("project");
     assertThat(projectKey.description()).isEqualTo("Project key");
-    assertThat(projectKey.deprecatedKey()).isEqualTo("projectKey");
 
     WebService.Param language = definition.param("language");
     assertThat(language.possibleValues()).containsExactly("xoo1", "xoo2");
index fc23a0b1ee8e1e63eb7c95223eb344e0a8f62f46..5db7f93f6511b7193a4f4b28e0eb4aee213fd42f 100644 (file)
@@ -45,6 +45,9 @@ import org.sonar.server.ws.WsActionTester;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
 
 public class SetDefaultActionTest {
 
@@ -106,38 +109,8 @@ public class SetDefaultActionTest {
 
     assertThat(definition).isNotNull();
     assertThat(definition.isPost()).isTrue();
-    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization");
+    assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("qualityProfile", "language", "organization");
     assertThat(definition.param("organization").since()).isEqualTo("6.4");
-    Param profile = definition.param("key");
-    assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
-    assertThat(definition.param("qualityProfile").deprecatedSince()).isNullOrEmpty();
-    assertThat(definition.param("language").deprecatedSince()).isNullOrEmpty();
-  }
-
-  @Test
-  public void set_default_profile_using_key() {
-    logInAsQProfileAdministrator();
-
-    checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
-    checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile2.getKee());
-
-    TestResponse response = ws.newRequest()
-      .setMethod("POST")
-      .setParam(PARAM_KEY, xoo2Profile.getKee()).execute();
-
-    assertThat(response.getInput()).isEmpty();
-
-    checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
-    checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile.getKee());
-
-    // One more time!
-    TestResponse response2 = ws.newRequest()
-      .setMethod("POST")
-      .setParam(PARAM_KEY, xoo2Profile.getKee()).execute();
-
-    assertThat(response2.getInput()).isEmpty();
-    checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
-    checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile.getKee());
   }
 
   @Test
@@ -196,21 +169,6 @@ public class SetDefaultActionTest {
     checkDefaultProfile(organization2, XOO_1_KEY, profileOrg2.getKee());
   }
 
-  @Test
-  public void fail_to_set_default_profile_using_invalid_key() {
-    logInAsQProfileAdministrator();
-
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage("Quality Profile with key 'unknown-profile-666' does not exist");
-
-    ws.newRequest().setMethod("POST")
-      .setParam(PARAM_KEY, "unknown-profile-666")
-      .execute();
-
-    checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
-    checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile2.getKee());
-  }
-
   @Test
   public void fail_to_set_default_profile_using_language_and_invalid_name() {
     logInAsQProfileAdministrator();
@@ -228,19 +186,6 @@ public class SetDefaultActionTest {
     }
   }
 
-  @Test
-  public void fail_if_parameter_profile_key_is_combined_with_parameter_organization() {
-    userSessionRule.logIn();
-
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("When a quality profile key is set, 'organization' 'language' and 'qualityProfile' can't be set");
-
-    ws.newRequest().setMethod("POST")
-      .setParam(PARAM_KEY, xoo2Profile.getKee())
-      .setParam("organization", organization.getKey())
-      .execute();
-  }
-
   @Test
   public void throw_ForbiddenException_if_not_profile_administrator() {
     userSessionRule.logIn();
@@ -249,7 +194,9 @@ public class SetDefaultActionTest {
     expectedException.expectMessage("Insufficient privileges");
 
     ws.newRequest().setMethod("POST")
-      .setParam(PARAM_KEY, xoo2Profile.getKee())
+      .setParam(PARAM_ORGANIZATION, organization.getKey())
+      .setParam(PARAM_QUALITY_PROFILE, xoo2Profile.getName())
+      .setParam(PARAM_LANGUAGE, xoo2Profile.getLanguage())
       .execute();
   }
 
index 7bf41b77a93f6a3a0feb28f27adac92ab8dd0b37..5fe74d33d93cf295a3dc275ac11b241c7cd88841 100644 (file)
@@ -57,7 +57,7 @@ public class DefaultQualityProfileLoader implements QualityProfileLoader {
 
   @Override
   public List<QualityProfile> load(String projectKey) {
-    StringBuilder url = new StringBuilder(WS_URL + "?projectKey=").append(encodeForUrl(projectKey));
+    StringBuilder url = new StringBuilder(WS_URL + "?project=").append(encodeForUrl(projectKey));
     return handleErrors(url, () -> String.format("Failed to load the quality profiles of project '%s'", projectKey), true);
   }
 
index edfc14e5bd6378aa3464b707cdec4f6f6e0228ba..f5d3661dff9a8824ba9bd9f2c55af4e48dee9332 100644 (file)
@@ -51,14 +51,14 @@ public class DefaultQualityProfileLoaderTest {
   public void load_gets_all_profiles_for_specified_project() throws IOException {
     prepareCallWithResults();
     underTest.load("foo");
-    verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo");
+    verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo");
   }
 
   @Test
   public void load_encodes_url_parameters() throws IOException {
-    WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo%232", createStreamOfProfiles("qp"));
+    WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?project=foo%232", createStreamOfProfiles("qp"));
     underTest.load("foo#2");
-    verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo%232");
+    verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo%232");
   }
 
   @Test
@@ -66,18 +66,18 @@ public class DefaultQualityProfileLoaderTest {
     when(properties.organizationKey()).thenReturn(Optional.of("my-org"));
     prepareCallWithResults();
     underTest.load("foo");
-    verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo&organization=my-org");
+    verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo&organization=my-org");
   }
 
   @Test
   public void load_tries_default_if_no_profiles_found_for_project() throws IOException {
     HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No project found with key 'foo'\"}]}");
-    WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo", e);
+    WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?project=foo", e);
     WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true", createStreamOfProfiles("qp"));
 
     underTest.load("foo");
 
-    verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo");
+    verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo");
     verifyCalledPath("/api/qualityprofiles/search.protobuf?defaults=true");
   }
 
@@ -86,7 +86,7 @@ public class DefaultQualityProfileLoaderTest {
     when(properties.organizationKey()).thenReturn(Optional.of("my-org"));
 
     HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No organization with key 'myorg'\"}]}");
-    WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo&organization=my-org", e);
+    WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?project=foo&organization=my-org", e);
     WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true&organization=my-org", createStreamOfProfiles("qp"));
 
     underTest.load("foo");
index d5e7d86e0150a6ae88bf9417701828834f504657..691cc75743f487cf528623ca54e815830a5c5e10 100644 (file)
@@ -56,13 +56,10 @@ public class QualityProfileWsParameters {
   public static final String PARAM_LOGIN = "login";
   public static final String PARAM_NAME = "name";
   public static final String PARAM_PARAMS = "params";
-  public static final String PARAM_PARENT_KEY = "parentKey";
   public static final String PARAM_PARENT_QUALITY_PROFILE = "parentQualityProfile";
   public static final String PARAM_KEY = "key";
   public static final String PARAM_QUALITY_PROFILE = "qualityProfile";
   public static final String PARAM_PROJECT = "project";
-  public static final String PARAM_PROJECT_KEY = "projectKey";
-  public static final String PARAM_PROJECT_UUID = "projectUuid";
   public static final String PARAM_QUERY = "q";
   public static final String PARAM_RESET = "reset";
   public static final String PARAM_RULE = "rule";