use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseTest method testFetchKeysPaginateStatelessNextPage.
public void testFetchKeysPaginateStatelessNextPage() {
Discovery[] discs = new Discovery[10];
for (int i = 0; i < 10; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs);
Query<Discovery> query = pm.createQuery(Discovery.class).paginate(5).order("name");
List<Discovery> res = query.fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i].id, res.get(i).id);
assertTrue(res.get(i).isOnlyIdFilled());
}
res = query.nextPage().fetchKeys();
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 BaseTest method testIterLotsOfEntitiesStateless.
public void testIterLotsOfEntitiesStateless() {
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).order("id");
Iterable<Discovery> iter = query.iter();
Iterator<Discovery> it = iter.iterator();
int i = 0;
while (it.hasNext()) {
Discovery disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(150, i);
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseTest method testFetchPaginateStatefulNextPage.
public void testFetchPaginateStatefulNextPage() {
Discovery[] discs = new Discovery[10];
for (int i = 0; i < 10; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs);
Query<Discovery> query = pm.createQuery(Discovery.class).paginate(5).stateful().order("id");
List<Discovery> res = query.fetch();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i], res.get(i));
}
res = query.nextPage().fetch();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5], res.get(i));
}
res = query.nextPage().fetch();
assertEquals(0, res.size());
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseTest method testFetchIterLotsOfEntitiesStatefulMixed3.
public void testFetchIterLotsOfEntitiesStatefulMixed3() {
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.fetch(50);
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i], res.get(i));
}
Iterable<Discovery> res2 = query.iter();
Iterator<Discovery> it2 = res2.iterator();
int i = 50;
while (it2.hasNext()) {
Discovery disc = it2.next();
assertEquals(discs[i++], disc);
}
assertEquals(150, i);
}
use of siena.base.test.model.Discovery in project siena by mandubian.
the class BaseTest method testIterPaginateStatelessPreviouPageSeveralTimes.
public void testIterPaginateStatelessPreviouPageSeveralTimes() {
Discovery[] discs = new Discovery[15];
for (int i = 0; i < 15; i++) {
discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
}
pm.insert((Object[]) discs);
Query<Discovery> query = pm.createQuery(Discovery.class).paginate(5).order("id");
Iterable<Discovery> iter = query.iter();
Iterator<Discovery> it = iter.iterator();
int i = 0;
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(5, i);
iter = query.nextPage().iter();
it = iter.iterator();
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(10, i);
iter = query.nextPage().iter();
it = iter.iterator();
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(15, i);
iter = query.previousPage().iter();
it = iter.iterator();
i = 5;
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(10, i);
iter = query.previousPage().iter();
it = iter.iterator();
i = 0;
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(5, i);
}
Aggregations