diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2017-09-22 18:52:19 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk@users.noreply.github.com> | 2017-09-26 11:15:35 +0200 |
commit | 184dbe792ce14f192f75b13507c30a4b697d5852 (patch) | |
tree | 79ad219937ecb586c156b34f8302eadfbcd324e4 /server | |
parent | 2310482d4297e8e8e051691a21e8c6add5fd25ff (diff) | |
download | sonarqube-184dbe792ce14f192f75b13507c30a4b697d5852.tar.gz sonarqube-184dbe792ce14f192f75b13507c30a4b697d5852.zip |
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
Diffstat (limited to 'server')
34 files changed, 307 insertions, 313 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 <code>api/qualityprofiles/search</code>") .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 <code>api/qualityprofiles/search</code>") + activate.createParam(PARAM_TARGET_KEY) + .setDescription("Quality Profile key on which the rule activation is done. To retrieve a quality profile key please see <code>api/qualityprofiles/search</code>") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) .setExampleValue(UUID_EXAMPLE_03); @@ -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.<br> " + "If no profile is provided, the inheritance link with current parent profile (if any) is broken, which deactivates all rules " + "which come from the parent and are not overridden.") - .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 <code>api/qualityprofiles/search</code>") .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 <code>api/qualityprofiles/search</code>") .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<QProfileDto> 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<QProfileDto> 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<QProfileDto> 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<ChangelogLoader.Change> 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<ChangelogLoader.Change> 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()); } |