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 /sonar-ws | |
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 'sonar-ws')
14 files changed, 135 insertions, 135 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java index 368f8512018..e98b2b396e2 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleWsRequest.java @@ -27,7 +27,7 @@ import static java.util.Objects.requireNonNull; public class ActivateRuleWsRequest { private final Optional<String> params; - private final String profileKey; + private final String key; private final Optional<Boolean> reset; private final String ruleKey; private final Optional<Severity> severity; @@ -36,7 +36,7 @@ public class ActivateRuleWsRequest { private ActivateRuleWsRequest(Builder builder) { organization = requireNonNull(builder.organization); params = requireNonNull(builder.params); - profileKey = requireNonNull(builder.profileKey); + key = requireNonNull(builder.key); reset = requireNonNull(builder.reset); ruleKey = requireNonNull(builder.ruleKey); severity = requireNonNull(builder.severity); @@ -50,8 +50,8 @@ public class ActivateRuleWsRequest { return params; } - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } public Optional<Boolean> getReset() { @@ -73,7 +73,7 @@ public class ActivateRuleWsRequest { public static class Builder { private Optional<String> organization = Optional.empty(); private Optional<String> params = Optional.empty(); - private String profileKey; + private String key; private Optional<Boolean> reset = Optional.empty(); private String ruleKey; private Optional<Severity> severity = Optional.empty(); @@ -91,8 +91,8 @@ public class ActivateRuleWsRequest { return this; } - public Builder setProfileKey(String profileKey) { - this.profileKey = profileKey; + public Builder setKey(String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java index 2b764d8caba..fc852433d5c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java @@ -31,16 +31,16 @@ public class AddProjectRequest { private final String language; private final Optional<String> organization; - private final String profileName; - private final String profileKey; + private final String qualityProfile; + private final String key; private final String projectKey; private final String projectUuid; private AddProjectRequest(Builder builder) { this.language = builder.language; this.organization = requireNonNull(builder.organization); - this.profileName = builder.profileName; - this.profileKey = builder.profileKey; + this.qualityProfile = builder.qualityProfile; + this.key = builder.key; this.projectKey = builder.projectKey; this.projectUuid = builder.projectUuid; } @@ -55,13 +55,13 @@ public class AddProjectRequest { } @CheckForNull - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } @CheckForNull - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } @CheckForNull @@ -81,8 +81,8 @@ public class AddProjectRequest { public static class Builder { private String language; private Optional<String> organization = Optional.empty(); - private String profileName; - private String profileKey; + private String qualityProfile; + private String key; private String projectKey; private String projectUuid; @@ -100,13 +100,13 @@ public class AddProjectRequest { return this; } - public Builder setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public Builder setQualityProfile(@Nullable String qualityProfile) { + this.qualityProfile = qualityProfile; return this; } - public Builder setProfileKey(@Nullable String profileKey) { - this.profileKey = profileKey; + public Builder setKey(@Nullable String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java index 1f3cc16fc9b..9b1b6a3ddca 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java @@ -25,17 +25,17 @@ import javax.annotation.Nullable; public class ChangeParentRequest { private final String language; private final String parentKey; - private final String parentName; - private final String profileKey; - private final String profileName; + private final String parentQualityProfile; + private final String key; + private final String qualityProfile; private final String organization; public ChangeParentRequest(Builder builder) { this.language = builder.language; this.parentKey = builder.parentKey; - this.parentName = builder.parentName; - this.profileKey = builder.profileKey; - this.profileName = builder.profileName; + this.parentQualityProfile = builder.parentName; + this.key = builder.profileKey; + this.qualityProfile = builder.profileName; this.organization = builder.organization; } @@ -47,16 +47,16 @@ public class ChangeParentRequest { return parentKey; } - public String getParentName() { - return parentName; + public String getParentQualityProfile() { + return parentQualityProfile; } - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } public String getOrganization() { diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java index 85319cb1c35..abf35e1c171 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java @@ -27,12 +27,12 @@ import static com.google.common.base.Preconditions.checkArgument; @Immutable public class CreateRequest { - private final String profileName; + private final String name; private final String language; private final String organizationKey; private CreateRequest(Builder builder) { - this.profileName = builder.profileName; + this.name = builder.name; this.language = builder.language; this.organizationKey = builder.organizationKey; } @@ -41,8 +41,8 @@ public class CreateRequest { return language; } - public String getProfileName() { - return profileName; + public String getName() { + return name; } public String getOrganizationKey() { @@ -55,7 +55,7 @@ public class CreateRequest { public static class Builder { private String language; - private String profileName; + private String name; private String organizationKey; private Builder() { @@ -67,8 +67,8 @@ public class CreateRequest { return this; } - public Builder setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public Builder setName(@Nullable String profileName) { + this.name = profileName; return this; } @@ -79,7 +79,7 @@ public class CreateRequest { public CreateRequest build() { checkArgument(language != null && !language.isEmpty(), "Language is mandatory and must not be empty."); - checkArgument(profileName != null && !profileName.isEmpty(), "Profile name is mandatory and must not be empty."); + checkArgument(name != null && !name.isEmpty(), "Profile name is mandatory and must not be empty."); checkArgument(organizationKey == null || !organizationKey.isEmpty(), "Organization key may be either null or not empty. Empty organization key is invalid."); return new CreateRequest(this); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java index 96b2d45c204..f4314b7a8d0 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java @@ -22,6 +22,7 @@ package org.sonarqube.ws.client.qualityprofile; public class QualityProfileWsParameters { public static final String CONTROLLER_QUALITY_PROFILES = "api/qualityprofiles"; + public interface RestoreActionParameters { String PARAM_BACKUP = "backup"; @@ -48,11 +49,10 @@ public class QualityProfileWsParameters { public static final String PARAM_LANGUAGE = "language"; public static final String PARAM_NAME = "name"; public static final String PARAM_PARAMS = "params"; - public static final String PARAM_PARENT_NAME = "parentName"; - public static final String PARAM_PARENT_PROFILE = "parentProfile"; - public static final String PARAM_PROFILE = "profile"; - public static final String PARAM_PROFILE_KEY = "profileKey"; - public static final String PARAM_PROFILE_NAME = "profileName"; + public static final String PARAM_PARENT_KEY = "parentKey"; + public static final String PARAM_PARENT_QUALITY_PROFILE = "parentQualityProfile"; + public static final String PARAM_KEY = "key"; + public static final String PARAM_QUALITY_PROFILE = "qualityProfile"; public static final String PARAM_PROJECT = "project"; public static final String PARAM_PROJECT_KEY = "projectKey"; public static final String PARAM_PROJECT_UUID = "projectUuid"; @@ -60,7 +60,7 @@ public class QualityProfileWsParameters { public static final String PARAM_RULE = "rule"; public static final String PARAM_SEVERITY = "severity"; public static final String PARAM_SINCE = "since"; - public static final String PARAM_TARGET_PROFILE = "targetProfile"; + public static final String PARAM_TARGET_KEY = "targetKey"; public static final String PARAM_TARGET_SEVERITY = "targetSeverity"; public static final String PARAM_TO = "to"; public static final String PARAM_TO_NAME = "toName"; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java index 431f310be56..ea9ad29636a 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java @@ -47,13 +47,13 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_NAME; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET; @@ -72,7 +72,7 @@ public class QualityProfilesService extends BaseService { PostRequest httpRequest = new PostRequest(path(ACTION_ACTIVATE_RULE)); httpRequest.setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null)); httpRequest.setParam(PARAM_PARAMS, request.getParams().orElse(null)); - httpRequest.setParam(PARAM_PROFILE, request.getProfileKey()); + httpRequest.setParam(PARAM_KEY, request.getKey()); httpRequest.setParam(PARAM_RESET, request.getReset().orElse(null)); httpRequest.setParam(PARAM_RULE, request.getRuleKey()); httpRequest.setParam(PARAM_SEVERITY, request.getSeverity().map(Enum::name).orElse(null)); @@ -81,7 +81,7 @@ public class QualityProfilesService extends BaseService { public void deactivateRule(String profileKey, String ruleKey) { PostRequest httpRequest = new PostRequest(path(ACTION_DEACTIVATE_RULE)); - httpRequest.setParam(PARAM_PROFILE, profileKey); + httpRequest.setParam(PARAM_KEY, profileKey); httpRequest.setParam(PARAM_RULE, ruleKey); call(httpRequest); } @@ -98,7 +98,7 @@ public class QualityProfilesService extends BaseService { new GetRequest(path(ACTION_SEARCH)) .setParam(PARAM_DEFAULTS, request.getDefaults()) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) .setParam(PARAM_ORGANIZATION, request.getOrganizationKey()), SearchWsResponse.parser()); @@ -107,7 +107,7 @@ public class QualityProfilesService extends BaseService { public QualityProfiles.ShowResponse show(ShowRequest request) { return call( new GetRequest(path(ACTION_SHOW)) - .setParam(PARAM_PROFILE, request.getProfile()) + .setParam(PARAM_KEY, request.getKey()) .setParam(PARAM_COMPARE_TO_SONAR_WAY, request.getCompareToSonarWay()), ShowResponse.parser()); } @@ -116,8 +116,8 @@ public class QualityProfilesService extends BaseService { call(new PostRequest(path(ACTION_ADD_PROJECT)) .setParam(PARAM_LANGUAGE, request.getLanguage()) .setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null)) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) - .setParam(PARAM_PROFILE_KEY, request.getProfileKey()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) + .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()) .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) .setParam(PARAM_PROJECT_UUID, request.getProjectUuid())); } @@ -125,8 +125,8 @@ public class QualityProfilesService extends BaseService { public void removeProject(RemoveProjectRequest request) { call(new PostRequest(path(ACTION_REMOVE_PROJECT)) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) - .setParam(PARAM_PROFILE_KEY, request.getProfileKey()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) + .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()) .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) .setParam(PARAM_PROJECT_UUID, request.getProjectUuid())); } @@ -135,7 +135,7 @@ public class QualityProfilesService extends BaseService { PostRequest postRequest = new PostRequest(path(ACTION_CREATE)) .setParam(PARAM_ORGANIZATION, request.getOrganizationKey()) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()); + .setParam(PARAM_NAME, request.getName()); return call(postRequest, CreateWsResponse.parser()); } @@ -150,23 +150,23 @@ public class QualityProfilesService extends BaseService { public void changeParent(ChangeParentRequest request) { call(new PostRequest(path(ACTION_CHANGE_PARENT)) .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PARENT_PROFILE, request.getParentKey()) - .setParam(PARAM_PARENT_NAME, request.getParentName()) - .setParam(PARAM_PROFILE, request.getProfileKey()) - .setParam(PARAM_PROFILE_NAME, request.getProfileName()) + .setParam(PARAM_PARENT_KEY, request.getParentKey()) + .setParam(PARAM_PARENT_QUALITY_PROFILE, request.getParentQualityProfile()) + .setParam(PARAM_KEY, request.getKey()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) .setParam(PARAM_ORGANIZATION, request.getOrganization())); } public void setDefault(SetDefaultRequest request) { PostRequest postRequest = new PostRequest(path(ACTION_SET_DEFAULT)) - .setParam(PARAM_PROFILE_KEY, request.getProfileKey()); + .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()); call(postRequest); } public void delete(String profileKey) { PostRequest postRequest = new PostRequest(path(ACTION_DELETE)) - .setParam(PARAM_PROFILE_KEY, profileKey); + .setParam(QualityProfileWsParameters.PARAM_KEY, profileKey); call(postRequest); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java index f3d297c8c84..ccc35577b4b 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java @@ -27,15 +27,15 @@ import javax.annotation.concurrent.Immutable; public class RemoveProjectRequest { private final String language; - private final String profileName; - private final String profileKey; + private final String qualityProfile; + private final String key; private final String projectKey; private final String projectUuid; private RemoveProjectRequest(Builder builder) { this.language = builder.language; - this.profileName = builder.profileName; - this.profileKey = builder.profileKey; + this.qualityProfile = builder.qualityProfile; + this.key = builder.key; this.projectKey = builder.projectKey; this.projectUuid = builder.projectUuid; } @@ -46,13 +46,13 @@ public class RemoveProjectRequest { } @CheckForNull - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } @CheckForNull - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } @CheckForNull @@ -71,8 +71,8 @@ public class RemoveProjectRequest { public static class Builder { private String language; - private String profileName; - private String profileKey; + private String qualityProfile; + private String key; private String projectKey; private String projectUuid; @@ -85,13 +85,13 @@ public class RemoveProjectRequest { return this; } - public Builder setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public Builder setQualityProfile(@Nullable String qualityProfile) { + this.qualityProfile = qualityProfile; return this; } - public Builder setProfileKey(@Nullable String profileKey) { - this.profileKey = profileKey; + public Builder setKey(@Nullable String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java index 16d82999f07..7cf4b966993 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchWsRequest.java @@ -26,7 +26,7 @@ public class SearchWsRequest { private String organizationKey; private boolean defaults; private String language; - private String profileName; + private String qualityProfile; private String projectKey; public String getOrganizationKey() { @@ -58,12 +58,12 @@ public class SearchWsRequest { } @CheckForNull - public String getProfileName() { - return profileName; + public String getQualityProfile() { + return qualityProfile; } - public SearchWsRequest setProfileName(@Nullable String profileName) { - this.profileName = profileName; + public SearchWsRequest setQualityProfile(@Nullable String qualityProfile) { + this.qualityProfile = qualityProfile; return this; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java index fd11fd24e92..57a7bd419bb 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java @@ -21,13 +21,13 @@ package org.sonarqube.ws.client.qualityprofile; public class SetDefaultRequest { - private final String profileKey; + private final String key; - public SetDefaultRequest(String profileKey) { - this.profileKey = profileKey; + public SetDefaultRequest(String key) { + this.key = key; } - public String getProfileKey() { - return profileKey; + public String getKey() { + return key; } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java index 2cbcfe95dcd..0e267e65e16 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java @@ -24,16 +24,16 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; public class ShowRequest { - private String profile; + private String key; private Boolean compareToSonarWay; @CheckForNull - public String getProfile() { - return profile; + public String getKey() { + return key; } - public ShowRequest setProfile(@Nullable String profile) { - this.profile = profile; + public ShowRequest setKey(@Nullable String key) { + this.key = key; return this; } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java index cb3a52f987e..7f0fcde543f 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java @@ -34,33 +34,33 @@ public class AddProjectRequestTest { @Test public void create_request_from_profile_key_and_project_key() { - AddProjectRequest result = underTest.setProfileKey("SonarWay").setProjectKey("sample").build(); + AddProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_name_and_language_and_project_key() { - AddProjectRequest result = underTest.setLanguage("xoo").setProfileName("Sonar Way").setProjectKey("sample").build(); + AddProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build(); assertThat(result.getLanguage()).isEqualTo("xoo"); - assertThat(result.getProfileKey()).isNull(); - assertThat(result.getProfileName()).isEqualTo("Sonar Way"); + assertThat(result.getKey()).isNull(); + assertThat(result.getQualityProfile()).isEqualTo("Sonar Way"); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_key_and_project_uuid() { - AddProjectRequest result = underTest.setProfileKey("SonarWay").setProjectUuid("123").build(); + AddProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isNull(); assertThat(result.getProjectUuid()).isEqualTo("123"); } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java index ab86203518f..7aff1d888d5 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java @@ -36,17 +36,17 @@ public class CreateRequestTest { public void create_set_request() { CreateRequest result = underTest .setLanguage("java") - .setProfileName("Sonar way") + .setName("Sonar way") .build(); assertThat(result.getLanguage()).isEqualTo("java"); - assertThat(result.getProfileName()).isEqualTo("Sonar way"); + assertThat(result.getName()).isEqualTo("Sonar way"); } @Test public void fail_when_no_language() { expectedException.expect(IllegalArgumentException.class); - underTest.setProfileName("Sonar way").build(); + underTest.setName("Sonar way").build(); } @Test diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java index 1ea8262b646..a3add919ea7 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java @@ -35,11 +35,11 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY; @@ -58,7 +58,7 @@ public class QualityProfilesServiceTest { .setDefaults(true) .setProjectKey("project") .setLanguage("language") - .setProfileName("profile")); + .setQualityProfile("profile")); GetRequest getRequest = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser()); @@ -67,21 +67,21 @@ public class QualityProfilesServiceTest { .hasParam(PARAM_DEFAULTS, true) .hasParam(PARAM_PROJECT_KEY, "project") .hasParam(PARAM_LANGUAGE, "language") - .hasParam(PARAM_PROFILE_NAME, "profile") + .hasParam(PARAM_QUALITY_PROFILE, "profile") .andNoOtherParam(); } @Test public void show() { underTest.show(new ShowRequest() - .setProfile("profile") + .setKey("profile") .setCompareToSonarWay(true)); GetRequest getRequest = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(ShowResponse.parser()); serviceTester.assertThat(getRequest) .hasPath("show") - .hasParam(PARAM_PROFILE, "profile") + .hasParam(PARAM_KEY, "profile") .hasParam(PARAM_COMPARE_TO_SONAR_WAY, true) .andNoOtherParam(); } @@ -90,14 +90,14 @@ public class QualityProfilesServiceTest { public void add_project() throws Exception { underTest.addProject(AddProjectRequest.builder() .setLanguage("xoo") - .setProfileName("Sonar Way") + .setQualityProfile("Sonar Way") .setProjectKey("sample") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("add_project") .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_PROFILE_NAME, "Sonar Way") + .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way") .hasParam(PARAM_PROJECT_KEY, "sample") .andNoOtherParam(); } @@ -106,14 +106,14 @@ public class QualityProfilesServiceTest { public void remove_project() throws Exception { underTest.removeProject(RemoveProjectRequest.builder() .setLanguage("xoo") - .setProfileName("Sonar Way") + .setQualityProfile("Sonar Way") .setProjectKey("sample") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("remove_project") .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_PROFILE_NAME, "Sonar Way") + .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way") .hasParam(PARAM_PROJECT_KEY, "sample") .andNoOtherParam(); } @@ -122,13 +122,13 @@ public class QualityProfilesServiceTest { public void create() throws Exception { underTest.create(CreateRequest.builder() .setLanguage("xoo") - .setProfileName("Sonar Way") + .setName("Sonar Way") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("create") .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_PROFILE_NAME, "Sonar Way") + .hasParam(PARAM_NAME, "Sonar Way") .andNoOtherParam(); } @@ -149,7 +149,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("set_default") - .hasParam(PARAM_PROFILE_KEY, "sample") + .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample") .andNoOtherParam(); } @@ -159,7 +159,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(serviceTester.getPostRequest()) .hasPath("delete") - .hasParam(PARAM_PROFILE_KEY, "sample") + .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample") .andNoOtherParam(); } @@ -170,7 +170,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(request) .hasPath("deactivate_rule") - .hasParam(PARAM_PROFILE, "P1") + .hasParam(PARAM_KEY, "P1") .hasParam(PARAM_RULE, "R1") .andNoOtherParam(); } @@ -179,7 +179,7 @@ public class QualityProfilesServiceTest { public void activate_rule() { underTest.activateRule(ActivateRuleWsRequest.builder() .setRuleKey("R1") - .setProfileKey("P1") + .setKey("P1") .setOrganization("O1") .setParams("PS1") .setSeverity(Severity.INFO) @@ -188,7 +188,7 @@ public class QualityProfilesServiceTest { serviceTester.assertThat(request) .hasPath("activate_rule") - .hasParam(PARAM_PROFILE, "P1") + .hasParam(PARAM_KEY, "P1") .hasParam(PARAM_RULE, "R1") .hasParam(PARAM_ORGANIZATION, "O1") .hasParam(PARAM_PARAMS, "PS1") diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java index b169d375d88..e6735e2e271 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java @@ -34,33 +34,33 @@ public class RemoveProjectRequestTest { @Test public void create_request_from_profile_key_and_project_key() { - RemoveProjectRequest result = underTest.setProfileKey("SonarWay").setProjectKey("sample").build(); + RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_name_and_language_and_project_key() { - RemoveProjectRequest result = underTest.setLanguage("xoo").setProfileName("Sonar Way").setProjectKey("sample").build(); + RemoveProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build(); assertThat(result.getLanguage()).isEqualTo("xoo"); - assertThat(result.getProfileKey()).isNull(); - assertThat(result.getProfileName()).isEqualTo("Sonar Way"); + assertThat(result.getKey()).isNull(); + assertThat(result.getQualityProfile()).isEqualTo("Sonar Way"); assertThat(result.getProjectKey()).isEqualTo("sample"); assertThat(result.getProjectUuid()).isNull(); } @Test public void create_request_from_profile_key_and_project_uuid() { - RemoveProjectRequest result = underTest.setProfileKey("SonarWay").setProjectUuid("123").build(); + RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build(); assertThat(result.getLanguage()).isNull(); - assertThat(result.getProfileKey()).isEqualTo("SonarWay"); - assertThat(result.getProfileName()).isNull(); + assertThat(result.getKey()).isEqualTo("SonarWay"); + assertThat(result.getQualityProfile()).isNull(); assertThat(result.getProjectKey()).isNull(); assertThat(result.getProjectUuid()).isEqualTo("123"); } |