}
public void testOffsetLimitStatefulPaginate2Iter(){
DiscoveryStringId[] discs = new DiscoveryStringId[300];
for(int i=0; i<300; i++){
discs[i] = new DiscoveryStringId("Disc_"+String.format("%03d", i), StringID_CURIE);
}
pm.insert((Object[])discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).stateful().order("name");
Iterable<DiscoveryStringId> iter = query.limit(50).offset(12).iter();
Iterator<DiscoveryStringId> it = iter.iterator();
int i=12;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(62, i);
iter = query.offset(13).limit(30).iter();
it = iter.iterator();
i=75;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(105, i);
iter = query.offset(10).limit(30).iter(15);
it = iter.iterator();
i=115;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(130, i);
iter = query.paginate(6).iter();
it = iter.iterator();
i=130;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(136, i);
iter = query.nextPage().iter();
it = iter.iterator();
i=136;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(142, i);
iter = query.nextPage().iter();
it = iter.iterator();
i=142;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(148, i);
iter = query.previousPage().iter();
it = iter.iterator();
i=136;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(142, i);
iter = query.offset(10).iter(10);
it = iter.iterator();
i=146;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(156, i);
try {
iter = query.nextPage().iter();
}catch(SienaException ex){
iter = query.paginate(8).iter();
it = iter.iterator();
i=156;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(164, i);
iter = query.nextPage().iter();
it = iter.iterator();
i=164;
while(it.hasNext()){
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(172, i);
return;