use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatefulPreviousPageFromScratch.
public void testFetchPaginateStatefulPreviousPageFromScratch() {
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.previousPage().fetch();
assertEquals(0, res.size());
res = query.nextPage().fetch();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i], res.get(i));
}
res = query.previousPage().fetch();
assertEquals(0, res.size());
res = query.previousPage().fetch();
assertEquals(0, res.size());
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_9_FETCH_ITER_PAGINATE method testIterPerPageStateless.
public void testIterPerPageStateless() {
DiscoveryStringId[] discs = new DiscoveryStringId[500];
for (int i = 0; i < 500; 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");
Iterable<DiscoveryStringId> iter = query.iterPerPage(50);
int i = 0;
for (DiscoveryStringId disc : iter) {
assertEquals(discs[i++], disc);
}
assertEquals(500, i);
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_9_FETCH_ITER_PAGINATE method testLimitStateful.
public void testLimitStateful() {
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).stateful().order("name");
List<DiscoveryStringId> res = query.limit(50).fetch();
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i], res.get(i));
}
res = query.fetch(50);
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i + 50], res.get(i));
}
res = query.paginate(50).fetch(25);
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i + 100], res.get(i));
}
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_9_FETCH_ITER_PAGINATE method testFetchPaginateStatefulTwiceIter.
public void testFetchPaginateStatefulTwiceIter() {
DiscoveryStringId[] discs = new DiscoveryStringId[15];
for (int i = 0; i < 15; i++) {
discs[i] = new DiscoveryStringId("Disc_" + String.format("%03d", i), StringID_CURIE);
}
pm.insert((Object[]) discs);
Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).stateful().paginate(5).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();
i = 5;
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(10, i);
iter = query.paginate(8).iter();
it = iter.iterator();
i = 5;
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(13, i);
iter = query.nextPage().iter();
it = iter.iterator();
i = 13;
while (it.hasNext()) {
DiscoveryStringId disc = it.next();
assertEquals(discs[i++], disc);
}
assertEquals(15, i);
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_9_FETCH_ITER_PAGINATE method testLimitStatefulKeys.
public void testLimitStatefulKeys() {
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).stateful().order("name");
List<DiscoveryStringId> res = query.limit(50).fetchKeys();
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i].name, res.get(i).name);
assertTrue(res.get(i).isOnlyIdFilled());
}
res = query.fetchKeys(50);
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i + 50].name, res.get(i).name);
assertTrue(res.get(i).isOnlyIdFilled());
}
res = query.paginate(50).fetchKeys(25);
assertEquals(50, res.size());
for (int i = 0; i < 50; i++) {
assertEquals(discs[i + 100].name, res.get(i).name);
assertTrue(res.get(i).isOnlyIdFilled());
}
}
Aggregations