Search in sources :

Example 61 with Discovery

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

the class BaseTest method testFetchKeysPaginateStatelessNextPage.

public void testFetchKeysPaginateStatelessNextPage() {
    Discovery[] discs = new Discovery[10];
    for (int i = 0; i < 10; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).paginate(5).order("name");
    List<Discovery> res = query.fetchKeys();
    assertEquals(5, res.size());
    for (int i = 0; i < 5; i++) {
        assertEquals(discs[i].id, res.get(i).id);
        assertTrue(res.get(i).isOnlyIdFilled());
    }
    res = query.nextPage().fetchKeys();
    assertEquals(5, res.size());
    for (int i = 0; i < 5; i++) {
        assertEquals(discs[i + 5].id, res.get(i).id);
        assertTrue(res.get(i).isOnlyIdFilled());
    }
}
Also used : Discovery(siena.base.test.model.Discovery)

Example 62 with Discovery

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

the class BaseTest method testIterLotsOfEntitiesStateless.

public void testIterLotsOfEntitiesStateless() {
    Discovery[] discs = new Discovery[150];
    for (int i = 0; i < 150; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).order("id");
    Iterable<Discovery> iter = query.iter();
    Iterator<Discovery> it = iter.iterator();
    int i = 0;
    while (it.hasNext()) {
        Discovery disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(150, i);
}
Also used : Discovery(siena.base.test.model.Discovery)

Example 63 with Discovery

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

the class BaseTest method testFetchPaginateStatefulNextPage.

public void testFetchPaginateStatefulNextPage() {
    Discovery[] discs = new Discovery[10];
    for (int i = 0; i < 10; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).paginate(5).stateful().order("id");
    List<Discovery> 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());
}
Also used : Discovery(siena.base.test.model.Discovery)

Example 64 with Discovery

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

the class BaseTest method testFetchIterLotsOfEntitiesStatefulMixed3.

public void testFetchIterLotsOfEntitiesStatefulMixed3() {
    Discovery[] discs = new Discovery[150];
    for (int i = 0; i < 150; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).stateful().order("id");
    List<Discovery> res = query.fetch(50);
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i], res.get(i));
    }
    Iterable<Discovery> res2 = query.iter();
    Iterator<Discovery> it2 = res2.iterator();
    int i = 50;
    while (it2.hasNext()) {
        Discovery disc = it2.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(150, i);
}
Also used : Discovery(siena.base.test.model.Discovery)

Example 65 with Discovery

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

the class BaseTest method testIterPaginateStatelessPreviouPageSeveralTimes.

public void testIterPaginateStatelessPreviouPageSeveralTimes() {
    Discovery[] discs = new Discovery[15];
    for (int i = 0; i < 15; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).paginate(5).order("id");
    Iterable<Discovery> iter = query.iter();
    Iterator<Discovery> it = iter.iterator();
    int i = 0;
    while (it.hasNext()) {
        assertEquals(discs[i++], it.next());
    }
    assertEquals(5, i);
    iter = query.nextPage().iter();
    it = iter.iterator();
    while (it.hasNext()) {
        assertEquals(discs[i++], it.next());
    }
    assertEquals(10, i);
    iter = query.nextPage().iter();
    it = iter.iterator();
    while (it.hasNext()) {
        assertEquals(discs[i++], it.next());
    }
    assertEquals(15, i);
    iter = query.previousPage().iter();
    it = iter.iterator();
    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);
}
Also used : Discovery(siena.base.test.model.Discovery)

Aggregations

Discovery (siena.base.test.model.Discovery)212 ArrayList (java.util.ArrayList)71 List (java.util.List)68 SienaException (siena.SienaException)18 QueryOptionGaeContext (siena.gae.QueryOptionGaeContext)10 EnumLong (siena.base.test.model.DataTypes.EnumLong)2 QueryJoin (siena.QueryJoin)1