]> source.dussan.org Git - sonarqube.git/commitdiff
Fix SearchOptions#setPage(int page, int pageSize) when pageSize is zero
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 9 Feb 2015 13:23:56 +0000 (14:23 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 9 Feb 2015 13:52:23 +0000 (14:52 +0100)
server/sonar-server/src/main/java/org/sonar/server/es/SearchOptions.java
server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexMediumTest.java
server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java
server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java
server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java
server/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/IssueJsonParserTest.java

index 57cf4904cef47a56b596c1438e326ac9305d054b..0c01aaccb688afce00d7f647c3a03da351c0a5ed 100644 (file)
@@ -89,7 +89,7 @@ public class SearchOptions {
    * 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);
index e4cac26fca33621f0df6161765cbd4746392e606..8eea2257555c65c7aff7bf9143726aeefc42915a 100644 (file)
@@ -61,9 +61,9 @@ public class SearchOptionsTest {
   @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
index bcb26d6a3e2fd5df835b770fd18a08e25b21b076..8f55539d654d5a0be1fa96bff82d5cfdda9e09fb 100644 (file)
@@ -786,7 +786,7 @@ public class IssueIndexMediumTest {
     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);
   }
 
index 702b83760ae2a1d91f43cc76bfa9919de7b87cac..a3baba1b8ce29887c10e4f3d2e9a0051f1b8f03d 100644 (file)
@@ -69,6 +69,4 @@ public interface Issues {
 
   Paging paging();
 
-  Boolean maxResultsReached();
-
 }
index cfacd6111a0fd01f9bb5445ea05aecb80b548f40..5f89a1a32bd52e811c9ef7f3935f825bc288452d 100644 (file)
@@ -28,9 +28,11 @@ import org.sonar.wsclient.rule.Rule;
 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
@@ -45,7 +47,6 @@ public class DefaultIssues implements Issues {
   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() {
@@ -128,12 +129,6 @@ public class DefaultIssues implements Issues {
     return paging;
   }
 
-  @Override
-  @Nullable
-  public Boolean maxResultsReached() {
-    return maxResultsReached;
-  }
-
   DefaultIssues add(Issue issue) {
     list.add(issue);
     return this;
@@ -169,9 +164,4 @@ public class DefaultIssues implements Issues {
     this.paging = paging;
     return this;
   }
-
-  DefaultIssues setMaxResultsReached(@Nullable Boolean maxResultsReached) {
-    this.maxResultsReached = maxResultsReached;
-    return this;
-  }
 }
index 40608c48e7d8c4533fca60d85834df263071aa1d..02cad915e570879ac8394d4315b37f29b3d9dd55 100644 (file)
@@ -63,7 +63,6 @@ public class IssueJsonParser {
   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) {
index c4db8a6f4e51ee915223ef6bb90ecb6e194db118..49295988c6a384394ecde3bcb6c2895f1cc931f4 100644 (file)
@@ -84,8 +84,6 @@ public class IssueJsonParserTest {
     assertThat(paging.pageSize()).isEqualTo(100);
     assertThat(paging.pages()).isEqualTo(1);
     assertThat(paging.total()).isEqualTo(2);
-
-    assertThat(issues.maxResultsReached()).isTrue();
   }
 
   @Test
@@ -95,7 +93,6 @@ public class IssueJsonParserTest {
     assertThat(issues).isNotNull();
     assertThat(issues.list()).isEmpty();
     assertThat(issues.rules()).isEmpty();
-    assertThat(issues.maxResultsReached()).isFalse();
   }
 
   @Test