use of siena.gae.QueryOptionGaeContext in project siena by mandubian.
the class GaeTest method testFilterWithOperatorNotEqualStateful.
public void testFilterWithOperatorNotEqualStateful() {
List<PersonUUID> l = getOrderedPersonUUIDs();
Query<PersonUUID> query = pm.createQuery(PersonUUID.class).filter("id!=", l.get(0).id).order("id").stateful().paginate(1);
List<PersonUUID> people = query.fetch();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(l.get(1), people.get(0));
people = query.nextPage().fetch();
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 GaeTest method testFilterWithOperatorNotEqualLotsOfEntitiesStateless.
public void testFilterWithOperatorNotEqualLotsOfEntitiesStateless() {
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 !=", discs[48].id);
List<Discovery> res = query.fetch();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(res);
assertEquals(200 - 1, res.size());
for (Discovery disc : res) {
assertFalse(discs[48].equals(disc));
}
}
use of siena.gae.QueryOptionGaeContext in project siena by mandubian.
the class GaeTest 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);
Query<Discovery> query = pm.createQuery(Discovery.class).filter("id IN", Arrays.asList(discs[48].id, discs[73].id, discs[86].id)).stateful().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 GaeTest method testFilterWithOperatorINStateful.
public void testFilterWithOperatorINStateful() {
List<PersonUUID> l = getOrderedPersonUUIDs();
Query<PersonUUID> query = pm.createQuery(PersonUUID.class).filter("id IN", Arrays.asList(l.get(0).id, l.get(1).id)).stateful().paginate(1);
List<PersonUUID> people = query.fetch();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(l.get(0), people.get(0));
people = query.nextPage().fetch();
gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(people);
assertEquals(1, people.size());
assertEquals(l.get(1), people.get(0));
}
use of siena.gae.QueryOptionGaeContext in project siena by mandubian.
the class GaeTest method testFilterWithOperatorNotEqualLotsOfEntitiesStateful.
public void testFilterWithOperatorNotEqualLotsOfEntitiesStateful() {
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).stateful().filter("id !=", discs[48].id);
List<Discovery> res = query.fetch();
QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
assertFalse(gaeCtx.useCursor);
assertNotNull(res);
assertEquals(200 - 1, res.size());
for (Discovery disc : res) {
assertFalse(discs[48].equals(disc));
}
}
Aggregations