From 184dbe792ce14f192f75b13507c30a4b697d5852 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Fri, 22 Sep 2017 18:52:19 +0200 Subject: [PATCH] SONAR-9865 Sanitize WS api/qualityprofiles/* - functional key of a quality profile is: name, language and organization - quality profile name is named 'name' - quality profile key is named 'key' - quality profile key parameter is deprecated when appropriate --- .../qualityprofile/ws/ActivateRuleAction.java | 6 +- .../ws/ActivateRulesAction.java | 8 +- .../qualityprofile/ws/ChangeParentAction.java | 20 +++-- .../qualityprofile/ws/CreateAction.java | 14 ++-- .../ws/DeactivateRuleAction.java | 6 +- .../ws/DeactivateRulesAction.java | 6 +- .../qualityprofile/ws/ExportAction.java | 22 +++--- .../qualityprofile/ws/ProjectsAction.java | 9 +-- .../qualityprofile/ws/QProfileReference.java | 20 ++--- .../qualityprofile/ws/RenameAction.java | 14 ++-- .../qualityprofile/ws/SearchAction.java | 15 ++-- .../server/qualityprofile/ws/ShowAction.java | 9 ++- .../ws/ActivateRuleActionTest.java | 16 ++-- .../ws/ActivateRulesActionTest.java | 12 +-- .../ws/AddProjectActionTest.java | 12 ++- .../qualityprofile/ws/BackupActionTest.java | 26 +++---- .../ws/ChangeParentActionTest.java | 73 +++++++++---------- .../ws/ChangelogActionDatabaseTest.java | 26 +++---- .../ws/ChangelogActionMockTest.java | 12 +-- .../qualityprofile/ws/CreateActionTest.java | 8 +- .../ws/DeactivateRuleActionTest.java | 16 ++-- .../ws/DeactivateRulesActionTest.java | 12 +-- .../qualityprofile/ws/DeleteActionTest.java | 17 +++-- .../qualityprofile/ws/ExportActionTest.java | 31 ++++---- .../ws/InheritanceActionTest.java | 25 ++++--- .../qualityprofile/ws/ProjectsActionTest.java | 36 ++++----- .../ws/QProfileReferenceTest.java | 10 +-- .../ws/QProfilesWsMediumTest.java | 32 ++++---- .../qualityprofile/ws/QProfilesWsTest.java | 13 ++-- .../ws/RemoveProjectActionTest.java | 10 +-- .../qualityprofile/ws/RenameActionTest.java | 10 +-- .../qualityprofile/ws/SearchActionTest.java | 10 +-- .../ws/SetDefaultActionTest.java | 28 +++---- .../qualityprofile/ws/ShowActionTest.java | 36 ++++----- .../qualityprofile/ActivateRuleWsRequest.java | 14 ++-- .../qualityprofile/AddProjectRequest.java | 28 +++---- .../qualityprofile/ChangeParentRequest.java | 24 +++--- .../client/qualityprofile/CreateRequest.java | 16 ++-- .../QualityProfileWsParameters.java | 12 +-- .../QualityProfilesService.java | 40 +++++----- .../qualityprofile/RemoveProjectRequest.java | 28 +++---- .../qualityprofile/SearchWsRequest.java | 10 +-- .../qualityprofile/SetDefaultRequest.java | 10 +-- .../ws/client/qualityprofile/ShowRequest.java | 10 +-- .../qualityprofile/AddProjectRequestTest.java | 18 ++--- .../qualityprofile/CreateRequestTest.java | 6 +- .../QualityProfilesServiceTest.java | 36 ++++----- .../RemoveProjectRequestTest.java | 18 ++--- .../org/sonarqube/tests/QProfileTester.java | 6 +- .../QualityProfileAdminPermissionTest.java | 2 +- .../issue/OrganizationIssueAssignTest.java | 2 +- ...uiltInQualityProfilesNotificationTest.java | 2 +- .../CustomQualityProfilesTest.java | 12 +-- .../OrganizationQualityProfilesUiTest.java | 2 +- .../qualityProfile/QualityProfilesUiTest.java | 4 +- .../qualityProfile/QualityProfilesWsTest.java | 12 +-- 56 files changed, 464 insertions(+), 468 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java index efcb4fe8e7b..8d1e5d29794 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java @@ -37,7 +37,7 @@ import static java.lang.String.format; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY; @@ -65,7 +65,7 @@ public class ActivateRuleAction implements QProfileWsAction { .setPost(true) .setSince("4.4"); - activate.createParam(PARAM_PROFILE) + activate.createParam(PARAM_KEY) .setDescription("Quality Profile key. Can be obtained through api/qualityprofiles/search") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) @@ -94,7 +94,7 @@ public class ActivateRuleAction implements QProfileWsAction { public void handle(Request request, Response response) throws Exception { userSession.checkLoggedIn(); try (DbSession dbSession = dbClient.openSession(false)) { - String profileKey = request.mandatoryParam(PARAM_PROFILE); + String profileKey = request.mandatoryParam(PARAM_KEY); QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromKey(profileKey)); wsSupport.checkPermission(dbSession, profile); wsSupport.checkNotBuiltInt(profile); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRulesAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRulesAction.java index fe1b61fc998..cf40a39cf2f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRulesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRulesAction.java @@ -36,7 +36,7 @@ import static org.sonar.server.qualityprofile.ws.BulkChangeWsResponse.writeRespo import static org.sonar.server.qualityprofile.ws.QProfileReference.fromKey; import static org.sonar.server.rule.ws.SearchAction.defineRuleSearchParameters; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULES; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_SEVERITY; public class ActivateRulesAction implements QProfileWsAction { @@ -66,8 +66,8 @@ public class ActivateRulesAction implements QProfileWsAction { defineRuleSearchParameters(activate); - activate.createParam(PARAM_TARGET_PROFILE) - .setDescription("Quality Profile key on which the rule activation is done. To retrieve a profile key please see api/qualityprofiles/search") + activate.createParam(PARAM_TARGET_KEY) + .setDescription("Quality Profile key on which the rule activation is done. To retrieve a quality profile key please see api/qualityprofiles/search") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) .setExampleValue(UUID_EXAMPLE_03); @@ -80,7 +80,7 @@ public class ActivateRulesAction implements QProfileWsAction { @Override public void handle(Request request, Response response) throws Exception { - String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_PROFILE); + String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_KEY); userSession.checkLoggedIn(); BulkChangeResult result; try (DbSession dbSession = dbClient.openSession(false)) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java index 8107ecd1b3f..1e3aad6865b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java @@ -30,18 +30,17 @@ import org.sonar.db.organization.OrganizationDto; import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.server.qualityprofile.RuleActivator; 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.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY; public class ChangeParentAction implements QProfileWsAction { - private static final String PARAM_PARENT_NAME = "parentName"; - - private DbClient dbClient; + private final DbClient dbClient; private final RuleActivator ruleActivator; private final Languages languages; private final QProfileWsSupport wsSupport; @@ -69,16 +68,15 @@ public class ChangeParentAction implements QProfileWsAction { .setSince("6.4"); QProfileReference.defineParams(inheritance, languages); - inheritance.createParam(PARAM_PARENT_PROFILE) + inheritance.createParam(PARAM_PARENT_KEY) .setDescription("New parent profile key.
" + "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.") - .setDeprecatedKey("parentKey", "6.5") + .setDeprecatedSince("6.6") .setExampleValue(UUID_EXAMPLE_02); - inheritance.createParam(PARAM_PARENT_NAME) - .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PARENT_PROFILE, PARAM_LANGUAGE) - .setDeprecatedSince("6.5") + 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) .setExampleValue("Sonar way"); } @@ -95,8 +93,8 @@ public class ChangeParentAction implements QProfileWsAction { userSession.checkPermission(ADMINISTER_QUALITY_PROFILES, organization); wsSupport.checkNotBuiltInt(profile); - String parentKey = request.param(PARAM_PARENT_PROFILE); - String parentName = request.param(PARAM_PARENT_NAME); + String parentKey = request.param(PARAM_PARENT_KEY); + String parentName = request.param(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE); if (isEmpty(parentKey) && isEmpty(parentName)) { ruleActivator.setParentAndCommit(dbSession, profile, null); } else { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java index 26933ceb73d..63061c405e9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java @@ -45,8 +45,8 @@ import static org.sonar.server.qualityprofile.ws.QProfileWsSupport.createOrganiz import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_CREATE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; public class CreateAction implements QProfileWsAction { @@ -91,14 +91,14 @@ public class CreateAction implements QProfileWsAction { createOrganizationParam(create) .setSince("6.4"); - create.createParam(PARAM_PROFILE_NAME) - .setDescription("Name for the new quality profile") + create.createParam(PARAM_NAME) + .setDescription("Quality profile name") .setExampleValue("My Sonar way") - .setDeprecatedKey("name", "6.1") + .setDeprecatedKey("profileName", "6.6") .setRequired(true); create.createParam(PARAM_LANGUAGE) - .setDescription("The language for the quality profile.") + .setDescription("Quality profile language") .setExampleValue("js") .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)) .setRequired(true); @@ -123,7 +123,7 @@ public class CreateAction implements QProfileWsAction { private CreateWsResponse doHandle(DbSession dbSession, CreateRequest createRequest, Request request, OrganizationDto organization) { QProfileResult result = new QProfileResult(); QProfileDto profile = profileFactory.checkAndCreateCustom(dbSession, organization, - QProfileName.createFor(createRequest.getLanguage(), createRequest.getProfileName())); + QProfileName.createFor(createRequest.getLanguage(), createRequest.getName())); result.setProfile(profile); for (ProfileImporter importer : importers) { String importerKey = importer.getKey(); @@ -140,7 +140,7 @@ public class CreateAction implements QProfileWsAction { CreateRequest.Builder builder = CreateRequest.builder() .setOrganizationKey(organization.getKey()) .setLanguage(request.mandatoryParam(PARAM_LANGUAGE)) - .setProfileName(request.mandatoryParam(PARAM_PROFILE_NAME)); + .setName(request.mandatoryParam(PARAM_NAME)); return builder.build(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java index 3bb8ed16dcc..10b2721f42b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java @@ -31,7 +31,7 @@ import org.sonar.server.user.UserSession; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; public class DeactivateRuleAction implements QProfileWsAction { @@ -57,7 +57,7 @@ public class DeactivateRuleAction implements QProfileWsAction { .setPost(true) .setSince("4.4"); - deactivate.createParam(PARAM_PROFILE) + deactivate.createParam(PARAM_KEY) .setDescription("Quality Profile key. Can be obtained through api/qualityprofiles/search") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) @@ -73,7 +73,7 @@ public class DeactivateRuleAction implements QProfileWsAction { @Override public void handle(Request request, Response response) throws Exception { RuleKey ruleKey = RuleKey.parse(request.mandatoryParam(PARAM_RULE)); - String qualityProfileKey = request.mandatoryParam(PARAM_PROFILE); + String qualityProfileKey = request.mandatoryParam(PARAM_KEY); userSession.checkLoggedIn(); try (DbSession dbSession = dbClient.openSession(false)) { QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromKey(qualityProfileKey)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRulesAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRulesAction.java index cff201af44c..6d23a6c91d2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRulesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRulesAction.java @@ -34,7 +34,7 @@ import static org.sonar.core.util.Uuids.UUID_EXAMPLE_04; import static org.sonar.server.qualityprofile.ws.BulkChangeWsResponse.writeResponse; import static org.sonar.server.rule.ws.SearchAction.defineRuleSearchParameters; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULES; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY; public class DeactivateRulesAction implements QProfileWsAction { public static final String SEVERITY = "activation_severity"; @@ -64,7 +64,7 @@ public class DeactivateRulesAction implements QProfileWsAction { defineRuleSearchParameters(deactivate); - deactivate.createParam(PARAM_TARGET_PROFILE) + deactivate.createParam(PARAM_TARGET_KEY) .setDescription("Quality Profile key on which the rule deactivation is done. To retrieve a profile key please see api/qualityprofiles/search") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) @@ -73,7 +73,7 @@ public class DeactivateRulesAction implements QProfileWsAction { @Override public void handle(Request request, Response response) throws Exception { - String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_PROFILE); + String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_KEY); userSession.checkLoggedIn(); BulkChangeResult result; try (DbSession dbSession = dbClient.openSession(false)) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java index 5194c3c9764..50f907490eb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java @@ -50,12 +50,12 @@ import static org.sonar.server.qualityprofile.ws.QProfileWsSupport.createOrganiz import static org.sonar.server.ws.WsUtils.checkFound; import static org.sonar.server.ws.WsUtils.checkRequest; 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_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; public class ExportAction implements QProfileWsAction { - private static final String PARAM_NAME = "name"; private static final String PARAM_EXPORTER_KEY = "exporterKey"; private final DbClient dbClient; @@ -80,20 +80,20 @@ public class ExportAction implements QProfileWsAction { .setResponseExample(getClass().getResource("export-example.xml")) .setHandler(this); - action.createParam(PARAM_PROFILE) + action.createParam(PARAM_KEY) .setDescription("Quality profile key") .setSince("6.5") + .setDeprecatedSince("6.6") .setExampleValue(UUID_EXAMPLE_01); - action.createParam(PARAM_NAME) + action.createParam(PARAM_QUALITY_PROFILE) .setDescription("Quality profile name to export. If left empty, the default profile for the language is exported. If this parameter is set, '%s' must not be set.", - PARAM_PROFILE) - .setDeprecatedSince("6.5") + PARAM_KEY) + .setDeprecatedKey("profileName", "6.6") .setExampleValue("My Sonar way"); action.createParam(PARAM_LANGUAGE) - .setDescription("Quality profile language. If this parameter is set, '%s' must not be set.", PARAM_PROFILE) - .setDeprecatedSince("6.5") + .setDescription("Quality profile language. If this parameter is set, '%s' must not be set.", PARAM_KEY) .setExampleValue(LanguageParamUtils.getExampleValue(languages)) .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)); @@ -117,10 +117,10 @@ public class ExportAction implements QProfileWsAction { @Override public void handle(Request request, Response response) throws Exception { - String key = request.param(PARAM_PROFILE); - String name = request.param(PARAM_NAME); + 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_PROFILE, PARAM_LANGUAGE); + checkRequest(key != null ^ language != null, "Either '%s' or '%s' must be provided.", PARAM_KEY, PARAM_LANGUAGE); try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java index 332b45c6a92..cdb9f246679 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java @@ -45,7 +45,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.util.Comparator.comparing; import static org.sonar.api.utils.Paging.forPageIndex; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class ProjectsAction implements QProfileWsAction { @@ -74,9 +74,8 @@ public class ProjectsAction implements QProfileWsAction { new Change("6.0", "'uuid' response field is deprecated and replaced by 'id'"), new Change("6.0", "'key' response field has been added to return the project key")); - action.createParam(PARAM_PROFILE) - .setDescription("Quality profile key.") - .setDeprecatedKey("key", "6.5") + action.createParam(PARAM_KEY) + .setDescription("Quality profile key") .setRequired(true) .setExampleValue(UUID_EXAMPLE_01); action.addSelectionModeParam(); @@ -92,7 +91,7 @@ public class ProjectsAction implements QProfileWsAction { @Override public void handle(Request request, Response response) throws Exception { - String profileKey = request.mandatoryParam(PARAM_PROFILE); + String profileKey = request.mandatoryParam(PARAM_KEY); try (DbSession session = dbClient.openSession(false)) { checkProfileExists(profileKey, session); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java index 9d6d1f4fcee..ecc4077d74b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java @@ -35,8 +35,8 @@ 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_LANGUAGE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; /** * Reference to a Quality profile as defined by requests to web services api/qualityprofiles. @@ -150,10 +150,10 @@ public class QProfileReference { } public static QProfileReference from(Request request) { - String key = request.param(PARAM_PROFILE); + String key = request.param(PARAM_KEY); String organizationKey = request.param(PARAM_ORGANIZATION); String lang = request.param(PARAM_LANGUAGE); - String name = request.param(PARAM_PROFILE_NAME); + String name = request.param(PARAM_QUALITY_PROFILE); return from(key, organizationKey, lang, name); } @@ -175,19 +175,19 @@ public class QProfileReference { } public static void defineParams(WebService.NewAction action, Languages languages) { - action.createParam(PARAM_PROFILE) + action.createParam(PARAM_KEY) .setDescription("Quality profile key") .setDeprecatedKey("profileKey", "6.5") + .setDeprecatedSince("6.6") .setExampleValue(UUID_EXAMPLE_01); - action.createParam(PARAM_PROFILE_NAME) - .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PROFILE, PARAM_LANGUAGE) - .setDeprecatedSince("6.5") + action.createParam(PARAM_QUALITY_PROFILE) + .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_KEY, PARAM_LANGUAGE) + .setDeprecatedKey("profileName", "6.6") .setExampleValue("Sonar way"); action.createParam(PARAM_LANGUAGE) - .setDescription("Quality profile language. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PROFILE, PARAM_LANGUAGE) - .setDeprecatedSince("6.5") + .setDescription("Quality profile language. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_KEY, PARAM_LANGUAGE) .setPossibleValues(Arrays.stream(languages.all()).map(Language::getKey).collect(MoreCollectors.toSet())); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RenameAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RenameAction.java index 01bb9e6debe..3801232ac50 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RenameAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RenameAction.java @@ -37,7 +37,7 @@ import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class RenameAction implements QProfileWsAction { @@ -62,22 +62,22 @@ public class RenameAction implements QProfileWsAction { .setPost(true) .setHandler(this); + setDefault.createParam(PARAM_KEY) + .setDescription("Quality profile key") + .setExampleValue(UUID_EXAMPLE_01) + .setRequired(true); + setDefault.createParam(PARAM_NAME) .setDescription("New quality profile name") .setExampleValue("My Sonar way") .setRequired(true); - setDefault.createParam(PARAM_PROFILE) - .setDescription("Quality profile key") - .setDeprecatedKey("key", "6.5") - .setExampleValue(UUID_EXAMPLE_01) - .setRequired(true); } @Override public void handle(Request request, Response response) throws Exception { String newName = request.mandatoryParam(PARAM_NAME); - String profileKey = request.mandatoryParam(PARAM_PROFILE); + String profileKey = request.mandatoryParam(PARAM_KEY); doHandle(newName, profileKey); response.noContent(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java index 3f9709faab2..b192a68d883 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java @@ -19,7 +19,6 @@ */ package org.sonar.server.qualityprofile.ws; -import com.google.common.annotations.VisibleForTesting; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; @@ -65,8 +64,8 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. 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_PROFILE_NAME; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; public class SearchAction implements QProfileWsAction { private static final Comparator Q_PROFILE_COMPARATOR = Comparator @@ -119,8 +118,9 @@ public class SearchAction implements QProfileWsAction { .setDescription("Language key. If provided, only profiles for the given language are returned.") .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)); - action.createParam(PARAM_PROFILE_NAME) - .setDescription("Profile name") + action.createParam(PARAM_QUALITY_PROFILE) + .setDescription("Quality profile name") + .setDeprecatedKey("profileName", "6.6") .setExampleValue("SonarQube Way"); } @@ -134,13 +134,12 @@ public class SearchAction implements QProfileWsAction { return new SearchWsRequest() .setOrganizationKey(request.param(PARAM_ORGANIZATION)) .setProjectKey(request.param(PARAM_PROJECT)) - .setProfileName(request.param(PARAM_PROFILE_NAME)) + .setQualityProfile(request.param(PARAM_QUALITY_PROFILE)) .setDefaults(request.paramAsBoolean(PARAM_DEFAULTS)) .setLanguage(request.param(PARAM_LANGUAGE)); } - @VisibleForTesting - SearchWsResponse doHandle(SearchWsRequest request) { + private SearchWsResponse doHandle(SearchWsRequest request) { SearchData data = load(request); return buildResponse(data); } @@ -204,7 +203,7 @@ public class SearchAction implements QProfileWsAction { } private static Predicate byName(SearchWsRequest request) { - return p -> request.getProfileName() == null || Objects.equals(p.getName(), request.getProfileName()); + return p -> request.getQualityProfile() == null || Objects.equals(p.getName(), request.getQualityProfile()); } private static Predicate byLanguage(SearchWsRequest request) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ShowAction.java index 9a293eeb25d..ce0b4a4ed87 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ShowAction.java @@ -52,7 +52,7 @@ import static org.sonar.server.ws.WsUtils.checkFound; import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SHOW; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class ShowAction implements QProfileWsAction { @@ -74,15 +74,16 @@ public class ShowAction implements QProfileWsAction { @Override public void define(WebService.NewController controller) { NewAction show = controller.createAction(ACTION_SHOW) - .setSince("6.5") .setDescription("Show a quality profile") + .setSince("6.5") .setResponseExample(getClass().getResource("show-example.json")) .setInternal(true) .setHandler(this); - show.createParam(PARAM_PROFILE) + 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) @@ -95,7 +96,7 @@ public class ShowAction implements QProfileWsAction { @Override public void handle(Request request, Response response) throws Exception { try (DbSession dbSession = dbClient.openSession(false)) { - QProfileDto profile = qProfileWsSupport.getProfile(dbSession, QProfileReference.fromKey(request.mandatoryParam(PARAM_PROFILE))); + QProfileDto profile = qProfileWsSupport.getProfile(dbSession, QProfileReference.fromKey(request.mandatoryParam(PARAM_KEY))); OrganizationDto organization = qProfileWsSupport.getOrganization(dbSession, profile); boolean isDefault = dbClient.defaultQProfileDao().isDefault(dbSession, profile.getOrganizationUuid(), profile.getKee()); ActiveRuleCountQuery.Builder builder = ActiveRuleCountQuery.builder().setOrganization(organization); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java index a2bef4dbdb8..229a95e4f9c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java @@ -52,7 +52,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; public class ActivateRuleActionTest { @@ -84,8 +84,8 @@ public class ActivateRuleActionTest { WebService.Action definition = ws.getDef(); assertThat(definition).isNotNull(); assertThat(definition.isPost()).isTrue(); - assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("severity", "profile", "reset", "rule", "params"); - WebService.Param profileKey = definition.param("profile"); + 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"); @@ -96,7 +96,7 @@ public class ActivateRuleActionTest { TestRequest request = ws.newRequest() .setMethod("POST") .setParam(PARAM_RULE, RuleTesting.newRule().getKey().toString()) - .setParam(PARAM_PROFILE, randomAlphanumeric(UUID_SIZE)); + .setParam(PARAM_KEY, randomAlphanumeric(UUID_SIZE)); expectedException.expect(UnauthorizedException.class); @@ -110,7 +110,7 @@ public class ActivateRuleActionTest { TestRequest request = ws.newRequest() .setMethod("POST") .setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_KEY, qualityProfile.getKee()); expectedException.expect(ForbiddenException.class); @@ -125,7 +125,7 @@ public class ActivateRuleActionTest { TestRequest request = ws.newRequest() .setMethod("POST") .setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_KEY, qualityProfile.getKee()); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Operation forbidden for built-in Quality Profile 'Xoo profile' with language 'xoo'"); @@ -141,7 +141,7 @@ public class ActivateRuleActionTest { TestRequest request = ws.newRequest() .setMethod("POST") .setParam(PARAM_RULE, ruleKey.toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()) + .setParam(PARAM_KEY, qualityProfile.getKee()) .setParam("severity", "BLOCKER") .setParam("params", "key1=v1;key2=v2") .setParam("reset", "false"); @@ -165,7 +165,7 @@ public class ActivateRuleActionTest { TestRequest request = ws.newRequest() .setMethod("POST") .setParam(PARAM_RULE, ruleKey.toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()) + .setParam(PARAM_KEY, qualityProfile.getKee()) .setParam("severity", "BLOCKER") .setParam("params", "key1=v1;key2=v2") .setParam("reset", "false"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java index 0e475029e23..4caa6f06ce2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java @@ -43,7 +43,7 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY; public class ActivateRulesActionTest { @@ -90,14 +90,14 @@ public class ActivateRulesActionTest { "active_severities", "s", "repositories", - "targetProfile", + "targetKey", "statuses", "rule_key", "available_since", "activation", "severities", "organization"); - WebService.Param targetProfile = definition.param("targetProfile"); + WebService.Param targetProfile = definition.param("targetKey"); assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key"); WebService.Param targetSeverity = definition.param("targetSeverity"); assertThat(targetSeverity.deprecatedKey()).isEqualTo("activation_severity"); @@ -107,7 +107,7 @@ public class ActivateRulesActionTest { public void should_fail_if_not_logged_in() { TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, randomAlphanumeric(UUID_SIZE)); + .setParam(PARAM_TARGET_KEY, randomAlphanumeric(UUID_SIZE)); expectedException.expect(UnauthorizedException.class); @@ -120,7 +120,7 @@ public class ActivateRulesActionTest { QProfileDto qualityProfile = db.qualityProfiles().insert(defaultOrganization, p -> p.setIsBuiltIn(true)); TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_TARGET_KEY, qualityProfile.getKee()); expectedException.expect(BadRequestException.class); @@ -133,7 +133,7 @@ public class ActivateRulesActionTest { QProfileDto qualityProfile = db.qualityProfiles().insert(organization); TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_TARGET_KEY, qualityProfile.getKee()); expectedException.expect(ForbiddenException.class); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java index 25f7cb780b6..47cd8cfd4f1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java @@ -72,15 +72,13 @@ public class AddProjectActionTest { // parameters assertThat(definition.params()).extracting(WebService.Param::key) - .containsExactlyInAnyOrder("profile", "profileName", "project", "language", "projectUuid", "organization"); - WebService.Param profile = definition.param("profile"); + .containsExactlyInAnyOrder("key", "qualityProfile", "project", "language", "projectUuid", "organization"); + WebService.Param profile = definition.param("key"); assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); - WebService.Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedSince()).isEqualTo("6.5"); + assertThat(profile.deprecatedSince()).isEqualTo("6.6"); WebService.Param languageParam = definition.param("language"); assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2); assertThat(languageParam.exampleValue()).isNull(); - assertThat(languageParam.deprecatedSince()).isEqualTo("6.5"); WebService.Param project = definition.param("project"); assertThat(project.deprecatedKey()).isEqualTo("projectKey"); WebService.Param projectUuid = definition.param("projectUuid"); @@ -293,7 +291,7 @@ public class AddProjectActionTest { private TestResponse call(ComponentDto project, QProfileDto qualityProfile) { TestRequest request = tester.newRequest() .setParam("projectUuid", project.uuid()) - .setParam("profile", qualityProfile.getKee()); + .setParam("key", qualityProfile.getKee()); return request.execute(); } @@ -302,7 +300,7 @@ public class AddProjectActionTest { .setParam("organization", organization.getKey()) .setParam("projectUuid", project.uuid()) .setParam("language", qualityProfile.getLanguage()) - .setParam("profileName", qualityProfile.getName()); + .setParam("qualityProfile", qualityProfile.getName()); return request.execute(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java index a0c81d94451..017f0d091e4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java @@ -40,7 +40,7 @@ import org.sonar.server.ws.TestResponse; import org.sonar.server.ws.WsActionTester; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class BackupActionTest { @@ -69,13 +69,13 @@ public class BackupActionTest { assertThat(definition.isPost()).isFalse(); // parameters - assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "organization", "profileName", "language"); - Param profile = definition.param("profile"); - assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); + 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"); Param language = definition.param("language"); - assertThat(language.deprecatedSince()).isEqualTo("6.5"); - Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedSince()).isEqualTo("6.5"); + assertThat(language.deprecatedSince()).isNullOrEmpty(); + Param profileName = definition.param("qualityProfile"); Param orgParam = definition.param("organization"); assertThat(orgParam.since()).isEqualTo("6.4"); } @@ -84,7 +84,7 @@ public class BackupActionTest { public void returns_backup_of_profile_with_specified_key() throws Exception { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization()); - TestResponse response = tester.newRequest().setParam(PARAM_PROFILE, profile.getKee()).execute(); + TestResponse response = tester.newRequest().setParam(PARAM_KEY, profile.getKee()).execute(); assertThat(response.getMediaType()).isEqualTo("application/xml"); assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile)); assertThat(response.getHeader("Content-Disposition")).isEqualTo("attachment; filename=" + profile.getKee() + ".xml"); @@ -96,7 +96,7 @@ public class BackupActionTest { TestResponse response = tester.newRequest() .setParam("language", profile.getLanguage()) - .setParam("profileName", profile.getName()) + .setParam("qualityProfile", profile.getName()) .execute(); assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile)); } @@ -109,7 +109,7 @@ public class BackupActionTest { TestResponse response = tester.newRequest() .setParam("organization", org.getKey()) .setParam("language", profile.getLanguage()) - .setParam("profileName", profile.getName()) + .setParam("qualityProfile", profile.getName()) .execute(); assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile)); } @@ -119,7 +119,7 @@ public class BackupActionTest { expectedException.expect(NotFoundException.class); expectedException.expectMessage("Quality Profile with key 'missing' does not exist"); - tester.newRequest().setParam(PARAM_PROFILE, "missing").execute(); + tester.newRequest().setParam(PARAM_KEY, "missing").execute(); } @Test @@ -130,7 +130,7 @@ public class BackupActionTest { tester.newRequest() .setParam("organization", "the-missing-org") .setParam("language", A_LANGUAGE) - .setParam("profileName", "the-name") + .setParam("qualityProfile", "the-name") .execute(); } @@ -147,7 +147,7 @@ public class BackupActionTest { tester.newRequest() .setParam("organization", org2.getKey()) .setParam("language", profileInOrg1.getLanguage()) - .setParam("profileName", profileInOrg1.getName()) + .setParam("qualityProfile", profileInOrg1.getName()) .execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java index 8ca0a99b486..110b3284175 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java @@ -32,6 +32,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; import org.sonar.api.server.ws.WebService; +import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -61,6 +62,7 @@ import org.sonar.server.tester.UserSessionRule; import org.sonar.server.util.TypeValidations; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.WsActionTester; +import org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters; import static java.util.Arrays.asList; import static java.util.Collections.emptySet; @@ -68,11 +70,11 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES; 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_NAME; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; +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; public class ChangeParentActionTest { @@ -134,19 +136,14 @@ public class ChangeParentActionTest { public void definition() { WebService.Action definition = ws.getDef(); assertThat(definition.isPost()).isTrue(); - assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder( - "organization", "profile", "profileName", "language", "parentProfile", "parentName"); + assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder( + "organization", "key", "qualityProfile", "language", "parentKey", "parentQualityProfile"); assertThat(definition.param("organization").since()).isEqualTo("6.4"); - WebService.Param profile = definition.param("profile"); + Param profile = definition.param("key"); assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); - WebService.Param parentProfile = definition.param("parentProfile"); - assertThat(parentProfile.deprecatedKey()).isEqualTo("parentKey"); - WebService.Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedSince()).isEqualTo("6.5"); - WebService.Param language = definition.param("language"); - assertThat(language.deprecatedSince()).isEqualTo("6.5"); - WebService.Param parentName = definition.param("parentName"); - assertThat(parentName.deprecatedSince()).isEqualTo("6.5"); + assertThat(profile.deprecatedSince()).isEqualTo("6.6"); + Param parentProfile = definition.param("parentKey"); + assertThat(parentProfile.deprecatedKey()).isNullOrEmpty(); } @Test @@ -164,8 +161,8 @@ public class ChangeParentActionTest { // Set parent ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()) - .setParam(PARAM_PARENT_PROFILE, parent1.getKee()) + .setParam(PARAM_KEY, child.getKee()) + .setParam(PARAM_PARENT_KEY, parent1.getKee()) .execute(); // Check rule 1 enabled @@ -195,8 +192,8 @@ public class ChangeParentActionTest { // Set parent 2 through WS ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()) - .setParam(PARAM_PARENT_PROFILE, parent2.getKee()) + .setParam(PARAM_KEY, child.getKee()) + .setParam(PARAM_PARENT_KEY, parent2.getKee()) .execute(); // Check rule 2 enabled @@ -223,7 +220,7 @@ public class ChangeParentActionTest { // Remove parent through WS ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()) + .setParam(PARAM_KEY, child.getKee()) .execute(); // Check no rule enabled @@ -254,9 +251,9 @@ public class ChangeParentActionTest { ws.newRequest() .setMethod("POST") .setParam(PARAM_LANGUAGE, child.getLanguage()) - .setParam(PARAM_PROFILE_NAME, child.getName()) + .setParam(PARAM_QUALITY_PROFILE, child.getName()) .setParam(PARAM_ORGANIZATION, organization.getKey()) - .setParam(PARAM_PARENT_NAME, parent1.getName()) + .setParam(PARAM_PARENT_QUALITY_PROFILE, parent1.getName()) .execute(); // 1. check rule 1 enabled @@ -269,9 +266,9 @@ public class ChangeParentActionTest { ws.newRequest() .setMethod("POST") .setParam(PARAM_LANGUAGE, child.getLanguage()) - .setParam(PARAM_PROFILE_NAME, child.getName()) + .setParam(PARAM_QUALITY_PROFILE, child.getName()) .setParam(PARAM_ORGANIZATION, organization.getKey()) - .setParam(PARAM_PARENT_NAME, parent2.getName()) + .setParam(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE, parent2.getName()) .execute(); // 2. check rule 2 enabled @@ -283,9 +280,9 @@ public class ChangeParentActionTest { ws.newRequest() .setMethod("POST") .setParam(PARAM_LANGUAGE, child.getLanguage()) - .setParam(PARAM_PROFILE_NAME, child.getName()) + .setParam(PARAM_QUALITY_PROFILE, child.getName()) .setParam(PARAM_ORGANIZATION, organization.getKey()) - .setParam(PARAM_PARENT_NAME, "") + .setParam(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE, "") .execute(); // 3. check no rule enabled @@ -312,8 +309,8 @@ public class ChangeParentActionTest { // Remove parent ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()) - .setParam(PARAM_PARENT_PROFILE, "") + .setParam(PARAM_KEY, child.getKee()) + .setParam(PARAM_PARENT_KEY, "") .execute(); // Check no rule enabled @@ -332,8 +329,8 @@ public class ChangeParentActionTest { TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()) - .setParam(PARAM_PARENT_PROFILE, "palap"); + .setParam(PARAM_KEY, child.getKee()) + .setParam(PARAM_PARENT_KEY, "palap"); thrown.expect(BadRequestException.class); @@ -349,9 +346,9 @@ public class ChangeParentActionTest { TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()) - .setParam(PARAM_PARENT_NAME, "polop") - .setParam(PARAM_PARENT_PROFILE, "palap"); + .setParam(PARAM_KEY, child.getKee()) + .setParam(PARAM_PARENT_QUALITY_PROFILE, "polop") + .setParam(PARAM_PARENT_KEY, "palap"); thrown.expect(IllegalArgumentException.class); request .execute(); @@ -366,10 +363,10 @@ public class ChangeParentActionTest { TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()) - .setParam(PARAM_PROFILE_NAME, child.getName()) + .setParam(PARAM_KEY, child.getKee()) + .setParam(PARAM_QUALITY_PROFILE, child.getName()) .setParam(PARAM_ORGANIZATION, organization.getKey()) - .setParam(PARAM_PARENT_PROFILE, "palap"); + .setParam(PARAM_PARENT_KEY, "palap"); thrown.expect(IllegalArgumentException.class); request.execute(); @@ -383,7 +380,7 @@ public class ChangeParentActionTest { TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()); + .setParam(PARAM_KEY, child.getKee()); thrown.expect(ForbiddenException.class); thrown.expectMessage("Insufficient privileges"); @@ -399,7 +396,7 @@ public class ChangeParentActionTest { TestRequest request = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, child.getKee()); + .setParam(PARAM_KEY, child.getKee()); thrown.expect(ForbiddenException.class); thrown.expectMessage("Insufficient privileges"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java index 798a30f2206..8f6d7166b66 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java @@ -42,8 +42,8 @@ import org.sonar.server.ws.WsActionTester; import static org.assertj.core.api.Assertions.assertThat; 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_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; public class ChangelogActionDatabaseTest { @@ -76,13 +76,11 @@ public class ChangelogActionDatabaseTest { assertThat(definition.responseExampleAsString()).isNotEmpty(); assertThat(definition.params()).extracting(WebService.Param::key) - .containsExactlyInAnyOrder("profile", "profileName", "language", "organization", "since", "to", "p", "ps"); - WebService.Param profile = definition.param("profile"); - assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); - WebService.Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedSince()).isEqualTo("6.5"); + .containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization", "since", "to", "p", "ps"); + WebService.Param profileName = definition.param("qualityProfile"); + assertThat(profileName.deprecatedSince()).isNullOrEmpty(); WebService.Param language = definition.param("language"); - assertThat(language.deprecatedSince()).isEqualTo("6.5"); + assertThat(language.deprecatedSince()).isNullOrEmpty(); } @Test @@ -91,7 +89,7 @@ public class ChangelogActionDatabaseTest { String response = ws.newRequest() .setMethod("GET") - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .execute() .getInput(); @@ -105,7 +103,7 @@ public class ChangelogActionDatabaseTest { String response = ws.newRequest() .setMethod("GET") .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage()) - .setParam(PARAM_PROFILE_NAME, qualityProfile.getName()) + .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName()) .execute() .getInput(); @@ -119,7 +117,7 @@ public class ChangelogActionDatabaseTest { String response = ws.newRequest() .setMethod("GET") .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage()) - .setParam(PARAM_PROFILE_NAME, qualityProfile.getName()) + .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName()) .setParam(PARAM_ORGANIZATION, organization.getKey()) .execute() .getInput(); @@ -137,7 +135,7 @@ public class ChangelogActionDatabaseTest { TestRequest request = ws.newRequest() .setMethod("GET") .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage()) - .setParam(PARAM_PROFILE_NAME, qualityProfile.getName()) + .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName()) .setParam(PARAM_ORGANIZATION, organization2.getKey()); thrown.expect(NotFoundException.class); @@ -151,7 +149,7 @@ public class ChangelogActionDatabaseTest { String response = ws.newRequest() .setMethod("GET") - .setParam(PARAM_PROFILE, qualityProfile.getKee()) + .setParam(PARAM_KEY, qualityProfile.getKee()) .execute() .getInput(); @@ -172,7 +170,7 @@ public class ChangelogActionDatabaseTest { String response = ws.newRequest() .setMethod("GET") - .setParam(PARAM_PROFILE, qualityProfile.getKee()) + .setParam(PARAM_KEY, qualityProfile.getKee()) .execute() .getInput(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionMockTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionMockTest.java index 022939bd9f6..736b0b76e09 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionMockTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionMockTest.java @@ -44,7 +44,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.sonar.api.utils.DateUtils.parseDate; import static org.sonar.server.qualityprofile.QProfileTesting.XOO_P1_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SINCE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TO; @@ -72,7 +72,7 @@ public class ChangelogActionMockTest { when(wsSupport.getProfile(any(DbSession.class), eq(QProfileReference.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1(organization)); when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(0, Collections.emptyList())); - ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY) + ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY) .execute().assertJson(getClass(), "changelog_empty.json"); } @@ -84,7 +84,7 @@ public class ChangelogActionMockTest { List changes = asList(change1, change2); when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(10, changes)); - ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY) + ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY) .execute().assertJson(getClass(), "changelog_nominal.json"); } @@ -97,7 +97,7 @@ public class ChangelogActionMockTest { List changes = asList(change1); when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(10, changes)); - ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY) + ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY) .execute().assertJson(getClass(), "changelog_full.json"); } @@ -107,7 +107,7 @@ public class ChangelogActionMockTest { when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(0, Collections.emptyList())); ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog") - .setParam(PARAM_PROFILE, XOO_P1_KEY) + .setParam(PARAM_KEY, XOO_P1_KEY) .setParam(PARAM_SINCE, "2016-09-01") .setParam(PARAM_TO, "2016-09-01") .execute(); @@ -122,6 +122,6 @@ public class ChangelogActionMockTest { public void fail_on_unknown_profile() throws Exception { when(wsSupport.getProfile(any(DbSession.class), eq(QProfileReference.fromKey(XOO_P1_KEY)))).thenThrow(new NotFoundException("Profile not found")); - ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY).execute(); + ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY).execute(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java index a27c80aebe3..a64522226a9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java @@ -117,10 +117,10 @@ public class CreateActionTest { assertThat(definition.responseExampleAsString()).isNotEmpty(); assertThat(definition.params()).extracting(Param::key) - .containsExactlyInAnyOrder("language", "organization", "profileName", "backup_with_messages", "backup_with_errors", "backup_xoo_lint"); - Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedKey()).isEqualTo("name"); - assertThat(profileName.deprecatedKeySince()).isEqualTo("6.1"); + .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 diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java index 3c70df775d3..c46792036de 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java @@ -50,7 +50,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; public class DeactivateRuleActionTest { @@ -80,8 +80,8 @@ public class DeactivateRuleActionTest { WebService.Action definition = wsActionTester.getDef(); assertThat(definition).isNotNull(); assertThat(definition.isPost()).isTrue(); - assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("profile", "rule"); - WebService.Param profileKey = definition.param("profile"); + 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"); @@ -92,7 +92,7 @@ public class DeactivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString()) - .setParam(PARAM_PROFILE, randomAlphanumeric(UUID_SIZE)); + .setParam(PARAM_KEY, randomAlphanumeric(UUID_SIZE)); expectedException.expect(UnauthorizedException.class); @@ -106,7 +106,7 @@ public class DeactivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_KEY, qualityProfile.getKee()); expectedException.expect(ForbiddenException.class); @@ -121,7 +121,7 @@ public class DeactivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_KEY, qualityProfile.getKee()); expectedException.expect(BadRequestException.class); @@ -136,7 +136,7 @@ public class DeactivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam(PARAM_RULE, ruleKey.toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_KEY, qualityProfile.getKee()); TestResponse response = request.execute(); @@ -157,7 +157,7 @@ public class DeactivateRuleActionTest { .setMethod("POST") .setParam("organization", organization.getKey()) .setParam(PARAM_RULE, ruleKey.toString()) - .setParam(PARAM_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_KEY, qualityProfile.getKee()); TestResponse response = request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java index 0312273fc84..4ce81b1b275 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java @@ -43,7 +43,7 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY; public class DeactivateRulesActionTest { @@ -88,14 +88,14 @@ public class DeactivateRulesActionTest { "active_severities", "s", "repositories", - "targetProfile", + "targetKey", "statuses", "rule_key", "available_since", "activation", "severities", "organization"); - WebService.Param targetProfile = definition.param("targetProfile"); + WebService.Param targetProfile = definition.param("targetKey"); assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key"); } @@ -103,7 +103,7 @@ public class DeactivateRulesActionTest { public void should_fail_if_not_logged_in() { TestRequest request = wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, randomAlphanumeric(UUID_SIZE)); + .setParam(PARAM_TARGET_KEY, randomAlphanumeric(UUID_SIZE)); thrown.expect(UnauthorizedException.class); request.execute(); @@ -115,7 +115,7 @@ public class DeactivateRulesActionTest { QProfileDto qualityProfile = dbTester.qualityProfiles().insert(defaultOrganization, p -> p.setIsBuiltIn(true)); TestRequest request = wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_TARGET_KEY, qualityProfile.getKee()); thrown.expect(BadRequestException.class); @@ -128,7 +128,7 @@ public class DeactivateRulesActionTest { QProfileDto qualityProfile = dbTester.qualityProfiles().insert(organization); TestRequest request = wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee()); + .setParam(PARAM_TARGET_KEY, qualityProfile.getKee()); thrown.expect(ForbiddenException.class); request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java index 8f9075b95d5..1ee7fffe84a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java @@ -104,7 +104,7 @@ public class DeleteActionTest { TestResponse response = ws.newRequest() .setMethod("POST") .setParam("language", profile1.getLanguage()) - .setParam("profileName", profile1.getName()) + .setParam("qualityProfile", profile1.getName()) .execute(); assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT); @@ -126,7 +126,7 @@ public class DeleteActionTest { .setMethod("POST") .setParam("organization", organization.getKey()) .setParam("language", profile1.getLanguage()) - .setParam("profileName", profile1.getName()) + .setParam("qualityProfile", profile1.getName()) .execute(); assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT); @@ -292,13 +292,14 @@ public class DeleteActionTest { public void definition() { WebService.Action definition = ws.getDef(); - assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "organization", "profile", "profileName"); - Param profile = definition.param("profile"); - assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); - Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedSince()).isEqualTo("6.5"); + 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()).isEqualTo("6.5"); + assertThat(language.deprecatedSince()).isNullOrEmpty(); } private void logInAsQProfileAdministrator(OrganizationDto organization) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java index 269debcf3be..04774a842f2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java @@ -49,7 +49,7 @@ import org.sonar.server.ws.WsActionTester; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class ExportActionTest { @@ -73,16 +73,17 @@ public class ExportActionTest { assertThat(definition.isPost()).isFalse(); assertThat(definition.isInternal()).isFalse(); - assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("profile", "language", "name", "organization"); + assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization"); WebService.Param organizationParam = definition.param("organization"); assertThat(organizationParam.since()).isEqualTo("6.4"); assertThat(organizationParam.isInternal()).isTrue(); - WebService.Param profile = definition.param("profile"); - assertThat(profile.since()).isEqualTo("6.5"); - WebService.Param name = definition.param("name"); - assertThat(name.deprecatedSince()).isEqualTo("6.5"); + 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(); WebService.Param language = definition.param("language"); - assertThat(language.deprecatedSince()).isEqualTo("6.5"); + assertThat(language.deprecatedSince()).isNullOrEmpty(); } @Test @@ -91,7 +92,7 @@ public class ExportActionTest { assertThat(definition.isPost()).isFalse(); assertThat(definition.isInternal()).isFalse(); - assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("profile", "language", "name", "organization", "exporterKey"); + assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization", "exporterKey"); WebService.Param exportersParam = definition.param("exporterKey"); assertThat(exportersParam.possibleValues()).containsOnly("polop", "palap"); assertThat(exportersParam.deprecatedKey()).isEqualTo("format"); @@ -105,7 +106,7 @@ public class ExportActionTest { WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap")); String result = tester.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam("exporterKey", "polop").execute() .getInput(); @@ -119,7 +120,7 @@ public class ExportActionTest { WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap")); ws.newRequest() - .setParam(PARAM_PROFILE, "PROFILE-KEY-404") + .setParam(PARAM_KEY, "PROFILE-KEY-404") .setParam("exporterKey", "polop").execute() .getInput(); } @@ -129,11 +130,11 @@ public class ExportActionTest { QProfileDto profile = createProfile(db.getDefaultOrganization(), false); expectedException.expect(BadRequestException.class); - expectedException.expectMessage("Either 'profile' or 'language' must be provided."); + expectedException.expectMessage("Either 'key' or 'language' must be provided."); WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap")); ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_LANGUAGE, profile.getLanguage()) .setParam("exporterKey", "polop").execute() .getInput(); @@ -146,7 +147,7 @@ public class ExportActionTest { WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap")); String result = tester.newRequest() .setParam("language", profile.getLanguage()) - .setParam("name", profile.getName()) + .setParam("qualityProfile", profile.getName()) .setParam("exporterKey", "polop").execute() .getInput(); @@ -162,7 +163,7 @@ public class ExportActionTest { String result = tester.newRequest() .setParam("organization", organization.getKey()) .setParam("language", profile.getLanguage()) - .setParam("name", profile.getName()) + .setParam("qualityProfile", profile.getName()) .setParam("exporterKey", "polop").execute() .getInput(); @@ -227,7 +228,7 @@ public class ExportActionTest { String result = newWsActionTester(newExporter("polop")).newRequest() .setParam("language", profile.getLanguage()) - .setParam("name", profile.getName()) + .setParam("qualityProfile", profile.getName()) .execute() .getInput(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java index beca53c8829..af5979d4dd9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java @@ -63,7 +63,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.server.qualityprofile.QProfileTesting.newQProfileDto; import static org.sonar.test.JsonAssert.assertJson; import static org.sonarqube.ws.MediaTypes.PROTOBUF; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class InheritanceActionTest { @@ -144,7 +144,7 @@ public class InheritanceActionTest { String response = ws.newRequest() .setMethod("GET") - .setParam(PARAM_PROFILE, buWide.getKee()) + .setParam(PARAM_KEY, buWide.getKee()) .execute() .getInput(); @@ -172,7 +172,7 @@ public class InheritanceActionTest { InputStream response = ws.newRequest() .setMethod("GET") .setMediaType(PROTOBUF) - .setParam(PARAM_PROFILE, child.getKee()) + .setParam(PARAM_KEY, child.getKee()) .execute() .getInputStream(); @@ -199,7 +199,7 @@ public class InheritanceActionTest { InputStream response = ws.newRequest() .setMethod("GET") .setMediaType(PROTOBUF) - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .execute() .getInputStream(); @@ -215,7 +215,7 @@ public class InheritanceActionTest { String response = ws.newRequest() .setMethod("GET") - .setParam(PARAM_PROFILE, remi.getKee()) + .setParam(PARAM_KEY, remi.getKee()) .execute() .getInput(); @@ -225,7 +225,7 @@ public class InheritanceActionTest { @Test(expected = NotFoundException.class) public void fail_if_not_found() throws Exception { ws.newRequest() - .setMethod("GET").setParam(PARAM_PROFILE, "polop").execute(); + .setMethod("GET").setParam(PARAM_KEY, "polop").execute(); } @Test @@ -233,13 +233,14 @@ public class InheritanceActionTest { WebService.Action definition = ws.getDef(); assertThat(definition.key()).isEqualTo("inheritance"); - assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "language", "profileName", "organization"); - Param profile = definition.param("profile"); - assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); - Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedSince()).isEqualTo("6.5"); + 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()).isEqualTo("6.5"); + assertThat(language.deprecatedSince()).isNullOrEmpty(); } private QProfileDto createProfile(String lang, String name, String key) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java index ad57f5db450..7051702e9e4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java @@ -44,7 +44,7 @@ import org.sonar.server.ws.WsTester; import org.sonar.server.ws.WsTester.TestRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class ProjectsActionTest { @@ -94,7 +94,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").execute().assertJson(this.getClass(), "authorized_selected.json"); + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").execute().assertJson(this.getClass(), "authorized_selected.json"); } @Test @@ -109,20 +109,20 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2") + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2") .execute().assertJson(this.getClass(), "selected_page1.json"); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "2") + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "2") .execute().assertJson(this.getClass(), "selected_page2.json"); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "3") + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "3") .execute().assertJson(this.getClass(), "empty.json"); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "4") + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "4") .execute().assertJson(this.getClass(), "empty.json"); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "1") + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "1") .execute().assertJson(this.getClass(), "selected_ps3_page1.json"); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "2") + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "2") .execute().assertJson(this.getClass(), "selected_ps3_page2.json"); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "3") + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "3") .execute().assertJson(this.getClass(), "empty.json"); } @@ -138,7 +138,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "deselected").execute().assertJson(this.getClass(), "deselected.json"); + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "deselected").execute().assertJson(this.getClass(), "deselected.json"); } @Test @@ -155,7 +155,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "all.json"); + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "all.json"); } @Test @@ -170,14 +170,14 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "all").setParam(Param.TEXT_QUERY, "project t").execute().assertJson(this.getClass(), "all_filtered.json"); + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "all").setParam(Param.TEXT_QUERY, "project t").execute().assertJson(this.getClass(), "all_filtered.json"); } @Test public void should_fail_on_nonexistent_profile() throws Exception { expectedException.expect(NotFoundException.class); - newRequest().setParam(PARAM_PROFILE, "unknown").setParam("selected", "all").execute(); + newRequest().setParam(PARAM_KEY, "unknown").setParam("selected", "all").execute(); } @Test @@ -194,7 +194,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "return_deprecated_uuid_field.json"); + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "return_deprecated_uuid_field.json"); } @Test @@ -202,7 +202,7 @@ public class ProjectsActionTest { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("The 'ps' parameter must be less than 500"); - newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam(Param.PAGE_SIZE, "501").execute(); + newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam(Param.PAGE_SIZE, "501").execute(); } @Test @@ -211,9 +211,9 @@ public class ProjectsActionTest { assertThat(definition.key()).isEqualTo("projects"); assertThat(definition.responseExampleAsString()).isNotEmpty(); - assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "p", "ps", "q", "selected"); - Param profile = definition.param("profile"); - assertThat(profile.deprecatedKey()).isEqualTo("key"); + assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "p", "ps", "q", "selected"); + Param profile = definition.param("key"); + assertThat(profile.deprecatedKey()).isNullOrEmpty(); Param page = definition.param("p"); assertThat(page.deprecatedKey()).isEqualTo("page"); Param pageSize = definition.param("ps"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileReferenceTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileReferenceTest.java index 18b8aa9e2af..71bce7be8de 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileReferenceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileReferenceTest.java @@ -101,7 +101,7 @@ public class QProfileReferenceTest { @Test public void from_reads_request_parameters_and_creates_reference_by_key() { SimpleGetRequest req = new SimpleGetRequest(); - req.setParam("profile", "foo"); + req.setParam("key", "foo"); QProfileReference ref = QProfileReference.from(req); assertThat(ref.getKey()).isEqualTo("foo"); @@ -111,7 +111,7 @@ public class QProfileReferenceTest { public void from_reads_request_parameters_and_creates_reference_by_name_on_default_organization() { SimpleGetRequest req = new SimpleGetRequest(); req.setParam("language", "js"); - req.setParam("profileName", "Sonar way"); + req.setParam("qualityProfile", "Sonar way"); QProfileReference ref = QProfileReference.from(req); assertThat(ref.getOrganizationKey()).isEmpty(); @@ -124,7 +124,7 @@ public class QProfileReferenceTest { SimpleGetRequest req = new SimpleGetRequest(); req.setParam("organization", "my-org"); req.setParam("language", "js"); - req.setParam("profileName", "Sonar way"); + req.setParam("qualityProfile", "Sonar way"); QProfileReference ref = QProfileReference.from(req); assertThat(ref.getOrganizationKey()).hasValue("my-org"); @@ -165,8 +165,8 @@ public class QProfileReferenceTest { WebService.Action action = wsTester.controller("api/qualityprofiles").action("do"); assertThat(action.param("language")).isNotNull(); assertThat(action.param("language").possibleValues()).containsOnly("java", "js"); - assertThat(action.param("profile")).isNotNull(); - assertThat(action.param("profileName")).isNotNull(); + assertThat(action.param("key")).isNotNull(); + assertThat(action.param("qualityProfile")).isNotNull(); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java index f51b8ddcbe0..4c7be42f5cf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java @@ -63,11 +63,11 @@ import org.sonar.server.ws.WsActionTester; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_SEVERITY; import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES; import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE; @@ -119,7 +119,7 @@ public class QProfilesWsMediumTest { // 1. Deactivate Rule wsDeactivateRule.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_RULE, rule.getKey().toString()) .execute(); dbSession.clearCache(); @@ -147,7 +147,7 @@ public class QProfilesWsMediumTest { // 1. Deactivate Rule wsDeactivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, profile.getKee()) + .setParam(PARAM_TARGET_KEY, profile.getKee()) .execute(); dbSession.clearCache(); @@ -173,7 +173,7 @@ public class QProfilesWsMediumTest { // 1. Deactivate Rule wsDeactivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, profile.getKee()) + .setParam(PARAM_TARGET_KEY, profile.getKee()) .execute(); dbSession.clearCache(); @@ -197,7 +197,7 @@ public class QProfilesWsMediumTest { // 1. Deactivate Rule wsDeactivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, profile.getKee()) + .setParam(PARAM_TARGET_KEY, profile.getKee()) .setParam(Param.TEXT_QUERY, "hello") .execute(); dbSession.clearCache(); @@ -217,7 +217,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule wsActivateRule.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_RULE, rule.getKey().toString()) .execute(); dbSession.clearCache(); @@ -238,7 +238,7 @@ public class QProfilesWsMediumTest { try { // 1. Activate Rule wsActivateRule.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_RULE, rule.getKey().toString()) .execute(); dbSession.clearCache(); @@ -259,7 +259,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule wsActivateRule.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_RULE, rule.getKey().toString()) .setParam(PARAM_SEVERITY, "MINOR") .execute(); @@ -287,7 +287,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule wsActivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, profile.getKee()) + .setParam(PARAM_TARGET_KEY, profile.getKee()) .setParam(PARAM_LANGUAGES, "java") .execute() .assertJson(getClass(), "bulk_activate_rule.json"); @@ -312,7 +312,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule wsActivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, php.getKee()) + .setParam(PARAM_TARGET_KEY, php.getKee()) .setParam(PARAM_LANGUAGES, "php") .execute() .assertJson(getClass(), "bulk_activate_rule_not_all.json"); @@ -336,7 +336,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule with query returning 0 hits wsActivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, profile.getKee()) + .setParam(PARAM_TARGET_KEY, profile.getKee()) .setParam(Param.TEXT_QUERY, "php") .execute(); dbSession.clearCache(); @@ -346,7 +346,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule with query returning 1 hits wsActivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, profile.getKee()) + .setParam(PARAM_TARGET_KEY, profile.getKee()) .setParam(Param.TEXT_QUERY, "world") .execute(); dbSession.commit(); @@ -372,7 +372,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule with query returning 2 hits wsActivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, profile.getKee()) + .setParam(PARAM_TARGET_KEY, profile.getKee()) .setParam(PARAM_TARGET_SEVERITY, "MINOR") .execute(); dbSession.commit(); @@ -398,7 +398,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule wsActivateRules.newRequest().setMethod("POST") - .setParam(PARAM_TARGET_PROFILE, javaProfile.getKee()) + .setParam(PARAM_TARGET_KEY, javaProfile.getKee()) .setParam(PARAM_QPROFILE, javaProfile.getKee()) .setParam("activation", "false") .execute() @@ -433,7 +433,7 @@ public class QProfilesWsMediumTest { // 1. reset child rule wsActivateRule.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, subProfile.getKee()) + .setParam(PARAM_KEY, subProfile.getKee()) .setParam(PARAM_RULE, rule.getKey().toString()) .setParam(PARAM_RESET, "true") .execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java index 40fc22c8f41..1797e4935a0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java @@ -28,6 +28,7 @@ import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Language; import org.sonar.api.resources.Languages; import org.sonar.api.server.ws.WebService; +import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.ValidationMessages; import org.sonar.db.DbClient; import org.sonar.server.language.LanguageTesting; @@ -106,8 +107,8 @@ public class QProfilesWsTest { assertThat(create.param("organization")).isNotNull(); assertThat(create.param("organization").isRequired()).isFalse(); assertThat(create.param("organization").isInternal()).isTrue(); - assertThat(create.param("profileName")).isNotNull(); - assertThat(create.param("profileName").isRequired()).isTrue(); + assertThat(create.param("name")).isNotNull(); + assertThat(create.param("name").isRequired()).isTrue(); assertThat(create.param("language").possibleValues()).containsOnly(xoo1Key, xoo2Key); assertThat(create.param("language").isRequired()).isTrue(); assertThat(create.param("backup_" + xoo1Key)).isNotNull(); @@ -152,8 +153,8 @@ public class QProfilesWsTest { WebService.Action delete = controller.action("delete"); assertThat(delete).isNotNull(); assertThat(delete.isPost()).isTrue(); - assertThat(delete.params()).hasSize(4).extracting("key").containsOnly( - "organization", "profile", "language", "profileName"); + assertThat(delete.params()).hasSize(4).extracting(Param::key).containsOnly( + "organization", "key", "language", "qualityProfile"); } @Test @@ -170,8 +171,8 @@ public class QProfilesWsTest { WebService.Action inheritance = controller.action("inheritance"); assertThat(inheritance).isNotNull(); assertThat(inheritance.isPost()).isFalse(); - assertThat(inheritance.params()).hasSize(4).extracting("key").containsExactlyInAnyOrder( - "organization", "profile", "language", "profileName"); + assertThat(inheritance.params()).hasSize(4).extracting(Param::key).containsExactlyInAnyOrder( + "organization", "key", "language", "qualityProfile"); assertThat(inheritance.responseExampleAsString()).isNotEmpty(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java index b08b83cc2b7..50576a44a1b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java @@ -75,18 +75,18 @@ public class RemoveProjectActionTest { assertThat(definition.isPost()).isTrue(); assertThat(definition.key()).isEqualTo("remove_project"); - assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("profile", "profileName", "project", "language", "projectUuid", "organization"); + assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("key", "qualityProfile", "project", "language", "projectUuid", "organization"); WebService.Param languageParam = definition.param("language"); assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2); assertThat(languageParam.exampleValue()).isNull(); - assertThat(languageParam.deprecatedSince()).isEqualTo("6.5"); + assertThat(languageParam.deprecatedSince()).isNullOrEmpty(); WebService.Param organizationParam = definition.param("organization"); assertThat(organizationParam.since()).isEqualTo("6.4"); assertThat(organizationParam.isInternal()).isTrue(); - WebService.Param profile = definition.param("profile"); + WebService.Param profile = definition.param("key"); assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); - WebService.Param profileName = definition.param("profileName"); - assertThat(profileName.deprecatedSince()).isEqualTo("6.5"); + 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"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java index 2208956d275..8211b0d87df 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java @@ -140,7 +140,7 @@ public class RenameActionTest { logInAsQProfileAdministrator(); expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The 'profile' parameter is missing"); + expectedException.expectMessage("The 'key' parameter is missing"); call(null, "Other Sonar Way"); } @@ -242,9 +242,9 @@ public class RenameActionTest { assertThat(definition.key()).isEqualTo("rename"); assertThat(definition.isPost()).isTrue(); - assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "name"); - Param profile = definition.param("profile"); - assertThat(profile.deprecatedKey()).isEqualTo("key"); + assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "name"); + Param profile = definition.param("key"); + assertThat(profile.deprecatedKey()).isNullOrEmpty(); } private String createNewValidQualityProfileKey() { @@ -272,7 +272,7 @@ public class RenameActionTest { TestRequest request = ws.newRequest() .setMethod("POST"); - setNullable(key, k -> request.setParam("profile", k)); + setNullable(key, k -> request.setParam("key", k)); setNullable(name, n -> request.setParam("name", n)); request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java index becad7fc7cb..9616039f8a9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java @@ -61,7 +61,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_PROFILE_NAME; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; public class SearchActionTest { @@ -116,9 +116,9 @@ public class SearchActionTest { assertThat(language.deprecatedSince()).isNull(); assertThat(language.description()).isEqualTo("Language key. If provided, only profiles for the given language are returned."); - WebService.Param profileName = definition.param("profileName"); + WebService.Param profileName = definition.param("qualityProfile"); assertThat(profileName.deprecatedSince()).isNull(); - assertThat(profileName.description()).isEqualTo("Profile name"); + assertThat(profileName.description()).isEqualTo("Quality profile name"); } @Test @@ -228,7 +228,7 @@ public class SearchActionTest { QProfileDto sonarWayInCamelCase = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setName("Sonar Way").setLanguage(XOO2.getKey())); QProfileDto anotherProfile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setName("Another").setLanguage(XOO2.getKey())); - SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROFILE_NAME, "Sonar way")); + SearchWsResponse result = call(ws.newRequest().setParam(PARAM_QUALITY_PROFILE, "Sonar way")); assertThat(result.getProfilesList()).extracting(QualityProfile::getKey) .containsExactlyInAnyOrder(sonarWayOnXoo1.getKee(), sonarWayOnXoo2.getKee()) @@ -244,7 +244,7 @@ public class SearchActionTest { SearchWsResponse result = call(ws.newRequest() .setParam(PARAM_DEFAULTS, "true") - .setParam(PARAM_PROFILE_NAME, "Sonar way")); + .setParam(PARAM_QUALITY_PROFILE, "Sonar way")); assertThat(result.getProfilesList()).extracting(QualityProfile::getKey) .containsExactlyInAnyOrder(sonarWayOnXoo1.getKee()) diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java index 48f29486809..90a1e1ab5f3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java @@ -44,7 +44,7 @@ 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_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class SetDefaultActionTest { @@ -106,12 +106,12 @@ public class SetDefaultActionTest { assertThat(definition).isNotNull(); assertThat(definition.isPost()).isTrue(); - assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "profileName", "language", "organization"); + assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization"); assertThat(definition.param("organization").since()).isEqualTo("6.4"); - Param profile = definition.param("profile"); + Param profile = definition.param("key"); assertThat(profile.deprecatedKey()).isEqualTo("profileKey"); - assertThat(definition.param("profileName").deprecatedSince()).isEqualTo("6.5"); - assertThat(definition.param("language").deprecatedSince()).isEqualTo("6.5"); + assertThat(definition.param("qualityProfile").deprecatedSince()).isNullOrEmpty(); + assertThat(definition.param("language").deprecatedSince()).isNullOrEmpty(); } @Test @@ -123,7 +123,7 @@ public class SetDefaultActionTest { TestResponse response = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, xoo2Profile.getKee()).execute(); + .setParam(PARAM_KEY, xoo2Profile.getKee()).execute(); assertThat(response.getInput()).isEmpty(); @@ -133,7 +133,7 @@ public class SetDefaultActionTest { // One more time! TestResponse response2 = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE, xoo2Profile.getKee()).execute(); + .setParam(PARAM_KEY, xoo2Profile.getKee()).execute(); assertThat(response2.getInput()).isEmpty(); checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee()); @@ -149,7 +149,7 @@ public class SetDefaultActionTest { TestResponse response = ws.newRequest().setMethod("POST") .setParam("language", xoo2Profile.getLanguage()) - .setParam("profileName", xoo2Profile.getName()) + .setParam("qualityProfile", xoo2Profile.getName()) .setParam("organization", organization.getKey()) .execute(); @@ -185,7 +185,7 @@ public class SetDefaultActionTest { TestResponse response = ws.newRequest().setMethod("POST") .setParam("language", profileOrg1New.getLanguage()) - .setParam("profileName", profileOrg1New.getName()) + .setParam("qualityProfile", profileOrg1New.getName()) .setParam("organization", organization1.getKey()) .execute(); @@ -204,7 +204,7 @@ public class SetDefaultActionTest { expectedException.expectMessage("Quality Profile with key 'unknown-profile-666' does not exist"); ws.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, "unknown-profile-666") + .setParam(PARAM_KEY, "unknown-profile-666") .execute(); checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee()); @@ -218,7 +218,7 @@ public class SetDefaultActionTest { try { TestResponse response = ws.newRequest().setMethod("POST") .setParam("language", XOO_2_KEY) - .setParam("profileName", "Unknown") + .setParam("qualityProfile", "Unknown") .execute(); Fail.failBecauseExceptionWasNotThrown(NotFoundException.class); } catch (NotFoundException nfe) { @@ -236,7 +236,7 @@ public class SetDefaultActionTest { expectedException.expectMessage("When providing a quality profile key, neither of organization/language/name must be set"); ws.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, xoo2Profile.getKee()) + .setParam(PARAM_KEY, xoo2Profile.getKee()) .setParam("organization", organization.getKey()) .execute(); } @@ -249,7 +249,7 @@ public class SetDefaultActionTest { expectedException.expectMessage("Insufficient privileges"); ws.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, xoo2Profile.getKee()) + .setParam(PARAM_KEY, xoo2Profile.getKee()) .execute(); } @@ -259,7 +259,7 @@ public class SetDefaultActionTest { expectedException.expectMessage("Authentication is required"); ws.newRequest().setMethod("POST") - .setParam(PARAM_PROFILE, xoo2Profile.getKee()) + .setParam(PARAM_KEY, xoo2Profile.getKee()) .execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java index 8e605e81919..52d23cd5a7c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java @@ -54,7 +54,7 @@ import static org.sonar.api.utils.DateUtils.parseDateTime; import static org.sonar.server.language.LanguageTesting.newLanguage; import static org.sonar.test.JsonAssert.assertJson; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; public class ShowActionTest { @@ -86,7 +86,7 @@ public class ShowActionTest { assertThat(action.isPost()).isFalse(); assertThat(action.since()).isEqualTo("6.5"); - WebService.Param profile = action.param("profile"); + WebService.Param profile = action.param("key"); assertThat(profile.isRequired()).isTrue(); assertThat(profile.isInternal()).isFalse(); assertThat(profile.description()).isNotEmpty(); @@ -103,7 +103,7 @@ public class ShowActionTest { public void profile_info() { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); - QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee())); + QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee())); assertThat(result.getProfile()) .extracting(QualityProfile::getKey, QualityProfile::getName, QualityProfile::getIsBuiltIn, QualityProfile::getLanguage, QualityProfile::getLanguageName, @@ -116,7 +116,7 @@ public class ShowActionTest { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); db.qualityProfiles().setAsDefault(profile); - QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee())); + QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee())); assertThat(result.getProfile().getIsDefault()).isTrue(); } @@ -127,7 +127,7 @@ public class ShowActionTest { QProfileDto defaultProfile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); db.qualityProfiles().setAsDefault(defaultProfile); - ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee())); + ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee())); assertThat(result.getProfile().getIsDefault()).isFalse(); } @@ -141,7 +141,7 @@ public class ShowActionTest { .setLastUsed(time) .setUserUpdatedAt(time)); - QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee())); + QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee())); assertThat(result.getProfile().getRulesUpdatedAt()).isEqualTo("2016-12-21T19:10:03+0100"); assertThat(parseDateTime(result.getProfile().getLastUsed()).getTime()).isEqualTo(time); @@ -164,7 +164,7 @@ public class ShowActionTest { .mapToObj(i -> db.components().insertPrivateProject()) .forEach(project -> db.qualityProfiles().associateWithProject(project, profile)); - QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee())); + QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee())); assertThat(result.getProfile()) .extracting(QualityProfile::getActiveRuleCount, QualityProfile::getActiveDeprecatedRuleCount, QualityProfile::getProjectCount) @@ -192,7 +192,7 @@ public class ShowActionTest { activeRuleIndexer.indexOnStartup(activeRuleIndexer.getIndexTypes()); CompareToSonarWay result = call(ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "true")) .getCompareToSonarWay(); @@ -212,7 +212,7 @@ public class ShowActionTest { activeRuleIndexer.indexOnStartup(activeRuleIndexer.getIndexTypes()); CompareToSonarWay result = call(ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "true")) .getCompareToSonarWay(); @@ -228,7 +228,7 @@ public class ShowActionTest { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); ShowResponse result = call(ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "true")); assertThat(result.hasCompareToSonarWay()).isFalse(); @@ -240,7 +240,7 @@ public class ShowActionTest { QProfileDto anotherBuiltInProfile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setIsBuiltIn(true).setLanguage(XOO1.getKey())); QualityProfiles.ShowResponse result = call(ws.newRequest() - .setParam(PARAM_PROFILE, anotherBuiltInProfile.getKee()) + .setParam(PARAM_KEY, anotherBuiltInProfile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "true")); assertThat(result.hasCompareToSonarWay()).isFalse(); @@ -252,7 +252,7 @@ public class ShowActionTest { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); QualityProfiles.ShowResponse result = call(ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "true")); assertThat(result.hasCompareToSonarWay()).isFalse(); @@ -264,7 +264,7 @@ public class ShowActionTest { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); QualityProfiles.ShowResponse result = call(ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "false")); assertThat(result.hasCompareToSonarWay()).isFalse(); @@ -276,7 +276,7 @@ public class ShowActionTest { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); CompareToSonarWay result = call(ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "true")) .getCompareToSonarWay(); @@ -292,7 +292,7 @@ public class ShowActionTest { QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey())); CompareToSonarWay result = call(ws.newRequest() - .setParam(PARAM_PROFILE, profile.getKee()) + .setParam(PARAM_KEY, profile.getKee()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, "true")) .getCompareToSonarWay(); @@ -308,7 +308,7 @@ public class ShowActionTest { expectedException.expect(NotFoundException.class); expectedException.expectMessage("Quality Profile with key 'unknown-profile' does not exist"); - call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee())); + call(ws.newRequest().setParam(PARAM_KEY, profile.getKee())); } @Test @@ -316,7 +316,7 @@ public class ShowActionTest { expectedException.expect(NotFoundException.class); expectedException.expectMessage("Quality Profile with key 'unknown-profile' does not exist"); - call(ws.newRequest().setParam(PARAM_PROFILE, "unknown-profile")); + call(ws.newRequest().setParam(PARAM_KEY, "unknown-profile")); } @Test @@ -344,7 +344,7 @@ public class ShowActionTest { ws = new WsActionTester( new ShowAction(db.getDbClient(), new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db)), new Languages(cs), ruleIndex)); - String result = ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()).execute().getInput(); + String result = ws.newRequest().setParam(PARAM_KEY, profile.getKee()).execute().getInput(); assertJson(result).ignoreFields("rulesUpdatedAt", "lastUsed", "userUpdatedAt").isSimilarTo(ws.getDef().responseExampleAsString()); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java index 368f8512018..e98b2b396e2 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java @@ -27,7 +27,7 @@ import static java.util.Objects.requireNonNull; public class ActivateRuleWsRequest { private final Optional params; - private final String profileKey; + private final String key; private final Optional reset; private final String ruleKey; private final Optional severity; @@ -36,7 +36,7 @@ public class ActivateRuleWsRequest { private ActivateRuleWsRequest(Builder builder) { organization = requireNonNull(builder.organization); params = requireNonNull(builder.params); - profileKey = requireNonNull(builder.profileKey); + key = requireNonNull(builder.key); reset = requireNonNull(builder.reset); ruleKey = requireNonNull(builder.ruleKey); severity = requireNonNull(builder.severity); @@ -50,8 +50,8 @@ public class ActivateRuleWsRequest { return params; } - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } public Optional getReset() { @@ -73,7 +73,7 @@ public class ActivateRuleWsRequest { public static class Builder { private Optional organization = Optional.empty(); private Optional params = Optional.empty(); - private String profileKey; + private String key; private Optional reset = Optional.empty(); private String ruleKey; private Optional severity = Optional.empty(); @@ -91,8 +91,8 @@ public class ActivateRuleWsRequest { return this; } - public Builder setProfileKey(String profileKey) { - this.profileKey = profileKey; + public Builder setKey(String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java index 2b764d8caba..fc852433d5c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java @@ -31,16 +31,16 @@ public class AddProjectRequest { private final String language; private final Optional organization; - private final String profileName; - private final String profileKey; + private final String qualityProfile; + private final String key; private final String projectKey; private final String projectUuid; private AddProjectRequest(Builder builder) { this.language = builder.language; this.organization = requireNonNull(builder.organization); - this.profileName = builder.profileName; - this.profileKey = builder.profileKey; + this.qualityProfile = builder.qualityProfile; + this.key = builder.key; this.projectKey = builder.projectKey; this.projectUuid = builder.projectUuid; } @@ -55,13 +55,13 @@ public class AddProjectRequest { } @CheckForNull - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } @CheckForNull - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } @CheckForNull @@ -81,8 +81,8 @@ public class AddProjectRequest { public static class Builder { private String language; private Optional organization = Optional.empty(); - private String profileName; - private String profileKey; + private String qualityProfile; + private String key; private String projectKey; private String projectUuid; @@ -100,13 +100,13 @@ public class AddProjectRequest { return this; } - public Builder setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public Builder setQualityProfile(@Nullable String qualityProfile) { + this.qualityProfile = qualityProfile; return this; } - public Builder setProfileKey(@Nullable String profileKey) { - this.profileKey = profileKey; + public Builder setKey(@Nullable String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java index 1f3cc16fc9b..9b1b6a3ddca 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java @@ -25,17 +25,17 @@ import javax.annotation.Nullable; public class ChangeParentRequest { private final String language; private final String parentKey; - private final String parentName; - private final String profileKey; - private final String profileName; + private final String parentQualityProfile; + private final String key; + private final String qualityProfile; private final String organization; public ChangeParentRequest(Builder builder) { this.language = builder.language; this.parentKey = builder.parentKey; - this.parentName = builder.parentName; - this.profileKey = builder.profileKey; - this.profileName = builder.profileName; + this.parentQualityProfile = builder.parentName; + this.key = builder.profileKey; + this.qualityProfile = builder.profileName; this.organization = builder.organization; } @@ -47,16 +47,16 @@ public class ChangeParentRequest { return parentKey; } - public String getParentName() { - return parentName; + public String getParentQualityProfile() { + return parentQualityProfile; } - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } public String getOrganization() { diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java index 85319cb1c35..abf35e1c171 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java @@ -27,12 +27,12 @@ import static com.google.common.base.Preconditions.checkArgument; @Immutable public class CreateRequest { - private final String profileName; + private final String name; private final String language; private final String organizationKey; private CreateRequest(Builder builder) { - this.profileName = builder.profileName; + this.name = builder.name; this.language = builder.language; this.organizationKey = builder.organizationKey; } @@ -41,8 +41,8 @@ public class CreateRequest { return language; } - public String getProfileName() { - return profileName; + public String getName() { + return name; } public String getOrganizationKey() { @@ -55,7 +55,7 @@ public class CreateRequest { public static class Builder { private String language; - private String profileName; + private String name; private String organizationKey; private Builder() { @@ -67,8 +67,8 @@ public class CreateRequest { return this; } - public Builder setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public Builder setName(@Nullable String profileName) { + this.name = profileName; return this; } @@ -79,7 +79,7 @@ public class CreateRequest { public CreateRequest build() { checkArgument(language != null && !language.isEmpty(), "Language is mandatory and must not be empty."); - checkArgument(profileName != null && !profileName.isEmpty(), "Profile name is mandatory and must not be empty."); + checkArgument(name != null && !name.isEmpty(), "Profile name is mandatory and must not be empty."); checkArgument(organizationKey == null || !organizationKey.isEmpty(), "Organization key may be either null or not empty. Empty organization key is invalid."); return new CreateRequest(this); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java index 96b2d45c204..f4314b7a8d0 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java @@ -22,6 +22,7 @@ package org.sonarqube.ws.client.qualityprofile; public class QualityProfileWsParameters { public static final String CONTROLLER_QUALITY_PROFILES = "api/qualityprofiles"; + public interface RestoreActionParameters { String PARAM_BACKUP = "backup"; @@ -48,11 +49,10 @@ public class QualityProfileWsParameters { public static final String PARAM_LANGUAGE = "language"; public static final String PARAM_NAME = "name"; public static final String PARAM_PARAMS = "params"; - public static final String PARAM_PARENT_NAME = "parentName"; - public static final String PARAM_PARENT_PROFILE = "parentProfile"; - public static final String PARAM_PROFILE = "profile"; - public static final String PARAM_PROFILE_KEY = "profileKey"; - public static final String PARAM_PROFILE_NAME = "profileName"; + 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"; @@ -60,7 +60,7 @@ public class QualityProfileWsParameters { public static final String PARAM_RULE = "rule"; public static final String PARAM_SEVERITY = "severity"; public static final String PARAM_SINCE = "since"; - public static final String PARAM_TARGET_PROFILE = "targetProfile"; + public static final String PARAM_TARGET_KEY = "targetKey"; public static final String PARAM_TARGET_SEVERITY = "targetSeverity"; public static final String PARAM_TO = "to"; public static final String PARAM_TO_NAME = "toName"; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java index 431f310be56..ea9ad29636a 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java @@ -47,13 +47,13 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_NAME; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET; @@ -72,7 +72,7 @@ public class QualityProfilesService extends BaseService { PostRequest httpRequest = new PostRequest(path(ACTION_ACTIVATE_RULE)); httpRequest.setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null)); httpRequest.setParam(PARAM_PARAMS, request.getParams().orElse(null)); - httpRequest.setParam(PARAM_PROFILE, request.getProfileKey()); + httpRequest.setParam(PARAM_KEY, request.getKey()); httpRequest.setParam(PARAM_RESET, request.getReset().orElse(null)); httpRequest.setParam(PARAM_RULE, request.getRuleKey()); httpRequest.setParam(PARAM_SEVERITY, request.getSeverity().map(Enum::name).orElse(null)); @@ -81,7 +81,7 @@ public class QualityProfilesService extends BaseService { public void deactivateRule(String profileKey, String ruleKey) { PostRequest httpRequest = new PostRequest(path(ACTION_DEACTIVATE_RULE)); - httpRequest.setParam(PARAM_PROFILE, profileKey); + httpRequest.setParam(PARAM_KEY, profileKey); httpRequest.setParam(PARAM_RULE, ruleKey); call(httpRequest); } @@ -98,7 +98,7 @@ public class QualityProfilesService extends BaseService { new GetRequest(path(ACTION_SEARCH)) .setParam(PARAM_DEFAULTS, request.getDefaults()) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) .setParam(PARAM_ORGANIZATION, request.getOrganizationKey()), SearchWsResponse.parser()); @@ -107,7 +107,7 @@ public class QualityProfilesService extends BaseService { public QualityProfiles.ShowResponse show(ShowRequest request) { return call( new GetRequest(path(ACTION_SHOW)) - .setParam(PARAM_PROFILE, request.getProfile()) + .setParam(PARAM_KEY, request.getKey()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, request.getCompareToSonarWay()), ShowResponse.parser()); } @@ -116,8 +116,8 @@ public class QualityProfilesService extends BaseService { call(new PostRequest(path(ACTION_ADD_PROJECT)) .setParam(PARAM_LANGUAGE, request.getLanguage()) .setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null)) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) - .setParam(PARAM_PROFILE_KEY, request.getProfileKey()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) + .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()) .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) .setParam(PARAM_PROJECT_UUID, request.getProjectUuid())); } @@ -125,8 +125,8 @@ public class QualityProfilesService extends BaseService { public void removeProject(RemoveProjectRequest request) { call(new PostRequest(path(ACTION_REMOVE_PROJECT)) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) - .setParam(PARAM_PROFILE_KEY, request.getProfileKey()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) + .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()) .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) .setParam(PARAM_PROJECT_UUID, request.getProjectUuid())); } @@ -135,7 +135,7 @@ public class QualityProfilesService extends BaseService { PostRequest postRequest = new PostRequest(path(ACTION_CREATE)) .setParam(PARAM_ORGANIZATION, request.getOrganizationKey()) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()); + .setParam(PARAM_NAME, request.getName()); return call(postRequest, CreateWsResponse.parser()); } @@ -150,23 +150,23 @@ public class QualityProfilesService extends BaseService { public void changeParent(ChangeParentRequest request) { call(new PostRequest(path(ACTION_CHANGE_PARENT)) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PARENT_PROFILE, request.getParentKey()) - .setParam(PARAM_PARENT_NAME, request.getParentName()) - .setParam(PARAM_PROFILE, request.getProfileKey()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) + .setParam(PARAM_PARENT_KEY, request.getParentKey()) + .setParam(PARAM_PARENT_QUALITY_PROFILE, request.getParentQualityProfile()) + .setParam(PARAM_KEY, request.getKey()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) .setParam(PARAM_ORGANIZATION, request.getOrganization())); } public void setDefault(SetDefaultRequest request) { PostRequest postRequest = new PostRequest(path(ACTION_SET_DEFAULT)) - .setParam(PARAM_PROFILE_KEY, request.getProfileKey()); + .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()); call(postRequest); } public void delete(String profileKey) { PostRequest postRequest = new PostRequest(path(ACTION_DELETE)) - .setParam(PARAM_PROFILE_KEY, profileKey); + .setParam(QualityProfileWsParameters.PARAM_KEY, profileKey); call(postRequest); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java index f3d297c8c84..ccc35577b4b 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java @@ -27,15 +27,15 @@ import javax.annotation.concurrent.Immutable; public class RemoveProjectRequest { private final String language; - private final String profileName; - private final String profileKey; + private final String qualityProfile; + private final String key; private final String projectKey; private final String projectUuid; private RemoveProjectRequest(Builder builder) { this.language = builder.language; - this.profileName = builder.profileName; - this.profileKey = builder.profileKey; + this.qualityProfile = builder.qualityProfile; + this.key = builder.key; this.projectKey = builder.projectKey; this.projectUuid = builder.projectUuid; } @@ -46,13 +46,13 @@ public class RemoveProjectRequest { } @CheckForNull - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } @CheckForNull - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } @CheckForNull @@ -71,8 +71,8 @@ public class RemoveProjectRequest { public static class Builder { private String language; - private String profileName; - private String profileKey; + private String qualityProfile; + private String key; private String projectKey; private String projectUuid; @@ -85,13 +85,13 @@ public class RemoveProjectRequest { return this; } - public Builder setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public Builder setQualityProfile(@Nullable String qualityProfile) { + this.qualityProfile = qualityProfile; return this; } - public Builder setProfileKey(@Nullable String profileKey) { - this.profileKey = profileKey; + public Builder setKey(@Nullable String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java index 16d82999f07..7cf4b966993 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java @@ -26,7 +26,7 @@ public class SearchWsRequest { private String organizationKey; private boolean defaults; private String language; - private String profileName; + private String qualityProfile; private String projectKey; public String getOrganizationKey() { @@ -58,12 +58,12 @@ public class SearchWsRequest { } @CheckForNull - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } - public SearchWsRequest setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public SearchWsRequest setQualityProfile(@Nullable String qualityProfile) { + this.qualityProfile = qualityProfile; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java index fd11fd24e92..57a7bd419bb 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java @@ -21,13 +21,13 @@ package org.sonarqube.ws.client.qualityprofile; public class SetDefaultRequest { - private final String profileKey; + private final String key; - public SetDefaultRequest(String profileKey) { - this.profileKey = profileKey; + public SetDefaultRequest(String key) { + this.key = key; } - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java index 2cbcfe95dcd..0e267e65e16 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java @@ -24,16 +24,16 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; public class ShowRequest { - private String profile; + private String key; private Boolean compareToSonarWay; @CheckForNull - public String getProfile() { - return profile; + public String getKey() { + return key; } - public ShowRequest setProfile(@Nullable String profile) { - this.profile = profile; + public ShowRequest setKey(@Nullable String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java index cb3a52f987e..7f0fcde543f 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java @@ -34,33 +34,33 @@ public class AddProjectRequestTest { @Test public void create_request_from_profile_key_and_project_key() { - AddProjectRequest result = underTest.setProfileKey("SonarWay").setProjectKey("sample").build(); + AddProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_name_and_language_and_project_key() { - AddProjectRequest result = underTest.setLanguage("xoo").setProfileName("Sonar Way").setProjectKey("sample").build(); + AddProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build(); assertThat(result.getLanguage()).isEqualTo("xoo"); - assertThat(result.getProfileKey()).isNull(); - assertThat(result.getProfileName()).isEqualTo("Sonar Way"); + assertThat(result.getKey()).isNull(); + assertThat(result.getQualityProfile()).isEqualTo("Sonar Way"); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_key_and_project_uuid() { - AddProjectRequest result = underTest.setProfileKey("SonarWay").setProjectUuid("123").build(); + AddProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isNull(); assertThat(result.getProjectUuid()).isEqualTo("123"); } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java index ab86203518f..7aff1d888d5 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java @@ -36,17 +36,17 @@ public class CreateRequestTest { public void create_set_request() { CreateRequest result = underTest .setLanguage("java") - .setProfileName("Sonar way") + .setName("Sonar way") .build(); assertThat(result.getLanguage()).isEqualTo("java"); - assertThat(result.getProfileName()).isEqualTo("Sonar way"); + assertThat(result.getName()).isEqualTo("Sonar way"); } @Test public void fail_when_no_language() { expectedException.expect(IllegalArgumentException.class); - underTest.setProfileName("Sonar way").build(); + underTest.setName("Sonar way").build(); } @Test diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java index 1ea8262b646..a3add919ea7 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java @@ -35,11 +35,11 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY; @@ -58,7 +58,7 @@ public class QualityProfilesServiceTest { .setDefaults(true) .setProjectKey("project") .setLanguage("language") - .setProfileName("profile")); + .setQualityProfile("profile")); GetRequest getRequest = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser()); @@ -67,21 +67,21 @@ public class QualityProfilesServiceTest { .hasParam(PARAM_DEFAULTS, true) .hasParam(PARAM_PROJECT_KEY, "project") .hasParam(PARAM_LANGUAGE, "language") - .hasParam(PARAM_PROFILE_NAME, "profile") + .hasParam(PARAM_QUALITY_PROFILE, "profile") .andNoOtherParam(); } @Test public void show() { underTest.show(new ShowRequest() - .setProfile("profile") + .setKey("profile") .setCompareToSonarWay(true)); GetRequest getRequest = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(ShowResponse.parser()); serviceTester.assertThat(getRequest) .hasPath("show") - .hasParam(PARAM_PROFILE, "profile") + .hasParam(PARAM_KEY, "profile") .hasParam(PARAM_COMPARE_TO_SONAR_WAY, true) .andNoOtherParam(); } @@ -90,14 +90,14 @@ public class QualityProfilesServiceTest { public void add_project() throws Exception { underTest.addProject(AddProjectRequest.builder() .setLanguage("xoo") - .setProfileName("Sonar Way") + .setQualityProfile("Sonar Way") .setProjectKey("sample") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("add_project") .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_PROFILE_NAME, "Sonar Way") + .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way") .hasParam(PARAM_PROJECT_KEY, "sample") .andNoOtherParam(); } @@ -106,14 +106,14 @@ public class QualityProfilesServiceTest { public void remove_project() throws Exception { underTest.removeProject(RemoveProjectRequest.builder() .setLanguage("xoo") - .setProfileName("Sonar Way") + .setQualityProfile("Sonar Way") .setProjectKey("sample") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("remove_project") .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_PROFILE_NAME, "Sonar Way") + .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way") .hasParam(PARAM_PROJECT_KEY, "sample") .andNoOtherParam(); } @@ -122,13 +122,13 @@ public class QualityProfilesServiceTest { public void create() throws Exception { underTest.create(CreateRequest.builder() .setLanguage("xoo") - .setProfileName("Sonar Way") + .setName("Sonar Way") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("create") .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_PROFILE_NAME, "Sonar Way") + .hasParam(PARAM_NAME, "Sonar Way") .andNoOtherParam(); } @@ -149,7 +149,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("set_default") - .hasParam(PARAM_PROFILE_KEY, "sample") + .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample") .andNoOtherParam(); } @@ -159,7 +159,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("delete") - .hasParam(PARAM_PROFILE_KEY, "sample") + .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample") .andNoOtherParam(); } @@ -170,7 +170,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(request) .hasPath("deactivate_rule") - .hasParam(PARAM_PROFILE, "P1") + .hasParam(PARAM_KEY, "P1") .hasParam(PARAM_RULE, "R1") .andNoOtherParam(); } @@ -179,7 +179,7 @@ public class QualityProfilesServiceTest { public void activate_rule() { underTest.activateRule(ActivateRuleWsRequest.builder() .setRuleKey("R1") - .setProfileKey("P1") + .setKey("P1") .setOrganization("O1") .setParams("PS1") .setSeverity(Severity.INFO) @@ -188,7 +188,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(request) .hasPath("activate_rule") - .hasParam(PARAM_PROFILE, "P1") + .hasParam(PARAM_KEY, "P1") .hasParam(PARAM_RULE, "R1") .hasParam(PARAM_ORGANIZATION, "O1") .hasParam(PARAM_PARAMS, "PS1") diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java index b169d375d88..e6735e2e271 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java @@ -34,33 +34,33 @@ public class RemoveProjectRequestTest { @Test public void create_request_from_profile_key_and_project_key() { - RemoveProjectRequest result = underTest.setProfileKey("SonarWay").setProjectKey("sample").build(); + RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_name_and_language_and_project_key() { - RemoveProjectRequest result = underTest.setLanguage("xoo").setProfileName("Sonar Way").setProjectKey("sample").build(); + RemoveProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build(); assertThat(result.getLanguage()).isEqualTo("xoo"); - assertThat(result.getProfileKey()).isNull(); - assertThat(result.getProfileName()).isEqualTo("Sonar Way"); + assertThat(result.getKey()).isNull(); + assertThat(result.getQualityProfile()).isEqualTo("Sonar Way"); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_key_and_project_uuid() { - RemoveProjectRequest result = underTest.setProfileKey("SonarWay").setProjectUuid("123").build(); + RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isNull(); assertThat(result.getProjectUuid()).isEqualTo("123"); } diff --git a/tests/src/test/java/org/sonarqube/tests/QProfileTester.java b/tests/src/test/java/org/sonarqube/tests/QProfileTester.java index c2d163151c6..29656d65c95 100644 --- a/tests/src/test/java/org/sonarqube/tests/QProfileTester.java +++ b/tests/src/test/java/org/sonarqube/tests/QProfileTester.java @@ -58,7 +58,7 @@ public class QProfileTester { CreateRequest.Builder request = CreateRequest.builder() .setOrganizationKey(organization.getKey()) .setLanguage("xoo") - .setProfileName("Profile" + id); + .setName("Profile" + id); stream(populators).forEach(p -> p.accept(request)); return service().create(request.build()).getProfile(); } @@ -69,7 +69,7 @@ public class QProfileTester { public QProfileTester activateRule(String profileKey, String ruleKey) { ActivateRuleWsRequest request = ActivateRuleWsRequest.builder() - .setProfileKey(profileKey) + .setKey(profileKey) .setRuleKey(ruleKey) .build(); service().activateRule(request); @@ -84,7 +84,7 @@ public class QProfileTester { public QProfileTester assignQProfileToProject(QualityProfile profile, Project project) { service().addProject(AddProjectRequest.builder() .setProjectKey(project.getKey()) - .setProfileKey(profile.getKey()) + .setKey(profile.getKey()) .build()); return this; } diff --git a/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java index 6983a6757a3..11fe9c49637 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java @@ -60,7 +60,7 @@ public class QualityProfileAdminPermissionTest { private void createProfile(String language, String name) { tester.wsClient().qualityProfiles().create(CreateRequest.builder() .setLanguage(language) - .setProfileName(name) + .setName(name) .build()); } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java index 436e466454d..683b808fbbe 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java @@ -209,7 +209,7 @@ public class OrganizationIssueAssignTest { .setProjectKey(projectKey) .setOrganization(organization) .setLanguage("xoo") - .setProfileName("one-issue-per-file-profile") + .setQualityProfile("one-issue-per-file-profile") .build()); } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java index 8593dc17a08..2ab31f1f1de 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java @@ -110,7 +110,7 @@ public class BuiltInQualityProfilesNotificationTest { WsUsers.CreateWsResponse.User noProfileAdmin = userRule.generate(); // Create a child profile on the built-in profile => The notification should not take into account updates of this profile - wsClient.qualityProfiles().create(CreateRequest.builder().setLanguage("foo").setProfileName("child").build()); + wsClient.qualityProfiles().create(CreateRequest.builder().setLanguage("foo").setName("child").build()); wsClient.qualityProfiles().changeParent(ChangeParentRequest.builder().setProfileName("child").setParentName("Basic").setLanguage("foo").build()); // uninstall plugin V1 diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java index 0be4b07d90f..76d707b38c6 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java @@ -65,8 +65,8 @@ public class CustomQualityProfilesTest { // create two profiles with same names in two organizations Organization org1 = tester.organizations().generate(); Organization org2 = tester.organizations().generate(); - QualityProfile profileInOrg1 = tester.qProfiles().createXooProfile(org1, p -> p.setProfileName("foo")); - QualityProfile profileInOrg2 = tester.qProfiles().createXooProfile(org2, p -> p.setProfileName("foo")); + QualityProfile profileInOrg1 = tester.qProfiles().createXooProfile(org1, p -> p.setName("foo")); + QualityProfile profileInOrg2 = tester.qProfiles().createXooProfile(org2, p -> p.setName("foo")); tester.qProfiles() .assertThatNumberOfActiveRulesEqualsTo(profileInOrg1, 0) @@ -133,7 +133,7 @@ public class CustomQualityProfilesTest { CreateRequest.builder() .setLanguage(parentProfile.getLanguage()) .setOrganizationKey(org.getKey()) - .setProfileName("inherited_profile") + .setName("inherited_profile") .build()) .getProfile(); @@ -145,7 +145,7 @@ public class CustomQualityProfilesTest { CreateRequest.builder() .setLanguage(parentProfile.getLanguage()) .setOrganizationKey(org.getKey()) - .setProfileName("inherited_profile2") + .setName("inherited_profile2") .build()) .getProfile(); @@ -223,7 +223,7 @@ public class CustomQualityProfilesTest { CreateRequest.builder() .setLanguage(parentProfile.getLanguage()) .setOrganizationKey(org.getKey()) - .setProfileName("inherited_profile") + .setName("inherited_profile") .build()) .getProfile(); @@ -295,7 +295,7 @@ public class CustomQualityProfilesTest { .setParam("organization", org.getKey())); adminSession.qProfiles().service().addProject(AddProjectRequest.builder() - .setProfileKey(newXooProfile.getKey()) + .setKey(newXooProfile.getKey()) .setProjectKey(projectKey) .build()); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java index ad75bcdf9d9..1414b129683 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java @@ -188,7 +188,7 @@ public class OrganizationQualityProfilesUiTest { private void addProfileToProject(String language, String profileName, String projectKey) { tester.wsClient().qualityProfiles().addProject(AddProjectRequest.builder() .setLanguage(language) - .setProfileName(profileName) + .setQualityProfile(profileName) .setProjectKey(projectKey) .setOrganization(organization.getKey()) .build()); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java index a1583020954..f67a20b0acd 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java @@ -153,7 +153,7 @@ public class QualityProfilesUiTest { private void createProfile(String language, String name) { tester.wsClient().qualityProfiles().create(CreateRequest.builder() .setLanguage(language) - .setProfileName(name) + .setName(name) .build()); } @@ -172,7 +172,7 @@ public class QualityProfilesUiTest { private void addProfileToProject(String language, String profileName, String projectKey) { tester.wsClient().qualityProfiles().addProject(AddProjectRequest.builder() .setLanguage(language) - .setProfileName(profileName) + .setQualityProfile(profileName) .setProjectKey(projectKey) .build()); } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java index 9abacf1bf29..6047ae1230d 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java @@ -57,7 +57,7 @@ public class QualityProfilesWsTest { tester.qProfiles().activateRule(xooProfile, RULE_ONE_BUG_PER_LINE); tester.qProfiles().activateRule(xooProfile, RULE_ONE_ISSUE_PER_LINE); - ShowResponse result = tester.qProfiles().service().show(new ShowRequest().setProfile(xooProfile.getKey())); + ShowResponse result = tester.qProfiles().service().show(new ShowRequest().setKey(xooProfile.getKey())); assertThat(result.getProfile()) .extracting(QualityProfile::getName, QualityProfile::getLanguage, QualityProfile::getIsBuiltIn, QualityProfile::getIsDefault, @@ -74,7 +74,7 @@ public class QualityProfilesWsTest { SearchWsResponse.QualityProfile sonarWay = getProfile(org, p -> "Sonar way".equals(p.getName()) && "xoo".equals(p.getLanguage()) && p.getIsBuiltIn()); CompareToSonarWay result = tester.qProfiles().service().show(new ShowRequest() - .setProfile(xooProfile.getKey()) + .setKey(xooProfile.getKey()) .setCompareToSonarWay(true)).getCompareToSonarWay(); assertThat(result) @@ -92,14 +92,14 @@ public class QualityProfilesWsTest { // Bulk activate missing rules from the Sonar way profile tester.wsClient().wsConnector().call(new PostRequest("api/qualityprofiles/activate_rules") - .setParam("targetProfile", xooProfile.getKey()) + .setParam("targetKey", xooProfile.getKey()) .setParam("qprofile", xooProfile.getKey()) .setParam("activation", "false") .setParam("compareToProfile", sonarWay.getKey())).failIfNotSuccessful(); // Check that the profile has no missing rule from the Sonar way profile assertThat(tester.qProfiles().service().show(new ShowRequest() - .setProfile(xooProfile.getKey()) + .setKey(xooProfile.getKey()) .setCompareToSonarWay(true)).getCompareToSonarWay()) .extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount) .containsExactly(sonarWay.getKey(), sonarWay.getName(), 0L); @@ -113,7 +113,9 @@ public class QualityProfilesWsTest { assertThat(response.content()).isEqualTo("xoo -> Basic -> 1"); // Check 'name' parameter is taken into account - assertThat(tester.wsClient().wsConnector().call(new GetRequest("profiles/export?language=xoo&name=empty&format=XooFakeExporter")).content()).isEqualTo("xoo -> empty -> 0"); + assertThat(tester.wsClient().wsConnector() + .call(new GetRequest("profiles/export?language=xoo&qualityProfile=empty&format=XooFakeExporter")).content()) + .isEqualTo("xoo -> empty -> 0"); } private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate filter) { -- 2.39.5