}
public void testIterPaginateStatefulPreviousPage() {
DiscoveryStringId[] discs = new DiscoveryStringId[10];
for(int i=0; i<10; i++){
discs[i] = new DiscoveryStringId("Disc_"+String.format("%02d", i), StringID_CURIE);
}
pm.insert((Object[])discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).paginate(5).stateful().order("name");
Iterable<DiscoveryStringId> iter = query.iter();
Iterator<DiscoveryStringId> it = iter.iterator();
int i=0;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(5, i);
iter = query.nextPage().iter();
it = iter.iterator();
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(10, i);
iter = query.previousPage().iter();
it = iter.iterator();
i=0;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(5, i);
}