use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatelessNextPage.
public void testFetchPaginateStatelessNextPage() {
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");
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));
}
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testIterPaginateStatelessPreviousPage.
public void testIterPaginateStatelessPreviousPage() {
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.nextPage().iter();
Iterator<DiscoveryStringId> it = iter.iterator();
int 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);
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatelessNextPageToEnd.
public void testFetchPaginateStatelessNextPageToEnd() {
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");
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.nextPage().fetch();
assertEquals(0, res.size());
res = query.nextPage().fetch();
assertEquals(0, res.size());
res = query.previousPage().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.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatefulNextPageToEnd.
public void testFetchPaginateStatefulNextPageToEnd() {
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").stateful();
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.nextPage().fetch();
assertEquals(0, res.size());
res = query.nextPage().fetch();
assertEquals(0, res.size());
res = query.previousPage().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.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testIterPaginateStatelessNextPage.
public void testIterPaginateStatelessNextPage() {
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");
try {
Iterable<DiscoveryStringId> res = query.iter();
Iterator<DiscoveryStringId> it = res.iterator();
int i = 0;
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(5, i);
res = query.nextPage().iter();
it = res.iterator();
while (it.hasNext()) {
assertEquals(discs[i++], it.next());
}
assertEquals(10, i);
} finally {
query.release();
}
}
Aggregations