Search in sources :

Example 6 with DiscoveryModel

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

the class BaseModelTest method testFetchPaginateAsyncStatefulAndGetAndResetAsync2Models.

public void testFetchPaginateAsyncStatefulAndGetAndResetAsync2Models() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().async().stateful();
    QueryAsync<PersonLongAutoIDModel> qp = PersonLongAutoIDModel.all().async();
    SienaFuture<List<DiscoveryModel>> futured = qd.paginate(50).fetch();
    SienaFuture<PersonLongAutoIDModel> futurep1 = qp.filter("lastName", "Tesla").get();
    PersonLongAutoIDModel person = futurep1.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();
    SienaFuture<PersonLongAutoIDModel> futurep2 = qp.resetData().filter("lastName", "Curie").get();
    PersonLongAutoIDModel person2 = futurep2.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 7 with DiscoveryModel

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

the class BaseModelTest method testFetchPaginateStatelessAsyncUpdateData.

public void testFetchPaginateStatelessAsyncUpdateData() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().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)

Example 8 with DiscoveryModel

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

the class BaseModelTest method testFetchPaginateSyncAndGetAndResetAsync2Models.

public void testFetchPaginateSyncAndGetAndResetAsync2Models() {
    Query<DiscoveryModel> qd = DiscoveryModel.all();
    QueryAsync<PersonLongAutoIDModel> qp = PersonLongAutoIDModel.all().async();
    SienaFuture<PersonLongAutoIDModel> futurep1 = qp.filter("lastName", "Tesla").get();
    SienaFuture<PersonLongAutoIDModel> futurep2 = qp.resetData().filter("lastName", "Curie").get();
    List<DiscoveryModel> res = qd.fetch();
    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)

Example 9 with DiscoveryModel

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

the class BaseModelTest method testFetchPaginateAsync2Sync2AsyncAndGetAndResetSync2Models.

public void testFetchPaginateAsync2Sync2AsyncAndGetAndResetSync2Models() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().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));
    }
    PersonLongAutoIDModel person2 = qp.resetData().filter("lastName", "Curie").get();
    assertEquals(PERSON_LONGAUTOID_CURIE, person2);
    res = qd.sync().nextPage().fetch();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 50], res.get(i));
    }
    PersonLongAutoIDModel person3 = qp.resetData().filter("lastName", "Einstein").get();
    assertEquals(PERSON_LONGAUTOID_EINSTEIN, person3);
    futured = qd.nextPage().fetch();
    res = futured.get();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 100], res.get(i));
    }
    person2 = qp.resetData().filter("lastName", "Curie").get();
    assertEquals(PERSON_LONGAUTOID_CURIE, person2);
    res = qd.sync().nextPage().fetch();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 150], res.get(i));
    }
    futured = qd.nextPage().fetch();
    res = futured.get();
    assertEquals(0, res.size());
    futured = qd.nextPage().fetch();
    res = futured.get();
    assertEquals(0, res.size());
    person3 = qp.resetData().filter("lastName", "Einstein").get();
    assertEquals(PERSON_LONGAUTOID_EINSTEIN, person3);
    res = qd.sync().previousPage().fetch();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 150], res.get(i));
    }
    futured = qd.previousPage().fetch();
    res = futured.get();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 100], res.get(i));
    }
    res = qd.sync().previousPage().fetch();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i + 50], res.get(i));
    }
    futured = qd.previousPage().fetch();
    res = futured.get();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i], res.get(i));
    }
    res = qd.sync().previousPage().fetch();
    assertEquals(0, res.size());
    futured = qd.nextPage().fetch();
    res = futured.get();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i], res.get(i));
    }
    res = qd.sync().fetch();
    assertEquals(50, res.size());
    for (int i = 0; i < 50; i++) {
        assertEquals(discs[i], res.get(i));
    }
    res = qd.sync().previousPage().fetch();
    assertEquals(0, res.size());
    futured = qd.previousPage().fetch();
    res = futured.get();
    assertEquals(0, res.size());
}
Also used : PersonLongAutoIDModel(siena.base.test.model.PersonLongAutoIDModel) DiscoveryModel(siena.base.test.model.DiscoveryModel) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with DiscoveryModel

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

the class BaseModelTest method testFetchAsyncAndGetAndResetSync2Models.

public void testFetchAsyncAndGetAndResetSync2Models() {
    QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().async();
    Query<PersonLongAutoIDModel> qp = PersonLongAutoIDModel.all();
    SienaFuture<List<DiscoveryModel>> futured = qd.fetch();
    PersonLongAutoIDModel person = qp.filter("lastName", "Tesla").get();
    assertEquals(PERSON_LONGAUTOID_TESLA, person);
    PersonLongAutoIDModel person2 = qp.resetData().filter("lastName", "Curie").get();
    assertEquals(PERSON_LONGAUTOID_CURIE, person2);
    List<DiscoveryModel> res = futured.get();
    assertEquals(200, res.size());
    for (int i = 0; i < 200; i++) {
        assertEquals(discs[i], 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)

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