use of com.cinchapi.concourse.lang.paginate.Page in project concourse by cinchapi.
the class ResultPaginationTest method testGetCclPage.
@Test
public void testGetCclPage() {
List<Long> records = Lists.newArrayList();
for (long i = 0; i < 100; ++i) {
client.add("foo", i, i);
records.add(i);
}
Page page = Page.sized(15);
Map<Long, Map<String, Set<Object>>> data = null;
while (data == null || !data.isEmpty()) {
data = client.get("foo >= 50", page);
for (long record : data.keySet()) {
Assert.assertTrue(record >= page.skip() + 50 && record <= (page.limit() + page.skip() + 50));
}
records.removeAll(data.keySet());
page = page.next();
}
}
use of com.cinchapi.concourse.lang.paginate.Page in project concourse by cinchapi.
the class PaginationTest method testPaginateSortedMap.
@Test
public void testPaginateSortedMap() {
SortableTable<Set<TObject>> table = SortableTable.multiValued(Maps.newLinkedHashMap());
table.put(1L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("a"))));
table.put(2L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("b"))));
table.put(3L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("c"))));
table.put(4L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("d"))));
table.put(5L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("e"))));
table.put(6L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("z"))));
table.sort(Sorting.byValues(Order.by("name").largestFirst(), null));
Page page = Page.sized(2).go(2);
Map<Long, Map<String, Set<TObject>>> expected = table.entrySet().stream().skip(page.skip()).limit(page.limit()).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (a, b) -> b, LinkedHashMap::new));
Map<Long, Map<String, Set<TObject>>> actual = Paging.page(table, page);
Assert.assertEquals(expected, actual);
}
use of com.cinchapi.concourse.lang.paginate.Page in project concourse by cinchapi.
the class ResultPaginationTest method testSelectRecordsPage.
@Test
public void testSelectRecordsPage() {
List<Long> records = Lists.newArrayList();
for (long i = 0; i < 100; ++i) {
client.add("foo", i, i);
records.add(i);
}
List<Long> $records = Lists.newArrayList(records);
Page page = Page.sized(15);
Map<Long, Map<String, Set<Object>>> data = null;
while (data == null || !data.isEmpty()) {
data = client.select($records, page);
for (long record : data.keySet()) {
Assert.assertTrue(record >= page.skip() && record <= (page.limit() + page.skip()));
}
records.removeAll(data.keySet());
page = page.next();
}
Assert.assertTrue(records.isEmpty());
}
Aggregations