diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2017-06-29 15:16:16 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-07-04 16:29:36 +0200 |
commit | 82e6624f67a8cb93aea2a2517db879801b8e9346 (patch) | |
tree | f9fdec89dc3837d47b9741f81b8c8136a9dd9b9f /sonar-ws/src | |
parent | a756c3bc2cd74b77ec0ae9c7e0401932c408c7bb (diff) | |
download | sonarqube-82e6624f67a8cb93aea2a2517db879801b8e9346.tar.gz sonarqube-82e6624f67a8cb93aea2a2517db879801b8e9346.zip |
SONAR-9482 Add WS client for api/qualityprofiles/show
Diffstat (limited to 'sonar-ws/src')
5 files changed, 82 insertions, 3 deletions
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 f52962bee5c..96b2d45c204 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 @@ -39,6 +39,7 @@ public class QualityProfileWsParameters { public static final String ACTION_REMOVE_PROJECT = "remove_project"; public static final String ACTION_RESTORE = "restore"; public static final String ACTION_SEARCH = "search"; + public static final String ACTION_SHOW = "show"; public static final String ACTION_SET_DEFAULT = "set_default"; public static final String PARAM_DEFAULTS = "defaults"; 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 46e327963ee..431f310be56 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 @@ -20,9 +20,11 @@ package org.sonarqube.ws.client.qualityprofile; import org.sonarqube.ws.MediaTypes; +import org.sonarqube.ws.QualityProfiles; import org.sonarqube.ws.QualityProfiles.CopyWsResponse; import org.sonarqube.ws.QualityProfiles.CreateWsResponse; import org.sonarqube.ws.QualityProfiles.SearchWsResponse; +import org.sonarqube.ws.QualityProfiles.ShowResponse; import org.sonarqube.ws.client.BaseService; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; @@ -39,7 +41,9 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_RESTORE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SET_DEFAULT; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SHOW; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.CONTROLLER_QUALITY_PROFILES; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY; 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; @@ -100,6 +104,14 @@ public class QualityProfilesService extends BaseService { SearchWsResponse.parser()); } + public QualityProfiles.ShowResponse show(ShowRequest request) { + return call( + new GetRequest(path(ACTION_SHOW)) + .setParam(PARAM_PROFILE, request.getProfile()) + .setParam(PARAM_COMPARE_TO_SONAR_WAY, request.getCompareToSonarWay()), + ShowResponse.parser()); + } + public void addProject(AddProjectRequest request) { call(new PostRequest(path(ACTION_ADD_PROJECT)) .setParam(PARAM_LANGUAGE, request.getLanguage()) 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 new file mode 100644 index 00000000000..2cbcfe95dcd --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonarqube.ws.client.qualityprofile; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +public class ShowRequest { + private String profile; + private Boolean compareToSonarWay; + + @CheckForNull + public String getProfile() { + return profile; + } + + public ShowRequest setProfile(@Nullable String profile) { + this.profile = profile; + return this; + } + + @CheckForNull + public Boolean getCompareToSonarWay() { + return compareToSonarWay; + } + + public ShowRequest setCompareToSonarWay(@Nullable Boolean compareToSonarWay) { + this.compareToSonarWay = compareToSonarWay; + return this; + } +} diff --git a/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto b/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto index 0f1ddd6cb0b..3e19aaf63a7 100644 --- a/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto +++ b/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto @@ -101,7 +101,7 @@ message CopyWsResponse { } // WS api/qualityprofiles/show -message ShowWsResponse { +message ShowResponse { optional QualityProfile profile = 1; optional CompareToSonarWay compareToSonarWay = 2; 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 316d97d77b3..1ea8262b646 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 @@ -22,7 +22,8 @@ package org.sonarqube.ws.client.qualityprofile; import org.junit.Rule; import org.junit.Test; import org.sonarqube.ws.Common.Severity; -import org.sonarqube.ws.QualityProfiles; +import org.sonarqube.ws.QualityProfiles.SearchWsResponse; +import org.sonarqube.ws.QualityProfiles.ShowResponse; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.ServiceTester; @@ -30,6 +31,7 @@ import org.sonarqube.ws.client.WsConnector; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY; 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; @@ -59,7 +61,7 @@ public class QualityProfilesServiceTest { .setProfileName("profile")); GetRequest getRequest = serviceTester.getGetRequest(); - assertThat(serviceTester.getGetParser()).isSameAs(QualityProfiles.SearchWsResponse.parser()); + assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser()); serviceTester.assertThat(getRequest) .hasPath("search") .hasParam(PARAM_DEFAULTS, true) @@ -70,6 +72,21 @@ public class QualityProfilesServiceTest { } @Test + public void show() { + underTest.show(new ShowRequest() + .setProfile("profile") + .setCompareToSonarWay(true)); + GetRequest getRequest = serviceTester.getGetRequest(); + + assertThat(serviceTester.getGetParser()).isSameAs(ShowResponse.parser()); + serviceTester.assertThat(getRequest) + .hasPath("show") + .hasParam(PARAM_PROFILE, "profile") + .hasParam(PARAM_COMPARE_TO_SONAR_WAY, true) + .andNoOtherParam(); + } + + @Test public void add_project() throws Exception { underTest.addProject(AddProjectRequest.builder() .setLanguage("xoo") |