aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-08-03 18:17:24 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-09-12 10:55:10 +0200
commit6e7b6d89e87413ce7139f8fa269f88cffda1a44e (patch)
treeaff45552e2ea7ca09c3a74aa330ad2ff4385949e /sonar-ws
parentf2bdffe9ab4d8079a639d203b804bd1b3118bcf6 (diff)
downloadsonarqube-6e7b6d89e87413ce7139f8fa269f88cffda1a44e.tar.gz
sonarqube-6e7b6d89e87413ce7139f8fa269f88cffda1a44e.zip
SONAR-9616 Support branch in api/measures/search_history
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java2
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java1
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java18
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java3
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java5
5 files changed, 25 insertions, 4 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
index 72bf5763307..470dfa7fa29 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
@@ -35,6 +35,7 @@ import static org.sonarqube.ws.client.measure.MeasuresWsParameters.CONTROLLER_ME
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_ID;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_KEY;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT_ID;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT_KEY;
@@ -91,6 +92,7 @@ public class MeasuresService extends BaseService {
public SearchHistoryResponse searchHistory(SearchHistoryRequest request) {
GetRequest getRequest = new GetRequest(path(ACTION_SEARCH_HISTORY))
.setParam(PARAM_COMPONENT, request.getComponent())
+ .setParam(PARAM_BRANCH, request.getBranch())
.setParam(PARAM_METRICS, inlineMultipleParamValue(request.getMetrics()))
.setParam(PARAM_FROM, request.getFrom())
.setParam(PARAM_TO, request.getTo())
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
index 4a440f313fc..48599358cc4 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
@@ -34,6 +34,7 @@ public class MeasuresWsParameters {
public static final String PARAM_BASE_COMPONENT_ID = "baseComponentId";
public static final String PARAM_BASE_COMPONENT_KEY = "baseComponentKey";
public static final String PARAM_COMPONENT = "component";
+ public static final String PARAM_BRANCH = "branch";
public static final String PARAM_STRATEGY = "strategy";
public static final String PARAM_QUALIFIERS = "qualifiers";
public static final String PARAM_METRICS = "metrics";
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java
index 3bcc5acf209..b99b9b77b43 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java
@@ -21,6 +21,7 @@ package org.sonarqube.ws.client.measure;
import java.util.List;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import static java.lang.String.format;
@@ -29,6 +30,7 @@ public class SearchHistoryRequest {
public static final int DEFAULT_PAGE_SIZE = 100;
private final String component;
+ private final String branch;
private final List<String> metrics;
private final String from;
private final String to;
@@ -37,6 +39,7 @@ public class SearchHistoryRequest {
public SearchHistoryRequest(Builder builder) {
this.component = builder.component;
+ this.branch = builder.branch;
this.metrics = builder.metrics;
this.from = builder.from;
this.to = builder.to;
@@ -48,6 +51,11 @@ public class SearchHistoryRequest {
return component;
}
+ @CheckForNull
+ public String getBranch() {
+ return branch;
+ }
+
public List<String> getMetrics() {
return metrics;
}
@@ -76,6 +84,7 @@ public class SearchHistoryRequest {
public static class Builder {
private String component;
+ private String branch;
private List<String> metrics;
private String from;
private String to;
@@ -91,17 +100,22 @@ public class SearchHistoryRequest {
return this;
}
+ public Builder setBranch(@Nullable String branch) {
+ this.branch = branch;
+ return this;
+ }
+
public Builder setMetrics(List<String> metrics) {
this.metrics = metrics;
return this;
}
- public Builder setFrom(String from) {
+ public Builder setFrom(@Nullable String from) {
this.from = from;
return this;
}
- public Builder setTo(String to) {
+ public Builder setTo(@Nullable String to) {
this.to = to;
return this;
}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java
index f4ecaf06038..c0b0d0c1967 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java
@@ -36,6 +36,7 @@ import static org.mockito.Mockito.mock;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_ID;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_KEY;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_KEY;
@@ -121,6 +122,7 @@ public class MeasuresServiceTest {
public void search_history() {
SearchHistoryRequest request = SearchHistoryRequest.builder()
.setComponent(VALUE_COMPONENT)
+ .setBranch("my_branch")
.setMetrics(VALUE_METRICS)
.setFrom(VALUE_FROM)
.setTo(VALUE_TO)
@@ -134,6 +136,7 @@ public class MeasuresServiceTest {
assertThat(serviceTester.getGetParser()).isSameAs(WsMeasures.SearchHistoryResponse.parser());
serviceTester.assertThat(getRequest)
.hasParam(PARAM_COMPONENT, VALUE_COMPONENT)
+ .hasParam(PARAM_BRANCH, "my_branch")
.hasParam(PARAM_METRICS, "ncloc,complexity")
.hasParam(PARAM_FROM, VALUE_FROM)
.hasParam(PARAM_TO, VALUE_TO)
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java
index b58a2671fcc..85a9dab34e1 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java
@@ -39,6 +39,7 @@ public class SearchHistoryRequestTest {
public void full_example() {
SearchHistoryRequest result = underTest
.setComponent("C1")
+ .setBranch("my_branch")
.setMetrics(singletonList("new_lines"))
.setFrom("2017-01-15")
.setTo("2017-01-20")
@@ -47,9 +48,9 @@ public class SearchHistoryRequestTest {
.build();
assertThat(result)
- .extracting(SearchHistoryRequest::getComponent, SearchHistoryRequest::getMetrics, SearchHistoryRequest::getFrom, SearchHistoryRequest::getTo,
+ .extracting(SearchHistoryRequest::getComponent, SearchHistoryRequest::getBranch, SearchHistoryRequest::getMetrics, SearchHistoryRequest::getFrom, SearchHistoryRequest::getTo,
SearchHistoryRequest::getPage, SearchHistoryRequest::getPageSize)
- .containsExactly("C1", singletonList("new_lines"), "2017-01-15", "2017-01-20", 23, 42);
+ .containsExactly("C1", "my_branch", singletonList("new_lines"), "2017-01-15", "2017-01-20", 23, 42);
}
@Test