From 71e3e04d3182fd1c13ca405bc3c5ded90ec8f73a Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 17 Aug 2017 11:03:18 +0200 Subject: [PATCH] SONAR-9616 Add missing branch parameter in some ws client --- .../main/java/org/sonarqube/ws/client/ce/CeService.java | 6 ++++-- .../sonarqube/ws/client/component/ComponentsService.java | 1 + .../org/sonarqube/ws/client/issue/IssuesService.java | 2 ++ .../java/org/sonarqube/ws/client/ce/CeServiceTest.java | 4 +++- .../ws/client/component/ComponentsServiceTest.java | 9 ++++++--- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java index c223da8dd3a..272d6670f47 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java @@ -29,6 +29,7 @@ import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsConnector; import static org.sonarqube.ws.client.ce.CeWsParameters.ACTION_WORKER_COUNT; +import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_BRANCH; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_KEY; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MAX_EXECUTED_AT; @@ -96,10 +97,11 @@ public class CeService extends BaseService { return call(new GetRequest(path(ACTION_WORKER_COUNT)), WorkerCountResponse.parser()); } - public ProjectResponse component(String componentKey) { + public ProjectResponse component(String componentKey, String branch) { return call( new GetRequest(path("component")) - .setParam(PARAM_COMPONENT_KEY, componentKey), + .setParam(PARAM_COMPONENT_KEY, componentKey) + .setParam(PARAM_BRANCH, branch), ProjectResponse.parser()); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java index 4f2db0a0608..e9a49cfe0b8 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java @@ -66,6 +66,7 @@ public class ComponentsService extends BaseService { GetRequest get = new GetRequest(path(ACTION_TREE)) .setParam(PARAM_COMPONENT_ID, request.getBaseComponentId()) .setParam(PARAM_COMPONENT, request.getBaseComponentKey()) + .setParam(PARAM_BRANCH, request.getBranch()) .setParam(PARAM_QUALIFIERS, inlineMultipleParamValue(request.getQualifiers())) .setParam(PARAM_STRATEGY, request.getStrategy()) .setParam(Param.PAGE, request.getPage()) diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java index a977e19be21..fb9c73feae7 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java @@ -58,6 +58,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNED; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEE; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_AUTHORS; +import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_BRANCH; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMMENT; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS; @@ -176,6 +177,7 @@ public class IssuesService extends BaseService { .setParam(PARAM_CREATED_BEFORE, request.getCreatedBefore()) .setParam(PARAM_CREATED_IN_LAST, request.getCreatedInLast()) .setParam(PARAM_DIRECTORIES, inlineMultipleParamValue(request.getDirectories())) + .setParam(PARAM_BRANCH, request.getBranch()) .setParam(FACET_MODE, request.getFacetMode()) .setParam(FACETS, inlineMultipleParamValue(request.getFacets())) .setParam(PARAM_FILE_UUIDS, inlineMultipleParamValue(request.getFileUuids())) diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java index 5e65034cd41..39d42729c24 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java @@ -31,6 +31,7 @@ import org.sonarqube.ws.client.WsConnector; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.MapEntry.entry; import static org.mockito.Mockito.mock; +import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_BRANCH; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_KEY; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MAX_EXECUTED_AT; @@ -145,13 +146,14 @@ public class CeServiceTest { @Test public void component() { - underTest.component("my_component"); + underTest.component("my_component", "my_branch"); GetRequest result = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(WsCe.ProjectResponse.parser()); serviceTester.assertThat(result) .hasPath("component") .hasParam(PARAM_COMPONENT_KEY, "my_component") + .hasParam(PARAM_BRANCH, "my_branch") .andNoOtherParam(); } } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java index 7316d14e93a..8b73590c1ee 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java @@ -95,13 +95,15 @@ public class ComponentsServiceTest { String id = randomAlphanumeric(20); underTest.show(new ShowWsRequest() .setKey(key) - .setId(id)); + .setId(id) + .setBranch("my_branch")); assertThat(serviceTester.getGetParser()).isSameAs(WsComponents.ShowWsResponse.parser()); serviceTester.assertThat(serviceTester.getGetRequest()) .hasPath("show") .hasParam("component", key) .hasParam("componentId", id) + .hasParam("branch", "my_branch") .andNoOtherParam(); } @@ -137,8 +139,7 @@ public class ComponentsServiceTest { .setQualifiers(asList("q1", "q2")) .setPage(page) .setPageSize(pageSize) - .setQuery(textQuery) - ); + .setQuery(textQuery)); assertThat(serviceTester.getGetParser()).isSameAs(WsComponents.SearchWsResponse.parser()); serviceTester.assertThat(serviceTester.getGetRequest()) @@ -162,6 +163,7 @@ public class ComponentsServiceTest { underTest.tree(new TreeWsRequest() .setBaseComponentId(componentId) .setBaseComponentKey(componentKey) + .setBranch("my_branch") .setQualifiers(asList("q1", "q2")) .setStrategy(strategy) .setPage(page) @@ -174,6 +176,7 @@ public class ComponentsServiceTest { .hasPath("tree") .hasParam("componentId", componentId) .hasParam("component", componentKey) + .hasParam("branch", "my_branch") .hasParam("qualifiers", "q1,q2") .hasParam("strategy", strategy) .hasParam("p", page) -- 2.39.5