use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testFetchPaginateStatefulNextPageRealAsync.
public void testFetchPaginateStatefulNextPageRealAsync() {
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).stateful().order("name");
SienaFuture<List<Discovery>> future1 = query.fetch();
SienaFuture<List<Discovery>> future2 = query.nextPage().fetch();
List<Discovery> res = future1.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i], res.get(i));
}
res = future2.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5], res.get(i));
}
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testOffsetLimitStatelessKeys.
public void testOffsetLimitStatelessKeys() {
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).order("id");
SienaFuture<List<Discovery>> future = query.offset(50).limit(50).fetchKeys();
List<Discovery> res = future.get();
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i + 50].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 testFetchPaginateStatefulPreviouPageSeveralTimes.
public void testFetchPaginateStatefulPreviouPageSeveralTimes() {
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).paginate(5).stateful().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.nextPage().fetch();
res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 10], res.get(i));
}
future = query.previousPage().fetch();
res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5], res.get(i));
}
future = query.previousPage().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 BaseTest method testOffsetStatefulKeys.
public void testOffsetStatefulKeys() {
Discovery[] discs = new Discovery[150];
for (int i = 0; i < 150; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs);
Query<Discovery> query = pm.createQuery(Discovery.class).stateful().order("id");
List<Discovery> res = query.offset(50).fetchKeys();
assertEquals(100, res.size());
for (int i = 0; i < 100; i++) {
assertEquals(discs[i + 50].id, res.get(i).id);
assertTrue(res.get(i).isOnlyIdFilled());
}
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseTest method testBatchGetList.
public void testBatchGetList() {
Discovery[] discs = new Discovery[100];
for (int i = 0; i < 100; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs);
List<Discovery> discs2Get = new ArrayList<Discovery>();
for (int i = 0; i < 100; i++) {
Discovery disc = new Discovery();
disc.id = discs[i].id;
discs2Get.add(disc);
}
int nb = pm.get(discs2Get);
assertEquals(nb, discs.length);
int i = 0;
for (Discovery disc : discs2Get) {
assertEquals(discs[i++], disc);
}
}
Aggregations