Search in sources :

Example 11 with DiscoveryModel

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

the class BaseModelTest method testFetchPaginateStatefulAsyncAndGetAndResetSync2Models.

public void testFetchPaginateStatefulAsyncAndGetAndResetSync2Models() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().stateful().async();
    Query<PersonLongAutoIDModel> qp = PersonLongAutoIDModel.all();
    SienaFuture<List<DiscoveryModel>> futured = qd.paginate(50).fetch();
    PersonLongAutoIDModel person = qp.filter("lastName", "Tesla").get();
    assertEquals(PERSON_LONGAUTOID_TESLA, person);
    List<DiscoveryModel> res = futured.get();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i], res.get(i));
    }
    futured = qd.nextPage().fetch();
    PersonLongAutoIDModel person2 = qp.resetData().filter("lastName", "Curie").get();
    assertEquals(PERSON_LONGAUTOID_CURIE, person2);
    res = futured.get();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 50], res.get(i));
    }
}
Also used : PersonLongAutoIDModel(siena.base.test.model.PersonLongAutoIDModel) DiscoveryModel(siena.base.test.model.DiscoveryModel) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with DiscoveryModel

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

the class BaseModelTest method testFetchPaginateStatefulRealAsyncUpdateData.

public void testFetchPaginateStatefulRealAsyncUpdateData() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().stateful().async();
    SienaFuture<List<DiscoveryModel>> future = qd.paginate(200).fetch();
    DiscoveryModel disc = new DiscoveryModel("Disc_201", PERSON_LONGAUTOID_CURIE);
    SienaFuture<Void> futureDisc = disc.async().insert();
    List<DiscoveryModel> res = future.get();
    assertEquals(200, res.size());
    for (int i = 0; i < 200; i++) {
        assertEquals(discs[i], res.get(i));
    }
    futureDisc.get();
    SienaFuture<List<DiscoveryModel>> future2 = qd.nextPage().fetch();
    res = future2.get();
    assertEquals(1, res.size());
    assertEquals(disc, res.get(0));
    future = qd.nextPage().fetch();
    res = future.get();
    assertEquals(0, res.size());
    future = qd.previousPage().fetch();
    res = future.get();
    assertEquals(1, res.size());
    assertEquals(disc, res.get(0));
}
Also used : DiscoveryModel(siena.base.test.model.DiscoveryModel) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with DiscoveryModel

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

the class BaseModelTest method testFetchAsyncAndGetAndResetAsync2Models.

public void testFetchAsyncAndGetAndResetAsync2Models() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().async();
    QueryAsync<PersonLongAutoIDModel> qp = PersonLongAutoIDModel.all().async();
    SienaFuture<List<DiscoveryModel>> futured = qd.fetch();
    SienaFuture<PersonLongAutoIDModel> futurep1 = qp.filter("lastName", "Tesla").get();
    SienaFuture<PersonLongAutoIDModel> futurep2 = qp.resetData().filter("lastName", "Curie").get();
    List<DiscoveryModel> res = futured.get();
    assertEquals(200, res.size());
    for (int i = 0; i < 200; i++) {
        assertEquals(discs[i], res.get(i));
    }
    PersonLongAutoIDModel person = futurep1.get();
    assertEquals(PERSON_LONGAUTOID_TESLA, person);
    PersonLongAutoIDModel person2 = futurep2.get();
    assertEquals(PERSON_LONGAUTOID_CURIE, person2);
}
Also used : PersonLongAutoIDModel(siena.base.test.model.PersonLongAutoIDModel) DiscoveryModel(siena.base.test.model.DiscoveryModel) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with DiscoveryModel

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

the class BaseModelTest method testFetchPaginateStatefulAsyncUpdateData.

public void testFetchPaginateStatefulAsyncUpdateData() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().stateful().async();
    SienaFuture<List<DiscoveryModel>> future = qd.paginate(200).fetch();
    List<DiscoveryModel> res = future.get();
    assertEquals(200, res.size());
    for (int i = 0; i < 200; i++) {
        assertEquals(discs[i], res.get(i));
    }
    future = qd.nextPage().fetch();
    res = future.get();
    assertEquals(0, res.size());
    DiscoveryModel disc = new DiscoveryModel("Disc_201", PERSON_LONGAUTOID_CURIE);
    disc.insert();
    future = qd.fetch();
    res = future.get();
    assertEquals(1, res.size());
    assertEquals(disc, res.get(0));
    future = qd.nextPage().fetch();
    res = future.get();
    assertEquals(0, res.size());
    future = qd.previousPage().fetch();
    res = future.get();
    assertEquals(1, res.size());
    assertEquals(disc, res.get(0));
}
Also used : DiscoveryModel(siena.base.test.model.DiscoveryModel) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DiscoveryModel (siena.base.test.model.DiscoveryModel)14 ArrayList (java.util.ArrayList)11 List (java.util.List)10 PersonLongAutoIDModel (siena.base.test.model.PersonLongAutoIDModel)9