Search in sources :

Example 1 with QueryOptionGaeContext

use of siena.gae.QueryOptionGaeContext in project siena by mandubian.

the class GaeTest method testFilterWithOperatorNotEqualStateful.

public void testFilterWithOperatorNotEqualStateful() {
    List<PersonUUID> l = getOrderedPersonUUIDs();
    Query<PersonUUID> query = pm.createQuery(PersonUUID.class).filter("id!=", l.get(0).id).order("id").stateful().paginate(1);
    List<PersonUUID> people = query.fetch();
    QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
    assertFalse(gaeCtx.useCursor);
    assertNotNull(people);
    assertEquals(1, people.size());
    assertEquals(l.get(1), people.get(0));
    people = query.nextPage().fetch();
    gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
    assertFalse(gaeCtx.useCursor);
    assertNotNull(people);
    assertEquals(1, people.size());
    assertEquals(l.get(2), people.get(0));
}
Also used : QueryOptionGaeContext(siena.gae.QueryOptionGaeContext) PersonUUID(siena.base.test.model.PersonUUID)

Example 2 with QueryOptionGaeContext

use of siena.gae.QueryOptionGaeContext in project siena by mandubian.

the class GaeTest method testFilterWithOperatorNotEqualLotsOfEntitiesStateless.

public void testFilterWithOperatorNotEqualLotsOfEntitiesStateless() {
    Discovery[] discs = new Discovery[200];
    for (int i = 0; i < 200; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).filter("id !=", discs[48].id);
    List<Discovery> res = query.fetch();
    QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
    assertFalse(gaeCtx.useCursor);
    assertNotNull(res);
    assertEquals(200 - 1, res.size());
    for (Discovery disc : res) {
        assertFalse(discs[48].equals(disc));
    }
}
Also used : QueryOptionGaeContext(siena.gae.QueryOptionGaeContext) Discovery(siena.base.test.model.Discovery)

Example 3 with QueryOptionGaeContext

use of siena.gae.QueryOptionGaeContext in project siena by mandubian.

the class GaeTest method testFilterWithOperatorINLotsOfEntitiesPaginateStateful.

public void testFilterWithOperatorINLotsOfEntitiesPaginateStateful() {
    Discovery[] discs = new Discovery[200];
    for (int i = 0; i < 200; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).filter("id IN", Arrays.asList(discs[48].id, discs[73].id, discs[86].id)).stateful().paginate(2);
    List<Discovery> people = query.fetch();
    QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
    assertFalse(gaeCtx.useCursor);
    assertNotNull(people);
    assertEquals(2, people.size());
    assertEquals(discs[48], people.get(0));
    assertEquals(discs[73], people.get(1));
    people = query.nextPage().fetch();
    assertFalse(gaeCtx.useCursor);
    assertNotNull(people);
    assertEquals(1, people.size());
    assertEquals(discs[86], people.get(0));
    people = query.nextPage().fetch();
    assertNotNull(people);
    assertEquals(0, people.size());
    people = query.previousPage().fetch();
    assertNotNull(people);
    assertEquals(1, people.size());
    assertEquals(discs[86], people.get(0));
    people = query.previousPage().fetch();
    assertNotNull(people);
    assertEquals(2, people.size());
    assertEquals(discs[48], people.get(0));
    assertEquals(discs[73], people.get(1));
    people = query.previousPage().fetch();
    assertNotNull(people);
    assertEquals(0, people.size());
}
Also used : QueryOptionGaeContext(siena.gae.QueryOptionGaeContext) Discovery(siena.base.test.model.Discovery)

Example 4 with QueryOptionGaeContext

use of siena.gae.QueryOptionGaeContext in project siena by mandubian.

the class GaeTest method testFilterWithOperatorINStateful.

public void testFilterWithOperatorINStateful() {
    List<PersonUUID> l = getOrderedPersonUUIDs();
    Query<PersonUUID> query = pm.createQuery(PersonUUID.class).filter("id IN", Arrays.asList(l.get(0).id, l.get(1).id)).stateful().paginate(1);
    List<PersonUUID> people = query.fetch();
    QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
    assertFalse(gaeCtx.useCursor);
    assertNotNull(people);
    assertEquals(1, people.size());
    assertEquals(l.get(0), people.get(0));
    people = query.nextPage().fetch();
    gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
    assertFalse(gaeCtx.useCursor);
    assertNotNull(people);
    assertEquals(1, people.size());
    assertEquals(l.get(1), people.get(0));
}
Also used : QueryOptionGaeContext(siena.gae.QueryOptionGaeContext) PersonUUID(siena.base.test.model.PersonUUID)

Example 5 with QueryOptionGaeContext

use of siena.gae.QueryOptionGaeContext in project siena by mandubian.

the class GaeTest method testFilterWithOperatorNotEqualLotsOfEntitiesStateful.

public void testFilterWithOperatorNotEqualLotsOfEntitiesStateful() {
    Discovery[] discs = new Discovery[200];
    for (int i = 0; i < 200; i++) {
        discs[i] = new Discovery("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery> query = pm.createQuery(Discovery.class).stateful().filter("id !=", discs[48].id);
    List<Discovery> res = query.fetch();
    QueryOptionGaeContext gaeCtx = (QueryOptionGaeContext) query.option(QueryOptionGaeContext.ID);
    assertFalse(gaeCtx.useCursor);
    assertNotNull(res);
    assertEquals(200 - 1, res.size());
    for (Discovery disc : res) {
        assertFalse(discs[48].equals(disc));
    }
}
Also used : QueryOptionGaeContext(siena.gae.QueryOptionGaeContext) Discovery(siena.base.test.model.Discovery)

Aggregations

QueryOptionGaeContext (siena.gae.QueryOptionGaeContext)14 Discovery (siena.base.test.model.Discovery)10 List (java.util.List)7 PersonUUID (siena.base.test.model.PersonUUID)4