### Question:
GraphqlQueryLanguageProvider implements QueryLanguageProvider<Object> { protected static Pair<Integer, Integer> toMagentoPageNumberAndSize(int offset, int limit) { if (offset % limit == 0) { return Pair.of((offset / limit) + 1, limit); } else { int total = offset + limit; for (int size = limit; size < total; size++) { int min = offset - (offset % size); int max = min + size; if (min <= offset && max >= total) { return Pair.of((min / size) + 1, size); } } return Pair.of(1, total); } } GraphqlQueryLanguageProvider(ResourceMapper resourceMapper, GraphqlDataService graphqlDataService, Map<String, String> properties); @Override String[] getSupportedLanguages(ResolveContext<Object> paramResolveContext); @Override Iterator<Resource> findResources(ResolveContext<Object> ctx, String query, String language); @Override Iterator<ValueMap> queryResources(ResolveContext<Object> paramResolveContext, String query, String language); static final String CATEGORY_ID_PARAMETER; static final String CATEGORY_PATH_PARAMETER; }### Answer:
@Test public void testPagination() { Pair<Integer, Integer> pair = GraphqlQueryLanguageProvider.toMagentoPageNumberAndSize(0, 20); assertEquals(Integer.valueOf(1), pair.getLeft()); assertEquals(Integer.valueOf(20), pair.getRight()); pair = GraphqlQueryLanguageProvider.toMagentoPageNumberAndSize(20, 10); assertEquals(Integer.valueOf(3), pair.getLeft()); assertEquals(Integer.valueOf(10), pair.getRight()); pair = GraphqlQueryLanguageProvider.toMagentoPageNumberAndSize(20, 11); assertEquals(Integer.valueOf(2), pair.getLeft()); assertEquals(Integer.valueOf(16), pair.getRight()); pair = GraphqlQueryLanguageProvider.toMagentoPageNumberAndSize(20, 9); assertEquals(Integer.valueOf(3), pair.getLeft()); assertEquals(Integer.valueOf(10), pair.getRight()); pair = GraphqlQueryLanguageProvider.toMagentoPageNumberAndSize(31, 4); assertEquals(Integer.valueOf(7), pair.getLeft()); assertEquals(Integer.valueOf(5), pair.getRight()); pair = GraphqlQueryLanguageProvider.toMagentoPageNumberAndSize(5, 6); assertEquals(Integer.valueOf(1), pair.getLeft()); assertEquals(Integer.valueOf(11), pair.getRight()); }