diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-17 17:00:15 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-17 17:00:15 +0200 |
commit | b8bdde5e341b95afad6726f00c76f303f5de25b0 (patch) | |
tree | f2d91848c2998bfcca6c0a467d12c6da89e23c43 /sonar-plugin-api | |
parent | 65bd6acd3051ca64f61dc6e4510a9c8a21aba29e (diff) | |
download | sonarqube-b8bdde5e341b95afad6726f00c76f303f5de25b0.tar.gz sonarqube-b8bdde5e341b95afad6726f00c76f303f5de25b0.zip |
SONAR-3257 use max size when pageSize<=0
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java | 3 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java | 17 |
2 files changed, 8 insertions, 12 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java index 887d57bc0b3..869be8aca7e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java @@ -332,10 +332,9 @@ public class IssueQuery { } else { if (pageSize == null) { pageSize = DEFAULT_PAGE_SIZE; - } else if (pageSize > MAX_PAGE_SIZE) { + } else if (pageSize<=0 || pageSize > MAX_PAGE_SIZE) { pageSize = MAX_PAGE_SIZE; } - Preconditions.checkArgument(pageSize > 0, "Page size must be greater than 0 (got " + pageSize + ")"); } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java index 2ec08dabf13..fb972c40cee 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java @@ -74,15 +74,12 @@ public class IssueQueryTest { } @Test - public void page_size_should_be_positive() throws Exception { - try { - IssueQuery.builder() - .pageSize(0) - .build(); - fail(); - } catch (Exception e) { - assertThat(e).hasMessage("Page size must be greater than 0 (got 0)").isInstanceOf(IllegalArgumentException.class); - } + public void should_use_max_page_size_if_negative() throws Exception { + IssueQuery query = IssueQuery.builder().pageSize(0).build(); + assertThat(query.pageSize()).isEqualTo(IssueQuery.MAX_PAGE_SIZE); + + query = IssueQuery.builder().pageSize(-1).build(); + assertThat(query.pageSize()).isEqualTo(IssueQuery.MAX_PAGE_SIZE); } @Test @@ -93,7 +90,7 @@ public class IssueQueryTest { } @Test - public void automatically_resize_page_size() throws Exception { + public void should_reset_to_max_page_size() throws Exception { IssueQuery query = IssueQuery.builder() .pageSize(IssueQuery.MAX_PAGE_SIZE + 100) .build(); |