use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testFetchPaginateStatelessPreviousPageFromScratch.
public void testFetchPaginateStatelessPreviousPageFromScratch() {
Discovery[] discs = new Discovery[10];
for (int i = 0; i < 10; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs).get();
QueryAsync<Discovery> query = pm.createQuery(Discovery.class).paginate(5).order("name");
SienaFuture<List<Discovery>> future = query.previousPage().fetch();
List<Discovery> res = future.get();
assertEquals(0, res.size());
future = query.previousPage().fetch();
res = future.get();
assertEquals(0, res.size());
future = query.nextPage().fetch();
res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i], res.get(i));
}
future = query.previousPage().fetch();
res = future.get();
assertEquals(0, res.size());
future = query.previousPage().fetch();
res = future.get();
assertEquals(0, res.size());
future = query.nextPage().fetch();
res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i], res.get(i));
}
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testLimitStatelessKeys.
public void testLimitStatelessKeys() {
Discovery[] discs = new Discovery[150];
for (int i = 0; i < 150; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs).get();
QueryAsync<Discovery> query = pm.createQuery(Discovery.class).stateless().order("id");
SienaFuture<List<Discovery>> future = query.limit(50).fetchKeys();
List<Discovery> res = future.get();
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i].id, res.get(i).id);
assertTrue(res.get(i).isOnlyIdFilled());
}
future = query.limit(50).fetchKeys();
res = future.get();
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i].id, res.get(i).id);
assertTrue(res.get(i).isOnlyIdFilled());
}
future = query.fetchKeys(50);
res = future.get();
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i].id, res.get(i).id);
assertTrue(res.get(i).isOnlyIdFilled());
}
future = query.paginate(50).fetchKeys();
res = future.get();
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i].id, res.get(i).id);
assertTrue(res.get(i).isOnlyIdFilled());
}
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testFetchPaginateStatefulTwice.
public void testFetchPaginateStatefulTwice() {
Discovery[] discs = new Discovery[15];
for (int i = 0; i < 15; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs).get();
QueryAsync<Discovery> query = pm.createQuery(Discovery.class).stateful().paginate(5).order("id");
SienaFuture<List<Discovery>> future = query.fetch();
List<Discovery> res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i], res.get(i));
}
future = query.nextPage().fetch();
res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5], res.get(i));
}
future = query.paginate(8).fetch();
res = future.get();
assertEquals(8, res.size());
for (int i = 0; i < 8; i++) {
assertEquals(discs[i + 5], res.get(i));
}
future = query.nextPage().fetch();
res = future.get();
assertEquals(2, res.size());
for (int i = 0; i < 2; i++) {
assertEquals(discs[i + 13], res.get(i));
}
}
use of siena.base.test.model.Discovery 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.base.test.model.Discovery 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());
}
Aggregations