diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-08-11 19:37:42 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 10:59:56 +0200 |
commit | 50328a09b14418b47232bb75665040fc755d6b58 (patch) | |
tree | 724fc1df6b10765228f85e1e3be7765e1b742851 /sonar-ws | |
parent | 7fbdc10fe125547f2d61bfcc00aa31a63242d482 (diff) | |
download | sonarqube-50328a09b14418b47232bb75665040fc755d6b58.tar.gz sonarqube-50328a09b14418b47232bb75665040fc755d6b58.zip |
SONAR-9616 Create api/projectbranches/show
Diffstat (limited to 'sonar-ws')
4 files changed, 34 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java index 9b056ef0bc7..e64477d1b11 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java @@ -25,9 +25,12 @@ public class ProjectBranchesParameters { // actions public static final String ACTION_LIST = "list"; + public static final String ACTION_SHOW = "show"; // parameters public static final String PARAM_PROJECT = "project"; + public static final String PARAM_COMPONENT = "component"; + public static final String PARAM_BRANCH = "branch"; private ProjectBranchesParameters() { // static utility class diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java index bb0aecba3d5..c9a5a21fc24 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java @@ -20,12 +20,15 @@ package org.sonarqube.ws.client.projectbranches; import org.sonarqube.ws.WsBranches.ListWsResponse; +import org.sonarqube.ws.WsBranches.ShowWsResponse; import org.sonarqube.ws.client.BaseService; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsConnector; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_LIST; +import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_SHOW; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.CONTROLLER; +import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_BRANCH; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; public class ProjectBranchesService extends BaseService { @@ -40,4 +43,11 @@ public class ProjectBranchesService extends BaseService { return call(get, ListWsResponse.parser()); } + public ShowWsResponse show(String project, String branch) { + GetRequest get = new GetRequest(path(ACTION_SHOW)) + .setParam(PARAM_PROJECT, project) + .setParam(PARAM_BRANCH, branch); + return call(get, ShowWsResponse.parser()); + } + } diff --git a/sonar-ws/src/main/protobuf/ws-projectbranches.proto b/sonar-ws/src/main/protobuf/ws-projectbranches.proto index 915e983e788..8054febfafc 100644 --- a/sonar-ws/src/main/protobuf/ws-projectbranches.proto +++ b/sonar-ws/src/main/protobuf/ws-projectbranches.proto @@ -30,6 +30,11 @@ message ListWsResponse { repeated Branch branches = 1; } +// WS api/project_branches/show +message ShowWsResponse { + optional Branch branch = 1; +} + message Branch { optional string name = 1; optional string project = 2; diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java index c3dbc7c581b..54bec8cd894 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java @@ -23,12 +23,14 @@ package org.sonarqube.ws.client.projectbranches; import org.junit.Rule; import org.junit.Test; import org.sonarqube.ws.WsBranches.ListWsResponse; +import org.sonarqube.ws.WsBranches.ShowWsResponse; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.ServiceTester; import org.sonarqube.ws.client.WsConnector; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; +import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_BRANCH; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; public class ProjectBranchesServiceTest { @@ -51,4 +53,18 @@ public class ProjectBranchesServiceTest { .andNoOtherParam(); } + @Test + public void show() { + underTest.show("projectKey", "my_branch"); + + assertThat(serviceTester.getGetParser()).isSameAs(ShowWsResponse.parser()); + + GetRequest getRequest = serviceTester.getGetRequest(); + serviceTester.assertThat(getRequest) + .hasPath("show") + .hasParam(PARAM_PROJECT, "projectKey") + .hasParam(PARAM_BRANCH, "my_branch") + .andNoOtherParam(); + } + } |