use of siena.gae.QueryOptionGaeContext in project siena by mandubian.
the class GaeTest method testFilterWithOperatorINLotsOfEntitiesPaginateStateless.
public void testFilterWithOperatorINLotsOfEntitiesPaginateStateless() {
Discovery[] discs = new Discovery[200];
for (int i = 0; i < 200; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs);
Query<Discovery> query = pm.createQuery(Discovery.class).filter("id IN", Arrays.asList(discs[48].id, discs[73].id, discs[86].id)).paginate(2);
List<Discovery> people = query.fetch();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(2, people.size());
assertEquals(discs[48], people.get(0));
assertEquals(discs[73], people.get(1));
people = query.nextPage().fetch();
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(discs[86], people.get(0));
people = query.nextPage().fetch();
assertNotNull(people);
assertEquals(0, people.size());
people = query.previousPage().fetch();
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(discs[86], people.get(0));
people = query.previousPage().fetch();
assertNotNull(people);
assertEquals(2, people.size());
assertEquals(discs[48], people.get(0));
assertEquals(discs[73], people.get(1));
people = query.previousPage().fetch();
assertNotNull(people);
assertEquals(0, people.size());
}
use of siena.gae.QueryOptionGaeContext in project siena by mandubian.
the class GaeAsyncTest method testFilterWithOperatorINLotsOfEntitiesPaginateStateful.
public void testFilterWithOperatorINLotsOfEntitiesPaginateStateful() {
Discovery[] discs = new Discovery[200];
for (int i = 0; i < 200; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs).get();
QueryAsync<Discovery> query = pm.createQuery(Discovery.class).filter("id IN", Arrays.asList(discs[48].id, discs[73].id, discs[86].id)).stateful().paginate(2);
SienaFuture<List<Discovery>> future = query.fetch();
List<Discovery> people = future.get();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(2, people.size());
assertEquals(discs[48], people.get(0));
assertEquals(discs[73], people.get(1));
future = query.nextPage().fetch();
people = future.get();
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(discs[86], people.get(0));
future = query.nextPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(0, people.size());
future = query.previousPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(discs[86], people.get(0));
future = query.previousPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(2, people.size());
assertEquals(discs[48], people.get(0));
assertEquals(discs[73], people.get(1));
future = query.previousPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(0, people.size());
}
use of siena.gae.QueryOptionGaeContext in project siena by mandubian.
the class GaeAsyncTest method testFilterWithOperatorNotEqualStateful.
public void testFilterWithOperatorNotEqualStateful() {
List<PersonUUID> l = getOrderedPersonUUIDs();
QueryAsync<PersonUUID> query = pm.createQuery(PersonUUID.class).filter("id!=", l.get(0).id).order("id").stateful().paginate(1);
SienaFuture<List<PersonUUID>> future = query.fetch();
List<PersonUUID> people = future.get();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(l.get(1), people.get(0));
future = query.nextPage().fetch();
people = future.get();
gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(l.get(2), people.get(0));
}
use of siena.gae.QueryOptionGaeContext in project siena by mandubian.
the class GaeAsyncTest method testFilterWithOperatorINLotsOfEntitiesPaginateStateless.
public void testFilterWithOperatorINLotsOfEntitiesPaginateStateless() {
Discovery[] discs = new Discovery[200];
for (int i = 0; i < 200; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs).get();
QueryAsync<Discovery> query = pm.createQuery(Discovery.class).filter("id IN", Arrays.asList(discs[48].id, discs[73].id, discs[86].id)).paginate(2);
SienaFuture<List<Discovery>> future = query.fetch();
List<Discovery> people = future.get();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(2, people.size());
assertEquals(discs[48], people.get(0));
assertEquals(discs[73], people.get(1));
future = query.nextPage().fetch();
people = future.get();
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(discs[86], people.get(0));
future = query.nextPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(0, people.size());
future = query.previousPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(discs[86], people.get(0));
future = query.previousPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(2, people.size());
assertEquals(discs[48], people.get(0));
assertEquals(discs[73], people.get(1));
future = query.previousPage().fetch();
people = future.get();
assertNotNull(people);
assertEquals(0, people.size());
}
Aggregations