diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-08-25 14:35:39 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 11:34:53 +0200 |
commit | 98d1c53522f3f69e16dfb9bbdb63e0174402ec57 (patch) | |
tree | 8c2aecaabc896cd812222773393adc8bbc62f0d8 /sonar-ws | |
parent | 0cf6dd627a9949749ce1400a82193e33632491b8 (diff) | |
download | sonarqube-98d1c53522f3f69e16dfb9bbdb63e0174402ec57.tar.gz sonarqube-98d1c53522f3f69e16dfb9bbdb63e0174402ec57.zip |
SONAR-9616 Handle branch in api/settings/list_definitions
Diffstat (limited to 'sonar-ws')
4 files changed, 29 insertions, 3 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java index a5aefe42a9f..0e2ac0ddb19 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java @@ -27,9 +27,11 @@ import javax.annotation.concurrent.Immutable; public class ListDefinitionsRequest { private final String component; + private final String branch; private ListDefinitionsRequest(Builder builder) { this.component = builder.component; + this.branch = builder.branch; } @CheckForNull @@ -37,12 +39,18 @@ public class ListDefinitionsRequest { return component; } + @CheckForNull + public String getBranch() { + return branch; + } + public static Builder builder() { return new Builder(); } public static class Builder { private String component; + private String branch; private Builder() { // enforce factory method use @@ -53,6 +61,11 @@ public class ListDefinitionsRequest { return this; } + public Builder setBranch(@Nullable String branch) { + this.branch = branch; + return this; + } + public ListDefinitionsRequest build() { return new ListDefinitionsRequest(this); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java index 3348fdb48c5..2fddb192e23 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java @@ -46,7 +46,8 @@ public class SettingsService extends BaseService { public ListDefinitionsWsResponse listDefinitions(ListDefinitionsRequest request) { GetRequest getRequest = new GetRequest(path(ACTION_LIST_DEFINITIONS)) - .setParam(PARAM_COMPONENT, request.getComponent()); + .setParam(PARAM_COMPONENT, request.getComponent()) + .setParam(PARAM_BRANCH, request.getBranch()); return call(getRequest, ListDefinitionsWsResponse.parser()); } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java index 989fcbc8eae..3a98984c95d 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java @@ -33,17 +33,27 @@ public class ListDefinitionsRequestTest { ListDefinitionsRequest.Builder underTest = ListDefinitionsRequest.builder(); @Test - public void create_request_with_no_component() { + public void create_request_with_nothing() { ListDefinitionsRequest result = underTest.build(); assertThat(result.getComponent()).isNull(); + assertThat(result.getBranch()).isNull(); } @Test - public void create_request_with_component_key() { + public void create_request_with_component() { ListDefinitionsRequest result = underTest.setComponent("projectKey").build(); assertThat(result.getComponent()).isEqualTo("projectKey"); + assertThat(result.getBranch()).isNull(); + } + + @Test + public void create_request_with_component_and_branch() { + ListDefinitionsRequest result = underTest.setComponent("projectKey").setBranch("branch").build(); + + assertThat(result.getComponent()).isEqualTo("projectKey"); + assertThat(result.getBranch()).isEqualTo("branch"); } } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java index 247acd0247f..d3215980f70 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java @@ -49,12 +49,14 @@ public class SettingsServiceTest { public void list_definitions() { underTest.listDefinitions(ListDefinitionsRequest.builder() .setComponent("KEY") + .setBranch("BRANCH") .build()); GetRequest getRequest = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(ListDefinitionsWsResponse.parser()); serviceTester.assertThat(getRequest) .hasParam(PARAM_COMPONENT, "KEY") + .hasParam(PARAM_BRANCH, "BRANCH") .andNoOtherParam(); } |