Search in sources :

Example 1 with DiscoveryStringId

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

the class BaseTestNoAutoInc_2_FETCH method testFetchLimitReal.

/*	
	@Deprecated
	public void testCountLimit() {
		assertEquals(1, pm.createQuery(PersonUUID.class).filter("n<", 3).count(1));
	}
*/
public void testFetchLimitReal() {
    DiscoveryStringId[] discs = new DiscoveryStringId[10];
    for (int i = 0; i < 10; i++) {
        discs[i] = new DiscoveryStringId("Disc_" + i, StringID_CURIE);
        pm.insert(discs[i]);
    }
    List<DiscoveryStringId> res = pm.createQuery(DiscoveryStringId.class).order("name").fetch(3);
    assertNotNull(res);
    assertEquals(3, res.size());
    assertEquals(discs[0], res.get(0));
    assertEquals(discs[1], res.get(1));
    assertEquals(discs[2], res.get(2));
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 2 with DiscoveryStringId

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

the class BaseTestNoAutoInc_2_FETCH method testFetchLotsOfEntitiesStatefulMixed.

public void testFetchLotsOfEntitiesStatefulMixed() {
    DiscoveryStringId[] discs = new DiscoveryStringId[150];
    for (int i = 0; i < 150; i++) {
        discs[i] = new DiscoveryStringId("Disc_" + String.format("%03d", i), StringID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).stateful().order("name");
    List<DiscoveryStringId> res = query.paginate(50).fetch();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i], res.get(i));
    }
    res = query.fetch(50);
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i], res.get(i));
    }
    res = query.nextPage().fetch();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 50], res.get(i));
    }
    res = query.fetch(50);
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 50], res.get(i));
    }
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 3 with DiscoveryStringId

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

the class BaseTestNoAutoInc_3_ITER method testIterLotsOfEntitiesStateless.

public void testIterLotsOfEntitiesStateless() {
    DiscoveryStringId[] discs = new DiscoveryStringId[150];
    for (int i = 0; i < 150; i++) {
        discs[i] = new DiscoveryStringId("Disc_" + String.format("%03d", i), StringID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).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(150, i);
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 4 with DiscoveryStringId

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

the class BaseTestNoAutoInc_3_ITER method testIterLotsOfEntitiesStatefulMixed.

public void testIterLotsOfEntitiesStatefulMixed() {
    DiscoveryStringId[] discs = new DiscoveryStringId[150];
    for (int i = 0; i < 150; i++) {
        discs[i] = new DiscoveryStringId("Disc_" + String.format("%03d", i), StringID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).stateful().order("name");
    Iterable<DiscoveryStringId> res = query.iter(50);
    Iterator<DiscoveryStringId> it = res.iterator();
    int i = 0;
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(50, i);
    res = query.iter(50, 50);
    it = res.iterator();
    i = 100;
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(150, i);
    res = query.iter(50, 100);
    it = res.iterator();
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(150, i);
}
Also used : DiscoveryStringId(siena.base.test.model.DiscoveryStringId)

Example 5 with DiscoveryStringId

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

the class BaseTestNoAutoInc_3_ITER method testIterLotsOfEntitiesStatefulMixed3.

public void testIterLotsOfEntitiesStatefulMixed3() {
    DiscoveryStringId[] discs = new DiscoveryStringId[150];
    for (int i = 0; i < 150; i++) {
        discs[i] = new DiscoveryStringId("Disc_" + String.format("%03d", i), StringID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<DiscoveryStringId> query = pm.createQuery(DiscoveryStringId.class).stateful().order("name");
    Iterable<DiscoveryStringId> iter = query.iter(50);
    Iterator<DiscoveryStringId> it = iter.iterator();
    int i = 0;
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(50, i);
    iter = query.paginate(50).iter();
    it = iter.iterator();
    i = 50;
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(100, i);
    iter = query.iter();
    it = iter.iterator();
    i = 50;
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(100, i);
    iter = query.nextPage().iter();
    it = iter.iterator();
    while (it.hasNext()) {
        DiscoveryStringId disc = it.next();
        assertEquals(discs[i++], disc);
    }
    assertEquals(150, 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