* Sets the limit on the number of results to return.
*/
public SearchOptions setLimit(int limit) {
- if (limit < 0) {
+ if (limit <= 0) {
this.limit = MAX_LIMIT;
} else {
this.limit = Math.min(limit, MAX_LIMIT);
@Test
public void with_zero_page_size() throws Exception {
SearchOptions options = new SearchOptions().setPage(1, 0);
- assertThat(options.getLimit()).isEqualTo(0);
+ assertThat(options.getLimit()).isEqualTo(SearchOptions.MAX_LIMIT);
assertThat(options.getOffset()).isEqualTo(0);
- assertThat(options.getPage()).isEqualTo(0);
+ assertThat(options.getPage()).isEqualTo(1);
}
@Test
assertThat(result.getTotal()).isEqualTo(12);
result = index.search(IssueQuery.builder().build(), new SearchOptions().setOffset(2).setLimit(0));
- assertThat(result.getDocs()).hasSize(0);
+ assertThat(result.getDocs()).hasSize(10);
assertThat(result.getTotal()).isEqualTo(12);
}
Paging paging();
- Boolean maxResultsReached();
-
}
import org.sonar.wsclient.user.User;
import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @since 3.6
private final Map<String, Component> projectsByKey = new HashMap<String, Component>();
private final Map<String, ActionPlan> actionPlansByKey = new HashMap<String, ActionPlan>();
private Paging paging;
- private Boolean maxResultsReached;
@Override
public List<Issue> list() {
return paging;
}
- @Override
- @Nullable
- public Boolean maxResultsReached() {
- return maxResultsReached;
- }
-
DefaultIssues add(Issue issue) {
list.add(issue);
return this;
this.paging = paging;
return this;
}
-
- DefaultIssues setMaxResultsReached(@Nullable Boolean maxResultsReached) {
- this.maxResultsReached = maxResultsReached;
- return this;
- }
}
private void parsePaging(DefaultIssues result, Map jsonRoot) {
Map paging = (Map) jsonRoot.get("paging");
result.setPaging(new Paging(paging));
- result.setMaxResultsReached(JsonUtils.getBoolean(jsonRoot, "maxResultsReached"));
}
private void parseProjects(DefaultIssues result, Map jsonRoot) {
assertThat(paging.pageSize()).isEqualTo(100);
assertThat(paging.pages()).isEqualTo(1);
assertThat(paging.total()).isEqualTo(2);
-
- assertThat(issues.maxResultsReached()).isTrue();
}
@Test
assertThat(issues).isNotNull();
assertThat(issues.list()).isEmpty();
assertThat(issues.rules()).isEmpty();
- assertThat(issues.maxResultsReached()).isFalse();
}
@Test