use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchKeysPaginateStatelessNextPage.
public void testFetchKeysPaginateStatelessNextPage() {
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.fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i].name, res.get(i).name);
assertTrue(res.get(i).isOnlyIdFilled());
}
res = query.nextPage().fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5].name, res.get(i).name);
assertTrue(res.get(i).isOnlyIdFilled());
}
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchKeysPaginateStatelessPreviousPage.
public void testFetchKeysPaginateStatelessPreviousPage() {
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.nextPage().fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5].name, res.get(i).name);
assertTrue(res.get(i).isOnlyIdFilled());
}
res = query.previousPage().fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i].name, res.get(i).name);
assertTrue(res.get(i).isOnlyIdFilled());
}
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatelessPreviousPageFromScratch.
public void testFetchPaginateStatelessPreviousPageFromScratch() {
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.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_5_PAGINATE method testFetchKeysPaginateStatefulSeveralTimes.
public void testFetchKeysPaginateStatefulSeveralTimes() {
DiscoveryStringId[] discs = new DiscoveryStringId[15];
for (int i = 0; i < 15; 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.fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i].name, res.get(i).name);
}
res = query.nextPage().fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5].name, res.get(i).name);
}
res = query.nextPage().fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 10].name, res.get(i).name);
}
res = query.previousPage().fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i + 5].name, res.get(i).name);
}
res = query.previousPage().fetchKeys();
assertEquals(5, res.size());
for (int i = 0; i < 5; i++) {
assertEquals(discs[i].name, res.get(i).name);
}
}
use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.
the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatefulNextPage.
public void testFetchPaginateStatefulNextPage() {
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.nextPage().fetch();
assertEquals(0, res.size());
}
Aggregations