use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testIterPaginateStatefulPreviousPage.
public void testIterPaginateStatefulPreviousPage() {
DiscoveryStringId[] discs = new DiscoveryStringId[10];
for (int i = 0; i < 10; i++) {
discs[i] = new DiscoveryStringId("Disc_" + String.format("%02d", i), StringID_CURIE);
}
pm.insert((Object[]) discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).paginate(5).stateful().order("name");
Iterable<DiscoveryStringId> iter = query.iter();
Iterator<DiscoveryStringId> it = iter.iterator();
int i = 0;
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(5, i);
iter = query.nextPage().iter();
it = iter.iterator();
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(10, i);
iter = query.previousPage().iter();
it = iter.iterator();
i = 0;
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(5, i);
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatefulPreviousPage.
public void testFetchPaginateStatefulPreviousPage() {
DiscoveryStringId[] discs = new DiscoveryStringId[10];
for (int i = 0; i < 10; i++) {
discs[i] = new DiscoveryStringId("Disc_" + String.format("%02d", i), StringID_CURIE);
}
pm.insert((Object[]) discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).paginate(5).stateful().order("name");
List<DiscoveryStringId> 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.previousPage().fetch();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i], res.get(i));
}
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testIterPaginateStatelessPreviousPageFromScratch.
public void testIterPaginateStatelessPreviousPageFromScratch() {
DiscoveryStringId[] discs = new DiscoveryStringId[10];
for (int i = 0; i < 10; i++) {
discs[i] = new DiscoveryStringId("Disc_" + String.format("%02d", i), StringID_CURIE);
}
pm.insert((Object[]) discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).paginate(5).order("name");
Iterable<DiscoveryStringId> iter = query.previousPage().iter();
Iterator<DiscoveryStringId> it = iter.iterator();
int i = 0;
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(0, i);
iter = query.previousPage().iter();
i = 0;
it = iter.iterator();
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(0, i);
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testIterPaginateStatefulPreviousPageFromScratch.
public void testIterPaginateStatefulPreviousPageFromScratch() {
DiscoveryStringId[] discs = new DiscoveryStringId[10];
for (int i = 0; i < 10; i++) {
discs[i] = new DiscoveryStringId("Disc_" + String.format("%02d", i), StringID_CURIE);
}
pm.insert((Object[]) discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).paginate(5).stateful().order("name");
Iterable<DiscoveryStringId> iter = query.previousPage().iter();
Iterator<DiscoveryStringId> it = iter.iterator();
int i = 0;
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(0, i);
it = iter.iterator();
i = 0;
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(0, i);
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_9_FETCH_ITER_PAGINATE method testOffsetStateless.
public void testOffsetStateless() {
DiscoveryStringId[] discs = new DiscoveryStringId[150];
for (int i = 0; i < 150; i++) {
discs[i] = new DiscoveryStringId("Disc_" + String.format("%03d", i), StringID_CURIE);
}
pm.insert((Object[]) discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).order("name");
List<DiscoveryStringId> res = query.offset(50).fetch();
assertEquals(100, res.size());
for (int i = 0; i < 100; i++) {
assertEquals(discs[i + 50], res.get(i));
}
}
Aggregations