aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-06-08 09:05:29 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-06-09 11:46:18 +0200
commite89422f9a72502bae8525ab487022eecea72fa03 (patch)
treeaea79302f9031e802e064c072aadb24f68aab8a3 /sonar-ws
parent73549aca8ea8fbc9eff34d7187873ebe89ae76b6 (diff)
downloadsonarqube-e89422f9a72502bae8525ab487022eecea72fa03.tar.gz
sonarqube-e89422f9a72502bae8525ab487022eecea72fa03.zip
SONAR-7723 WS api/permissions/add_project_creator_to_template
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddProjectCreatorToTemplateWsRequest.java84
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java10
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java18
3 files changed, 110 insertions, 2 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddProjectCreatorToTemplateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddProjectCreatorToTemplateWsRequest.java
new file mode 100644
index 00000000000..cbec95d29b0
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddProjectCreatorToTemplateWsRequest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.permission;
+
+import javax.annotation.CheckForNull;
+
+import static java.util.Objects.requireNonNull;
+
+public class AddProjectCreatorToTemplateWsRequest {
+ private final String templateId;
+ private final String templateName;
+ private final String permission;
+
+ public AddProjectCreatorToTemplateWsRequest(Builder builder) {
+ this.templateId = builder.templateId;
+ this.templateName = builder.templateName;
+ this.permission = requireNonNull(builder.permission);
+ }
+
+ @CheckForNull
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ @CheckForNull
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String templateId;
+ private String templateName;
+ private String permission;
+
+ private Builder() {
+ // enforce method constructor
+ }
+
+ public Builder setTemplateId(String templateId) {
+ this.templateId = templateId;
+ return this;
+ }
+
+ public Builder setTemplateName(String templateName) {
+ this.templateName = templateName;
+ return this;
+ }
+
+ public Builder setPermission(String permission) {
+ this.permission = permission;
+ return this;
+ }
+
+ public AddProjectCreatorToTemplateWsRequest build() {
+ return new AddProjectCreatorToTemplateWsRequest(this);
+ }
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java
index 76a553792ea..694f100d1f1 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java
@@ -97,6 +97,13 @@ public class PermissionsService extends BaseService {
.setParam(PARAM_TEMPLATE_NAME, request.getTemplateName()));
}
+ public void addProjectCreatorToTemplate(AddProjectCreatorToTemplateWsRequest request) {
+ call(new PostRequest(path("add_project_creator_to_template"))
+ .setParam(PARAM_PERMISSION, request.getPermission())
+ .setParam(PARAM_TEMPLATE_ID, request.getTemplateId())
+ .setParam(PARAM_TEMPLATE_NAME, request.getTemplateName()));
+ }
+
public void applyTemplate(ApplyTemplateWsRequest request) {
call(new PostRequest(path("apply_template"))
.setParam(PARAM_PROJECT_ID, request.getProjectId())
@@ -110,8 +117,7 @@ public class PermissionsService extends BaseService {
.setParam(PARAM_TEMPLATE_ID, request.getTemplateId())
.setParam(PARAM_TEMPLATE_NAME, request.getTemplateName())
.setParam("q", request.getQuery())
- .setParam(PARAM_QUALIFIER, request.getQualifier())
- );
+ .setParam(PARAM_QUALIFIER, request.getQualifier()));
}
public CreateTemplateWsResponse createTemplate(CreateTemplateWsRequest request) {
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java
index 5cdf798fbbd..e18ff730830 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java
@@ -454,4 +454,22 @@ public class PermissionsServiceTest {
.hasParam(PARAM_Q, QUERY_VALUE)
.andNoOtherParam();
}
+
+ @Test
+ public void add_project_creator_to_template() {
+ underTest.addProjectCreatorToTemplate(AddProjectCreatorToTemplateWsRequest.builder()
+ .setPermission(PERMISSION_VALUE)
+ .setTemplateId(TEMPLATE_ID_VALUE)
+ .setTemplateName(TEMPLATE_NAME_VALUE)
+ .build());
+
+ assertThat(serviceTester.getPostParser()).isNull();
+ PostRequest getRequest = serviceTester.getPostRequest();
+ serviceTester.assertThat(getRequest)
+ .hasPath("add_project_creator_to_template")
+ .hasParam(PARAM_PERMISSION, PERMISSION_VALUE)
+ .hasParam(PARAM_TEMPLATE_ID, TEMPLATE_ID_VALUE)
+ .hasParam(PARAM_TEMPLATE_NAME, TEMPLATE_NAME_VALUE)
+ .andNoOtherParam();
+ }
}