aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-12-07 20:10:13 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-12-07 20:10:13 +0100
commitdf4f0f6490ae8d999959972305479a3bba389013 (patch)
tree1a05c79979cabb388ff7dbb0f3deb94c69670b77 /server
parent1f7717e5e8692486be2cf7ef763c977ee13dc2b5 (diff)
downloadsonarqube-df4f0f6490ae8d999959972305479a3bba389013.tar.gz
sonarqube-df4f0f6490ae8d999959972305479a3bba389013.zip
Revert "SONAR-6820 WS using SearchOptions has a page size limit of 500"
This reverts commit c6374cf5b6820acd23b5a172b94cc56e90614e2d.
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchViewComponentsAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/SearchOptions.java21
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/user/ws/SearchAction.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchViewComponentsActionTest.java14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java22
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/ignore_paging_with_one_component.json5
18 files changed, 51 insertions, 95 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java
index e33c13fd9d4..e57c94aea74 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java
@@ -33,8 +33,6 @@ import org.sonar.server.es.SearchResult;
import org.sonar.server.search.QueryContext;
import org.sonar.server.user.UserSession;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
-
public class SearchAction implements RequestHandler {
public static final String PARAM_TYPE = "type";
@@ -63,7 +61,7 @@ public class SearchAction implements RequestHandler {
.setDescription("Activity type")
.setPossibleValues(Activity.Type.values());
- action.addPagingParams(10, MAX_LIMIT);
+ action.addPagingParams(10);
action.addFieldsParam(docToJsonMapping.supportedFields());
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchViewComponentsAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchViewComponentsAction.java
index d866bf59b7d..ca5fe49c506 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchViewComponentsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchViewComponentsAction.java
@@ -43,7 +43,6 @@ import org.sonar.server.user.UserSession;
import static com.google.common.collect.Sets.newLinkedHashSet;
import static org.sonar.api.server.ws.WebService.Param.PAGE;
import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
public class SearchViewComponentsAction implements RequestHandler {
@@ -81,7 +80,7 @@ public class SearchViewComponentsAction implements RequestHandler {
.setDescription("UTF-8 search query")
.setExampleValue("sonar");
- action.addPagingParams(10, MAX_LIMIT);
+ action.addPagingParams(10);
}
@Override
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/SearchOptions.java b/server/sonar-server/src/main/java/org/sonar/server/es/SearchOptions.java
index c99aa1cfc8e..0c01aaccb68 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/SearchOptions.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/SearchOptions.java
@@ -19,18 +19,19 @@
*/
package org.sonar.server.es;
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.text.JsonWriter;
+
+import javax.annotation.Nullable;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
-import javax.annotation.Nullable;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.text.JsonWriter;
-
-import static com.google.common.base.Preconditions.checkArgument;
/**
* Various Elasticsearch request options: paging, fields and facets
@@ -40,7 +41,6 @@ public class SearchOptions {
public static final int DEFAULT_OFFSET = 0;
public static final int DEFAULT_LIMIT = 10;
public static final int MAX_LIMIT = 500;
- private static final String MSG_MAX_LIMIT_ERROR = "Page size must be less than " + MAX_LIMIT;
private int offset = DEFAULT_OFFSET;
private int limit = DEFAULT_LIMIT;
@@ -58,7 +58,7 @@ public class SearchOptions {
* Sets the offset of the first result to return (zero-based).
*/
public SearchOptions setOffset(int offset) {
- checkArgument(offset >= 0, "Offset must be positive");
+ Preconditions.checkArgument(offset >= 0, "Offset must be positive");
this.offset = offset;
return this;
}
@@ -68,7 +68,7 @@ public class SearchOptions {
* {@link #MAX_LIMIT} is used.
*/
public SearchOptions setPage(int page, int pageSize) {
- checkArgument(page >= 1, "Page must be greater or equal to 1 (got " + page + ")");
+ Preconditions.checkArgument(page >= 1, "Page must be greater or equal to 1 (got " + page + ")");
setLimit(pageSize);
setOffset((page * this.limit) - this.limit);
return this;
@@ -89,11 +89,10 @@ public class SearchOptions {
* Sets the limit on the number of results to return.
*/
public SearchOptions setLimit(int limit) {
- checkArgument(limit <= MAX_LIMIT, MSG_MAX_LIMIT_ERROR);
if (limit <= 0) {
this.limit = MAX_LIMIT;
} else {
- this.limit = limit;
+ this.limit = Math.min(limit, MAX_LIMIT);
}
return this;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index a14cbacf138..91a99ee4f9e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -54,7 +54,6 @@ import static com.google.common.collect.FluentIterable.from;
import static com.google.common.collect.Iterables.concat;
import static java.util.Collections.singletonList;
import static org.sonar.api.utils.Paging.forPageIndex;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.ACTION_PLANS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.ADDITIONAL_FIELDS;
@@ -120,7 +119,7 @@ public class SearchAction implements IssuesWsAction {
.setSince("3.6")
.setResponseExample(Resources.getResource(this.getClass(), "example-search.json"));
- action.addPagingParams(100, MAX_LIMIT);
+ action.addPagingParams(100);
action.createParam(Param.FACETS)
.setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.")
.setPossibleValues(IssueIndex.SUPPORTED_FACETS);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java
index 6d28e6923fc..d62c3894c01 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java
@@ -47,7 +47,6 @@ import org.sonar.server.user.UserSession;
import org.sonar.server.user.index.UserIndex;
import static com.google.common.collect.Sets.newHashSet;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
import static org.sonar.server.measure.custom.ws.CustomMeasureValidator.checkPermissions;
public class SearchAction implements CustomMeasuresWsAction {
@@ -77,7 +76,7 @@ public class SearchAction implements CustomMeasuresWsAction {
"Requires 'Administer System' permission or 'Administer' permission on the project.")
.setSince("5.2")
.addFieldsParam(CustomMeasureJsonWriter.OPTIONAL_FIELDS)
- .addPagingParams(100, MAX_LIMIT)
+ .addPagingParams(100)
.setResponseExample(getClass().getResource("example-search.json"))
.setHandler(this);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java
index 7e1453a9ecc..03aa5e668b7 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java
@@ -69,7 +69,7 @@ public class SearchAction implements MetricsWsAction {
.setSince("5.2")
.setDescription("Search for metrics")
.setResponseExample(getClass().getResource("example-search.json"))
- .addPagingParams(100,500)
+ .addPagingParams(100)
.addFieldsParam(MetricJsonWriter.OPTIONAL_FIELDS)
.setHandler(this);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java
index ef30e6b8385..f4b505bef4f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java
@@ -39,7 +39,6 @@ import org.sonar.server.es.SearchOptions;
import org.sonar.server.user.UserSession;
import static com.google.common.collect.Sets.newHashSet;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
public class GhostsAction implements ProjectsWsAction {
public static final String ACTION = "ghosts";
@@ -60,7 +59,7 @@ public class GhostsAction implements ProjectsWsAction {
.setDescription("List ghost projects.<br /> Requires 'Administer System' permission.")
.setResponseExample(Resources.getResource(getClass(), "projects-example-ghosts.json"))
.setSince("5.2")
- .addPagingParams(100, MAX_LIMIT)
+ .addPagingParams(100)
.addFieldsParam(POSSIBLE_FIELDS)
.addSearchQuery("sonar", "names", "keys")
.setHandler(this);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
index 66a4d3da0c0..25e402929a1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
@@ -38,7 +38,6 @@ import org.sonar.server.es.SearchOptions;
import org.sonar.server.user.UserSession;
import static com.google.common.collect.Sets.newHashSet;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
public class ProvisionedAction implements ProjectsWsAction {
private static final Set<String> POSSIBLE_FIELDS = newHashSet("uuid", "key", "name", "creationDate");
@@ -61,7 +60,7 @@ public class ProvisionedAction implements ProjectsWsAction {
.setSince("5.2")
.setResponseExample(Resources.getResource(getClass(), "projects-example-provisioned.json"))
.setHandler(this)
- .addPagingParams(100, MAX_LIMIT)
+ .addPagingParams(100)
.addSearchQuery("sonar", "names", "keys")
.addFieldsParam(POSSIBLE_FIELDS);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
index 0869ba8db1f..ee4b2d7ad88 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
@@ -45,7 +45,6 @@ import org.sonar.server.qualityprofile.QProfileFactory;
import org.sonar.server.search.Result;
import static org.sonar.api.utils.Paging.forPageIndex;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
public class ChangelogAction implements QProfileWsAction {
@@ -75,7 +74,7 @@ public class ChangelogAction implements QProfileWsAction {
QProfileIdentificationParamUtils.defineProfileParams(changelog, languages);
- changelog.addPagingParams(50, MAX_LIMIT);
+ changelog.addPagingParams(50);
changelog.createParam(PARAM_SINCE)
.setDescription("Start date for the changelog.")
diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java
index 7a9ae4616f6..da29bcaafe9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java
@@ -50,8 +50,6 @@ import org.sonar.server.ws.WsUtils;
import org.sonarqube.ws.Common;
import org.sonarqube.ws.WsTests;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
-
public class ListAction implements TestsWsAction {
public static final String TEST_ID = "testId";
public static final String TEST_FILE_ID = "testFileId";
@@ -87,7 +85,7 @@ public class ListAction implements TestsWsAction {
.setSince("5.2")
.setResponseExample(Resources.getResource(getClass(), "tests-example-list.json"))
.setHandler(this)
- .addPagingParams(100, MAX_LIMIT);
+ .addPagingParams(100);
action
.createParam(TEST_FILE_ID)
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/SearchAction.java
index 2e891ec89a3..f5bbe77ccd0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/user/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/SearchAction.java
@@ -41,8 +41,6 @@ import org.sonar.server.es.SearchResult;
import org.sonar.server.user.index.UserDoc;
import org.sonar.server.user.index.UserIndex;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
-
public class SearchAction implements UsersWsAction {
private final UserIndex userIndex;
@@ -64,7 +62,7 @@ public class SearchAction implements UsersWsAction {
.setResponseExample(getClass().getResource("example-search.json"));
action.addFieldsParam(UserJsonWriter.FIELDS);
- action.addPagingParams(50, MAX_LIMIT);
+ action.addPagingParams(50);
action.createParam(Param.TEXT_QUERY)
.setDescription("Filter on login or name.");
diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
index 5990ddc88b4..c2da27123e6 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
@@ -40,8 +40,6 @@ import org.sonar.db.MyBatis;
import org.sonar.db.user.GroupDto;
import org.sonar.server.es.SearchOptions;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
-
public class SearchAction implements UserGroupsWsAction {
private static final String FIELD_ID = "id";
@@ -64,7 +62,7 @@ public class SearchAction implements UserGroupsWsAction {
.setResponseExample(getClass().getResource("example-search.json"))
.setSince("5.2")
.addFieldsParam(ALL_FIELDS)
- .addPagingParams(100, MAX_LIMIT)
+ .addPagingParams(100)
.addSearchQuery("sonar-users", "names");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchViewComponentsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchViewComponentsActionTest.java
index 5ddd74a3e20..1ad3bad1c4c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchViewComponentsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchViewComponentsActionTest.java
@@ -36,7 +36,6 @@ import org.sonar.server.ws.WsTester;
import org.sonar.test.DbTests;
import static org.mockito.Mockito.mock;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
@Category(DbTests.class)
public class SearchViewComponentsActionTest {
@@ -129,19 +128,6 @@ public class SearchViewComponentsActionTest {
request.execute();
}
- @Test
- public void fail_when_above_max_page_size() throws Exception {
- thrown.expect(IllegalArgumentException.class);
- db.prepareDbUnit(getClass(), "shared.xml");
- userSessionRule.login("john").addProjectUuidPermissions(UserRole.USER, "EFGH");
- WsTester.TestRequest request = newRequest()
- .setParam(Param.PAGE_SIZE, String.valueOf(MAX_LIMIT + 10))
- .setParam("componentId", "EFGH")
- .setParam("q", "st");
-
- request.execute();
- }
-
private WsTester.TestRequest newRequest() {
return ws.newGetRequest("api/components", "search_view_components");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java
index cec4c560e11..a1ce70fc6a0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java
@@ -19,9 +19,7 @@
*/
package org.sonar.server.es;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.server.search.QueryContext;
import org.sonar.test.JsonAssert;
@@ -33,9 +31,6 @@ import static org.junit.Assert.fail;
public class SearchOptionsTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void defaults() {
SearchOptions options = new SearchOptions();
@@ -91,14 +86,9 @@ public class SearchOptionsTest {
public void max_limit() {
SearchOptions options = new SearchOptions().setLimit(42);
assertThat(options.getLimit()).isEqualTo(42);
- }
- @Test
- public void fail_when_limit_is_greater_than_max_limit() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Page size must be less than " + SearchOptions.MAX_LIMIT);
-
- new SearchOptions().setLimit(SearchOptions.MAX_LIMIT + 10);
+ options.setLimit(SearchOptions.MAX_LIMIT + 10);
+ assertThat(options.getLimit()).isEqualTo(QueryContext.MAX_LIMIT);
}
@Test
@@ -109,7 +99,7 @@ public class SearchOptionsTest {
@Test
public void max_page_size() {
- SearchOptions options = new SearchOptions().setPage(3, QueryContext.MAX_LIMIT);
+ SearchOptions options = new SearchOptions().setPage(3, QueryContext.MAX_LIMIT + 10);
assertThat(options.getOffset()).isEqualTo(QueryContext.MAX_LIMIT * 2);
assertThat(options.getLimit()).isEqualTo(QueryContext.MAX_LIMIT);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
index 76a5046dcb4..451771cb895 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
@@ -916,6 +916,22 @@ public class IssueIndexTest {
}
@Test
+ public void search_with_max_limit() {
+ ComponentDto project = ComponentTesting.newProjectDto();
+ ComponentDto file = ComponentTesting.newFileDto(project);
+ List<IssueDoc> issues = newArrayList();
+ for (int i = 0; i < 500; i++) {
+ String key = "ISSUE" + i;
+ issues.add(IssueTesting.newDoc(key, file));
+ }
+ indexIssues(issues.toArray(new IssueDoc[] {}));
+
+ IssueQuery.Builder query = IssueQuery.builder(userSessionRule);
+ SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions().setLimit(Integer.MAX_VALUE));
+ assertThat(result.getDocs()).hasSize(SearchOptions.MAX_LIMIT);
+ }
+
+ @Test
public void sort_by_status() {
ComponentDto project = ComponentTesting.newProjectDto();
ComponentDto file = ComponentTesting.newFileDto(project);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
index 3fac59cffe8..50d4f0ffcc2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
@@ -25,7 +25,6 @@ import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.security.DefaultGroups;
@@ -60,14 +59,12 @@ import org.sonar.server.ws.WsTester;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
public class SearchActionMediumTest {
@ClassRule
public static ServerTester tester = new ServerTester().withStartupTasks().withEsIndexes();
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
+
@Rule
public UserSessionRule userSessionRule = UserSessionRule.forServerTester(tester);
@@ -632,17 +629,6 @@ public class SearchActionMediumTest {
result.assertJson(this.getClass(), "default_page_size_is_100.json");
}
- @Test
- public void fail_when_page_size_above_limit() throws Exception {
- expectedException.expect(IllegalArgumentException.class);
-
- WsTester.TestRequest request = wsTester
- .newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
- .setParam(WebService.Param.PAGE_SIZE, String.valueOf(MAX_LIMIT + 10));
-
- request.execute();
- }
-
private RuleDto newRule() {
RuleDto rule = RuleTesting.newXooX1()
.setName("Rule name")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
index f531721c32a..71fa47a68b5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
@@ -40,18 +40,18 @@ import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDao;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ComponentTesting;
import org.sonar.db.component.SnapshotDao;
-import org.sonar.db.component.SnapshotTesting;
-import org.sonar.db.measure.custom.CustomMeasureDao;
import org.sonar.db.measure.custom.CustomMeasureDto;
-import org.sonar.db.metric.MetricDao;
import org.sonar.db.metric.MetricDto;
import org.sonar.server.component.ComponentFinder;
+import org.sonar.db.component.ComponentTesting;
+import org.sonar.db.component.SnapshotTesting;
import org.sonar.server.db.DbClient;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
+import org.sonar.db.measure.custom.CustomMeasureDao;
+import org.sonar.db.metric.MetricDao;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.user.index.UserDoc;
import org.sonar.server.user.index.UserIndex;
@@ -62,7 +62,6 @@ import org.sonar.server.ws.WsTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.measure.custom.CustomMeasureTesting.newCustomMeasureDto;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
public class SearchActionTest {
@@ -281,16 +280,6 @@ public class SearchActionTest {
assertThat(response).contains("text-value-1");
}
- @Test
- public void fail_when_above_page_size_limit() throws Exception {
- expectedException.expect(IllegalArgumentException.class);
-
- newRequest()
- .setParam(SearchAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID)
- .setParam(WebService.Param.PAGE_SIZE, String.valueOf(MAX_LIMIT + 10))
- .execute();
- }
-
private ComponentDto insertDefaultProject() {
return insertProject(DEFAULT_PROJECT_UUID, DEFAULT_PROJECT_KEY);
}
@@ -313,8 +302,7 @@ public class SearchActionTest {
}
private static MetricDto newCustomMetric(String metricKey) {
- return newMetricDto().setEnabled(true).setUserManaged(true).setKey(metricKey).setDomain(metricKey + "-domain").setShortName(metricKey + "-name")
- .setValueType(ValueType.STRING.name());
+ return newMetricDto().setEnabled(true).setUserManaged(true).setKey(metricKey).setDomain(metricKey + "-domain").setShortName(metricKey + "-name").setValueType(ValueType.STRING.name());
}
private CustomMeasureDto insertCustomMeasure(int id, MetricDto metric) {
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/ignore_paging_with_one_component.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/ignore_paging_with_one_component.json
new file mode 100644
index 00000000000..7da1192f599
--- /dev/null
+++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/ignore_paging_with_one_component.json
@@ -0,0 +1,5 @@
+{
+ "total": 501,
+ "p": 1,
+ "ps": 999999
+}