public abstract class BaseTestNoAutoInc_6_FETCH_ITER extends BaseTestNoAutoInc_BASE {
public void testFetchIterLotsOfEntitiesStatefulMixed(){
DiscoveryStringId[] discs = new DiscoveryStringId[150];
for(int i=0; i<150; 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");
List<DiscoveryStringId> res = query.fetch(50);
assertEquals(50, res.size());
for(int i=0; i<50; i++){
assertEquals(discs[i], res.get(i));
}
Iterable<DiscoveryStringId> res2 = query.iter(50);
Iterator<DiscoveryStringId> it2 = res2.iterator();
int i=50;
while(it2.hasNext()){
DiscoveryStringId disc = it2.next();
assertEquals(discs[i++], disc);
}
assertEquals(100, i);
res = query.paginate(25).fetch();
assertEquals(25, res.size());
for(i=0; i<25; i++){
assertEquals(discs[i+100], res.get(i));
}
res2 = query.nextPage().iter();
it2 = res2.iterator();
i=125;
while(it2.hasNext()){
DiscoveryStringId disc = it2.next();
assertEquals(discs[i++], disc);
}
assertEquals(150, i);
res = query.previousPage().fetch();