PaginatedSearchQueryBuilder { public String queryForMatchingChildrenBetweenPages(int fromPageNumber, int toPageNumber) throws JSONException { StringBuilder queryBuilder = buildQuery(); return queryBuilder.append(String.format(") LIMIT %d OFFSET %d", toPageNumber - fromPageNumber, toPageNumber)).toString(); } PaginatedSearchQueryBuilder(RapidFtrApplication applicationContext, String searchKey); String queryForMatchingChildrenFirstPage(); String queryForMatchingChildrenBetweenPages(int fromPageNumber, int toPageNumber);  }
@Test public void returnsQueryForMatchesBetweenSpecifiedPageNumbers() throws JSONException { doReturn(true).when(user).isVerified(); PaginatedSearchQueryBuilder queryBuilder = new PaginatedSearchQueryBuilder(applicationContext, "john doe foo"); String actualQuery = queryBuilder.queryForMatchingChildrenBetweenPages(1, 10); String expectQuery = "SELECT child_json, synced " + "FROM children WHERE (child_json LIKE '%john%' OR id LIKE '%john%' " + "OR child_json LIKE '%doe%' OR id LIKE '%doe%' " + "OR child_json LIKE '%foo%' OR id LIKE '%foo%') LIMIT 9 OFFSET 10"; assertEquals(expectQuery, actualQuery); }