Search in sources :

Example 26 with DiscoveryStringId

use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.

the class BaseTestNoAutoInc_5_PAGINATE method testFetchKeysPaginateStatefulNextPage.

public void testFetchKeysPaginateStatefulNextPage() {
    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.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());
    }
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 27 with DiscoveryStringId

use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.

the class BaseTestNoAutoInc_5_PAGINATE method testFetchKeysPaginateStatelessPreviouPageSeveralTimes.

public void testFetchKeysPaginateStatelessPreviouPageSeveralTimes() {
    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).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());
    }
    res = query.nextPage().fetchKeys();
    assertEquals(5, res.size());
    for (int i = 0; i < 5; i++) {
        assertEquals(discs[i + 10].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 + 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());
    }
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 28 with DiscoveryStringId

use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.

the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatelessSeveralTimes.

public void testFetchPaginateStatelessSeveralTimes() {
    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).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(5, res.size());
    for (int i = 0; i < 5; i++) {
        assertEquals(discs[i + 10], res.get(i));
    }
    res = query.previousPage().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));
    }
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 29 with DiscoveryStringId

use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.

the class BaseTestNoAutoInc_5_PAGINATE method testIterPaginateStatefulPreviouPageSeveralTimes.

public void testIterPaginateStatefulPreviouPageSeveralTimes() {
    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");
    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.nextPage().iter();
    it = iter.iterator();
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(15, i);
    iter = query.previousPage().iter();
    i = 5;
    it = iter.iterator();
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(10, i);
    iter = query.previousPage().iter();
    i = 0;
    it = iter.iterator();
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(5, i);
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 30 with DiscoveryStringId

use of siena.base.test.model.DiscoveryStringId in project siena by mandubian.

the class BaseTestNoAutoInc_5_PAGINATE method testFetchPaginateStatelessPreviousPage.

public void testFetchPaginateStatelessPreviousPage() {
    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().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));
    }
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Aggregations

DiscoveryStringId (siena.base.test.model.DiscoveryStringId)98 SienaException (siena.SienaException)9 ArrayList (java.util.ArrayList)6