use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testFetchKeysPaginateStatefulNextPage.
public void testFetchKeysPaginateStatefulNextPage() {
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("id");
SienaFuture<List<Discovery>> future = query.fetchKeys();
List<Discovery> res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i].id, res.get(i).id);
assertTrue(res.get(i).isOnlyIdFilled());
}
future = query.nextPage().fetchKeys();
res = future.get();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5].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 testBatchUpdate.
public void testBatchUpdate() {
Object[] discs = new Discovery[100];
for (int i = 0; i < 100; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert(discs).get();
List<Discovery> res = pm.createQuery(Discovery.class).fetch().get();
assertEquals(discs.length, res.size());
for (int i = 0; i < 100; i++) {
((Discovery) discs[i]).discoverer = LongAutoID_EINSTEIN;
}
int nb = pm.update(discs).get();
assertEquals(discs.length, nb);
res = pm.createQuery(Discovery.class).fetch().get();
int i = 0;
for (Discovery disc : res) {
assertEquals(discs[i++], disc);
}
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testIterPaginateStatelessNextPageRealAsync.
public void testIterPaginateStatelessNextPageRealAsync() {
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<Iterable<Discovery>> future1 = query.iter();
SienaFuture<Iterable<Discovery>> future2 = query.nextPage().iter();
Iterator<Discovery> it = future1.get().iterator();
int i = 0;
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(5, i);
it = future2.get().iterator();
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(10, i);
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseAsyncTest method testFetchPaginateStatelessNextPageRealAsync.
public void testFetchPaginateStatelessNextPageRealAsync() {
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>> 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());
}
}
Aggregations