}
public void testOffsetLimitStatefulPaginate2Iter(){
Discovery[] discs = new Discovery[300];
for(int i=0; i<300; i++){
discs[i] = new Discovery("Disc_"+i, LongAutoID_CURIE);
}
pm.insert((Object[])discs);
Query<Discovery> query = pm.createQuery(Discovery.class).stateful().order("id");
Iterable<Discovery> iter = query.limit(50).offset(12).iter();
Iterator<Discovery> it = iter.iterator();
int i=12;
while(it.hasNext()){
Discovery 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()){
Discovery 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()){
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(130, i);
iter = query.paginate(6).iter();
it = iter.iterator();
i=130;
while(it.hasNext()){
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(136, i);
iter = query.nextPage().iter();
it = iter.iterator();
i=136;
while(it.hasNext()){
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(142, i);
iter = query.nextPage().iter();
it = iter.iterator();
i=142;
while(it.hasNext()){
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(148, i);
iter = query.previousPage().iter();
it = iter.iterator();
i=136;
while(it.hasNext()){
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(142, i);
iter = query.offset(10).iter(10);
it = iter.iterator();
i=146;
while(it.hasNext()){
Discovery 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()){
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(164, i);
iter = query.nextPage().iter();
it = iter.iterator();
i=164;
while(it.hasNext()){
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(172, i);
return;