diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-10-05 10:16:12 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-10-12 12:24:30 +0200 |
commit | 2a5cb5ade82337bcea0f4479184e248a869527bf (patch) | |
tree | 536ae0a1c1f9e28ea0d6d49b6a0e04afef27154c /sonar-ws | |
parent | 7b1e4138426ca8f88152e24bb66e89a2af576132 (diff) | |
download | sonarqube-2a5cb5ade82337bcea0f4479184e248a869527bf.tar.gz sonarqube-2a5cb5ade82337bcea0f4479184e248a869527bf.zip |
SONAR-8190 add ws-client RootService
Diffstat (limited to 'sonar-ws')
5 files changed, 122 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java index 139ca5d0d18..8f96d055746 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java @@ -29,6 +29,7 @@ import org.sonarqube.ws.client.project.ProjectsService; import org.sonarqube.ws.client.projectlinks.ProjectLinksService; import org.sonarqube.ws.client.qualitygate.QualityGatesService; import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; +import org.sonarqube.ws.client.root.RootService; import org.sonarqube.ws.client.rule.RulesService; import org.sonarqube.ws.client.setting.SettingsService; import org.sonarqube.ws.client.system.SystemService; @@ -57,6 +58,7 @@ class DefaultWsClient implements WsClient { private final ProjectsService projectsService; private final ProjectLinksService projectLinksService; private final SettingsService settingsService; + private final RootService rootService; DefaultWsClient(WsConnector wsConnector) { this.wsConnector = wsConnector; @@ -74,6 +76,7 @@ class DefaultWsClient implements WsClient { this.projectsService = new ProjectsService(wsConnector); this.projectLinksService = new ProjectLinksService(wsConnector); this.settingsService = new SettingsService(wsConnector); + this.rootService = new RootService(wsConnector); } @Override @@ -150,4 +153,9 @@ class DefaultWsClient implements WsClient { public SettingsService settingsService() { return settingsService; } + + @Override + public RootService rootService() { + return rootService; + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 9e9f0f1ae51..4514f55ec2d 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -29,6 +29,7 @@ import org.sonarqube.ws.client.project.ProjectsService; import org.sonarqube.ws.client.projectlinks.ProjectLinksService; import org.sonarqube.ws.client.qualitygate.QualityGatesService; import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; +import org.sonarqube.ws.client.root.RootService; import org.sonarqube.ws.client.rule.RulesService; import org.sonarqube.ws.client.setting.SettingsService; import org.sonarqube.ws.client.system.SystemService; @@ -91,4 +92,9 @@ public interface WsClient { * @since 6.1 */ SettingsService settingsService(); + + /** + * @since 6.2 + */ + RootService rootService(); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/root/RootService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/root/RootService.java new file mode 100644 index 00000000000..06da491ce75 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/root/RootService.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.root; + +import org.sonarqube.ws.client.BaseService; +import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.WsConnector; + +public class RootService extends BaseService { + public RootService(WsConnector wsConnector) { + super(wsConnector, "api/root"); + } + + public void setRoot(String login) { + PostRequest post = new PostRequest(path("set_root")) + .setParam("login", login); + + call(post); + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/root/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/root/package-info.java new file mode 100644 index 00000000000..3bf3961ceda --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/root/package-info.java @@ -0,0 +1,25 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ + +@ParametersAreNonnullByDefault +package org.sonarqube.ws.client.root; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/root/RootServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/root/RootServiceTest.java new file mode 100644 index 00000000000..d587eb80553 --- /dev/null +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/root/RootServiceTest.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.root; + +import org.junit.Rule; +import org.junit.Test; +import org.sonarqube.ws.client.ServiceTester; +import org.sonarqube.ws.client.WsConnector; + +import static org.mockito.Mockito.mock; + +public class RootServiceTest { + @Rule + public ServiceTester<RootService> serviceTester = new ServiceTester<>(new RootService(mock(WsConnector.class))); + + private RootService underTest = serviceTester.getInstanceUnderTest(); + + @Test + public void setRoot() { + String login = "johnDoe"; + + underTest.setRoot(login); + + serviceTester.assertThat(serviceTester.getPostRequest()) + .hasPath("set_root") + .hasParam("login", login) + .andNoOtherParam(); + } +} |