aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-01-31 14:02:10 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-02-02 16:12:13 +0100
commit6450dc1275f996ee35d84667a742d57f486dcfba (patch)
treeb4baaa653f35c3f26629e8e1368a4eee743a91bd /sonar-ws
parent544d210780aa299800f2653b5a4af9d7926da313 (diff)
downloadsonarqube-6450dc1275f996ee35d84667a742d57f486dcfba.tar.gz
sonarqube-6450dc1275f996ee35d84667a742d57f486dcfba.zip
SONAR-8651 add organization parameter to api/projects/create
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java13
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java1
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java16
3 files changed, 30 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java
index b68e7746999..06ab43c2270 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java
@@ -26,16 +26,23 @@ import javax.annotation.concurrent.Immutable;
@Immutable
public class CreateRequest {
+ private final String organization;
private final String key;
private final String name;
private final String branch;
private CreateRequest(Builder builder) {
+ this.organization = builder.organization;
this.key = builder.key;
this.name = builder.name;
this.branch = builder.branch;
}
+ @CheckForNull
+ public String getOrganization() {
+ return organization;
+ }
+
public String getKey() {
return key;
}
@@ -54,6 +61,7 @@ public class CreateRequest {
}
public static class Builder {
+ private String organization;
private String key;
private String name;
private String branch;
@@ -61,6 +69,11 @@ public class CreateRequest {
private Builder() {
}
+ public Builder setOrganization(String organization) {
+ this.organization = organization;
+ return this;
+ }
+
public Builder setKey(String key) {
this.key = key;
return this;
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java
index 37f0db639a7..328045fbd86 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java
@@ -48,6 +48,7 @@ public class ProjectsService extends BaseService {
*/
public CreateWsResponse create(CreateRequest project) {
PostRequest request = new PostRequest(path(ACTION_CREATE))
+ .setParam("organization", project.getOrganization())
.setParam(PARAM_PROJECT, project.getKey())
.setParam(PARAM_NAME, project.getName())
.setParam(PARAM_BRANCH, project.getBranch());
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java
index 94fc4c2b91e..1d3e3c51881 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java
@@ -51,6 +51,22 @@ public class ProjectsServiceTest {
}
@Test
+ public void creates_project_on_organization() {
+ underTest.create(CreateRequest.builder()
+ .setOrganization("org_key")
+ .setKey("project_key")
+ .setName("Project Name")
+ .build());
+
+ assertThat(serviceTester.getPostParser()).isSameAs(WsProjects.CreateWsResponse.parser());
+ assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create");
+ assertThat(serviceTester.getPostRequest().getParams()).containsOnly(
+ entry("organization", "org_key"),
+ entry("project", "project_key"),
+ entry("name", "Project Name"));
+ }
+
+ @Test
public void creates_project_on_branch() {
underTest.create(CreateRequest.builder()
.setKey("project_key")