From 0b3cf3fe412da603e81a9d01ff3ad55a2b4922e3 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 2 Nov 2016 12:00:05 +0100 Subject: SONAR-8120 api/measures/search now accepts only project keys --- .../ws/client/measure/MeasuresWsParameters.java | 2 +- .../sonarqube/ws/client/measure/SearchRequest.java | 24 +++++++++++----------- .../ws/client/measure/SearchRequestTest.java | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'sonar-ws/src') 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 49ce3efb27e..f83b5427f65 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 @@ -43,7 +43,7 @@ public class MeasuresWsParameters { public static final String PARAM_ADDITIONAL_FIELDS = "additionalFields"; public static final String PARAM_COMPONENT_ID = "componentId"; public static final String PARAM_COMPONENT_KEY = "componentKey"; - public static final String PARAM_COMPONENT_KEYS = "componentKeys"; + public static final String PARAM_PROJECT_KEYS = "projectKeys"; public static final String PARAM_DEVELOPER_ID = "developerId"; public static final String PARAM_DEVELOPER_KEY = "developerKey"; public static final String ADDITIONAL_METRICS = "metrics"; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java index a9e76772970..41821338e31 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java @@ -25,22 +25,22 @@ import java.util.List; import static com.google.common.base.Preconditions.checkArgument; public class SearchRequest { - public static final int MAX_NB_COMPONENTS = 100; + public static final int MAX_NB_PROJECTS = 100; private final List metricKeys; - private final List componentKeys; + private final List projectKeys; public SearchRequest(Builder builder) { metricKeys = builder.metricKeys; - componentKeys = builder.componentKeys; + projectKeys = builder.projectKeys; } public List getMetricKeys() { return metricKeys; } - public List getComponentKeys() { - return componentKeys; + public List getProjectKeys() { + return projectKeys; } public static Builder builder() { @@ -49,7 +49,7 @@ public class SearchRequest { public static class Builder { private List metricKeys; - private List componentKeys; + private List projectKeys; private Builder() { // enforce method constructor @@ -60,17 +60,17 @@ public class SearchRequest { return this; } - public Builder setComponentKeys(List componentKeys) { - this.componentKeys = componentKeys; + public Builder setProjectKeys(List projectKeys) { + this.projectKeys = projectKeys; return this; } public SearchRequest build() { checkArgument(metricKeys != null && !metricKeys.isEmpty(), "Metric keys must be provided"); - checkArgument(componentKeys != null && !componentKeys.isEmpty(), "Component keys must be provided"); - int nbComponents = componentKeys.size(); - checkArgument(nbComponents < MAX_NB_COMPONENTS, - "%s components provided, more than maximum authorized (%s)", nbComponents, MAX_NB_COMPONENTS); + checkArgument(projectKeys != null && !projectKeys.isEmpty(), "Project keys must be provided"); + int nbComponents = projectKeys.size(); + checkArgument(nbComponents < MAX_NB_PROJECTS, + "%s projects provided, more than maximum authorized (%s)", nbComponents, MAX_NB_PROJECTS); return new SearchRequest(this); } } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java index 6e174d78ed5..878f314a587 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java @@ -39,11 +39,11 @@ public class SearchRequestTest { public void with_component_keys() { SearchRequest result = underTest .setMetricKeys(singletonList("metric")) - .setComponentKeys(singletonList("key")) + .setProjectKeys(singletonList("key")) .build(); assertThat(result.getMetricKeys()).containsExactly("metric"); - assertThat(result.getComponentKeys()).containsExactly("key"); + assertThat(result.getProjectKeys()).containsExactly("key"); } @Test @@ -73,7 +73,7 @@ public class SearchRequestTest { underTest .setMetricKeys(singletonList("metric")) - .setComponentKeys(emptyList()) + .setProjectKeys(emptyList()) .build(); } @@ -84,6 +84,6 @@ public class SearchRequestTest { private void expectExceptionOnComponents() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Component keys must be provided"); + expectedException.expectMessage("Project keys must be provided"); } } -- cgit v1.2.3