diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-01-14 18:31:20 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-01-18 11:16:44 +0100 |
commit | ce63bf3bcfaabf6ce33e80224531cb7004a4bd98 (patch) | |
tree | 368777631ccc3b915c78ccd0711320656b74393e /sonar-ws | |
parent | 91ac20e2d89e3d5d5df1d9627e1471288a315a54 (diff) | |
download | sonarqube-ce63bf3bcfaabf6ce33e80224531cb7004a4bd98.tar.gz sonarqube-ce63bf3bcfaabf6ce33e80224531cb7004a4bd98.zip |
SONAR-7168 add system().restart() to WsClient
Diffstat (limited to 'sonar-ws')
5 files changed, 115 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java index 522c20f7ed0..664960aec8d 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java @@ -25,6 +25,7 @@ import org.sonarqube.ws.client.measure.MeasuresService; import org.sonarqube.ws.client.permission.PermissionsService; import org.sonarqube.ws.client.qualitygate.QualityGatesService; import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; +import org.sonarqube.ws.client.system.SystemService; import org.sonarqube.ws.client.usertoken.UserTokensService; /** @@ -41,6 +42,7 @@ public class HttpWsClient implements WsClient { private final UserTokensService userTokensService; private final QualityGatesService qualityGatesService; private final MeasuresService measuresService; + private final SystemService systemService; private final WsConnector wsConnector; public HttpWsClient(WsConnector wsConnector) { @@ -52,6 +54,7 @@ public class HttpWsClient implements WsClient { this.userTokensService = new UserTokensService(wsConnector); this.qualityGatesService = new QualityGatesService(wsConnector); this.measuresService = new MeasuresService(wsConnector); + this.systemService = new SystemService(wsConnector); } @Override @@ -93,4 +96,9 @@ public class HttpWsClient implements WsClient { public MeasuresService measures() { return measuresService; } + + @Override + public SystemService system() { + return systemService; + } } 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 8fbd2e74168..db7ab7ba245 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 @@ -25,6 +25,7 @@ import org.sonarqube.ws.client.measure.MeasuresService; import org.sonarqube.ws.client.permission.PermissionsService; import org.sonarqube.ws.client.qualitygate.QualityGatesService; import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; +import org.sonarqube.ws.client.system.SystemService; import org.sonarqube.ws.client.usertoken.UserTokensService; /** @@ -45,5 +46,7 @@ public interface WsClient { MeasuresService measures(); + SystemService system(); + WsConnector wsConnector(); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/system/SystemService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/system/SystemService.java new file mode 100644 index 00000000000..4412dac0984 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/system/SystemService.java @@ -0,0 +1,34 @@ +/* + * 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.system; + +import org.sonarqube.ws.client.BaseService; +import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.WsConnector; + +public class SystemService extends BaseService { + public SystemService(WsConnector wsConnector) { + super(wsConnector, "api/system"); + } + + public void restart() { + call(new PostRequest(path("restart"))); + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/system/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/system/package-info.java new file mode 100644 index 00000000000..acaa4e65f91 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/system/package-info.java @@ -0,0 +1,24 @@ +/* + * 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.system; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/system/SystemServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/system/SystemServiceTest.java new file mode 100644 index 00000000000..182b4c68dd5 --- /dev/null +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/system/SystemServiceTest.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.system; + +import org.junit.Rule; +import org.junit.Test; +import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.ServiceTester; +import org.sonarqube.ws.client.WsConnector; + +import static org.mockito.Mockito.mock; + +public class SystemServiceTest { + + @Rule + public ServiceTester<SystemService> serviceTester = new ServiceTester<>(new SystemService(mock(WsConnector.class))); + + private SystemService underTest = serviceTester.getInstanceUnderTest(); + + @Test + public void testName() throws Exception { + underTest.restart(); + + PostRequest postRequest = serviceTester.getPostRequest(); + serviceTester.assertThat(postRequest) + .hasPath("restart") + .andNoOtherParam(); + } +} |