diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-03-21 14:45:43 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-03-23 17:14:59 +0100 |
commit | c5eb8cdb70c6c2da5f4b5bcd72460a48e1c06e59 (patch) | |
tree | aefeb6711a5bb48a986f5d1020f57ba1107ff324 /sonar-ws | |
parent | 43a8901abae57754aa949673e666687cc7f9c98e (diff) | |
download | sonarqube-c5eb8cdb70c6c2da5f4b5bcd72460a48e1c06e59.tar.gz sonarqube-c5eb8cdb70c6c2da5f4b5bcd72460a48e1c06e59.zip |
SONAR-8962 Return sub views in api/measures/search
Diffstat (limited to 'sonar-ws')
-rw-r--r-- | sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java | 2 | ||||
-rw-r--r-- | sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java | 25 |
2 files changed, 25 insertions, 2 deletions
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 0207b93be4c..61b5e774110 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 @@ -68,7 +68,7 @@ public class SearchRequest { checkArgument(metricKeys != null && !metricKeys.isEmpty(), "Metric keys must be provided"); checkArgument(projectKeys != null && !projectKeys.isEmpty(), "Project keys must be provided"); int nbComponents = projectKeys.size(); - checkArgument(nbComponents < MAX_NB_PROJECTS, + 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 214d6cc0e10..90c36dc7ad5 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 @@ -19,6 +19,8 @@ */ package org.sonarqube.ws.client.measure; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -35,7 +37,7 @@ public class SearchRequestTest { SearchRequest.Builder underTest = SearchRequest.builder(); @Test - public void with_component_keys() { + public void create_request() { SearchRequest result = underTest .setMetricKeys(singletonList("metric")) .setProjectKeys(singletonList("key")) @@ -46,6 +48,16 @@ public class SearchRequestTest { } @Test + public void create_request_with_100_keys() { + SearchRequest result = underTest + .setMetricKeys(singletonList("metric")) + .setProjectKeys(IntStream.rangeClosed(1, 100).mapToObj(Integer::toString).collect(Collectors.toList())) + .build(); + + assertThat(result.getProjectKeys()).hasSize(100); + } + + @Test public void fail_when_non_null_metric_keys() { expectExceptionOnMetricKeys(); @@ -76,6 +88,17 @@ public class SearchRequestTest { .build(); } + @Test + public void fail_when_component_keys_contains_more_than_100_keys() { + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("101 projects provided, more than maximum authorized (100)"); + + underTest + .setMetricKeys(singletonList("metric")) + .setProjectKeys(IntStream.rangeClosed(1, 101).mapToObj(Integer::toString).collect(Collectors.toList())) + .build(); + } + private void expectExceptionOnMetricKeys() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Metric keys must be provided"); |