@Test
public void testJqlSearchWithPaging() {
if (!isJqlSupportedByRest()) {
return;
}
final SearchResult searchResultForNull = client.getSearchClient().searchJql(null, 3, 3, pm);
assertEquals(11, searchResultForNull.getTotal());
assertEquals(3, Iterables.size(searchResultForNull.getIssues()));
assertEquals(3, searchResultForNull.getStartIndex());
assertEquals(3, searchResultForNull.getMaxResults());
// seems pagination works differently between 4.4 and 5.0
// check the rationale https://jdog.atlassian.com/browse/JRADEV-8889
final SearchResult search2 = client.getSearchClient().searchJql("assignee is not EMPTY", 2, 1, pm);
assertEquals(11, search2.getTotal());
assertEquals(2, Iterables.size(search2.getIssues()));
if (IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER) {
assertEquals("TST-6", Iterables.get(search2.getIssues(), 0).getKey());
assertEquals("TST-5", Iterables.get(search2.getIssues(), 1).getKey());
} else {
assertEquals("TST-7", Iterables.get(search2.getIssues(), 0).getKey());
assertEquals("TST-6", Iterables.get(search2.getIssues(), 1).getKey());
}
assertEquals(IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? 1 : 0, search2.getStartIndex());
assertEquals(2, search2.getMaxResults());
setUser1();
final SearchResult search3 = client.getSearchClient().searchJql("assignee is not EMPTY", 10, 5, pm);
assertEquals(10, search3.getTotal());
assertEquals(IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? 5 : 10, Iterables.size(search3.getIssues()));
assertEquals(IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? 5 : 0, search3.getStartIndex());
assertEquals(10, search3.getMaxResults());
}