aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src/test/java
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-09-22 18:52:19 +0200
committerTeryk Bellahsene <teryk@users.noreply.github.com>2017-09-26 11:15:35 +0200
commit184dbe792ce14f192f75b13507c30a4b697d5852 (patch)
tree79ad219937ecb586c156b34f8302eadfbcd324e4 /sonar-ws/src/test/java
parent2310482d4297e8e8e051691a21e8c6add5fd25ff (diff)
downloadsonarqube-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/src/test/java')
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java18
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java6
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java36
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java18
4 files changed, 39 insertions, 39 deletions
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");
}