use of siena.base.test.model.DiscoveryModel in project siena by mandubian.
the class BaseModelTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(PersonLongAutoIDModel.class);
classes.add(DiscoveryModel.class);
classes.add(SampleModel.class);
classes.add(SampleModel2.class);
classes.add(PersonLongAutoIDExtended.class);
classes.add(PersonLongAutoIDExtended2.class);
classes.add(PersonLongAutoIDAbstract.class);
classes.add(PersonLongAutoIDExtendedAbstract.class);
classes.add(PersonLongAutoIDExtendedFilter.class);
classes.add(TransactionAccountFromModel.class);
classes.add(TransactionAccountToModel.class);
// classes.add(AggregateChildModel.class);
// classes.add(AggregateParentModel.class);
pm = createPersistenceManager(classes);
PersistenceManagerFactory.install(pm, classes);
for (Class<?> clazz : classes) {
if (!Modifier.isAbstract(clazz.getModifiers())) {
pm.createQuery(clazz).delete();
}
}
Batch<PersonLongAutoIDModel> batch = PersonLongAutoIDModel.batch();
batch.insert(PERSON_LONGAUTOID_TESLA, PERSON_LONGAUTOID_CURIE, PERSON_LONGAUTOID_EINSTEIN);
for (int i = 0; i < 200; i++) {
discs[i] = new DiscoveryModel("Disc_" + i, PERSON_LONGAUTOID_CURIE);
}
Batch<DiscoveryModel> batch2 = DiscoveryModel.batch();
batch2.insert(discs);
}
use of siena.base.test.model.DiscoveryModel in project siena by mandubian.
the class BaseModelTest method testFetchPaginateAsyncAndGetAndResetAsync2Models.
public void testFetchPaginateAsyncAndGetAndResetAsync2Models() {
QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().async();
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));
}
}
use of siena.base.test.model.DiscoveryModel in project siena by mandubian.
the class BaseModelTest method testFetchPaginateStatelessUpdateData.
public void testFetchPaginateStatelessUpdateData() {
Query<DiscoveryModel> qd = DiscoveryModel.all();
List<DiscoveryModel> res = qd.paginate(200).fetch();
assertEquals(200, res.size());
for (int i = 0; i < 200; i++) {
assertEquals(discs[i], res.get(i));
}
res = qd.nextPage().fetch();
assertEquals(0, res.size());
DiscoveryModel disc = new DiscoveryModel("Disc_201", PERSON_LONGAUTOID_CURIE);
disc.insert();
res = qd.fetch();
assertEquals(1, res.size());
assertEquals(disc, res.get(0));
res = qd.nextPage().fetch();
assertEquals(0, res.size());
res = qd.previousPage().fetch();
assertEquals(1, res.size());
assertEquals(disc, res.get(0));
}
use of siena.base.test.model.DiscoveryModel in project siena by mandubian.
the class BaseModelTest method testFetchPaginateStatefulUpdateData.
public void testFetchPaginateStatefulUpdateData() {
Query<DiscoveryModel> qd = DiscoveryModel.all().stateful();
List<DiscoveryModel> res = qd.paginate(200).fetch();
assertEquals(200, res.size());
for (int i = 0; i < 200; i++) {
assertEquals(discs[i], res.get(i));
}
res = qd.nextPage().fetch();
assertEquals(0, res.size());
DiscoveryModel disc = new DiscoveryModel("Disc_201", PERSON_LONGAUTOID_CURIE);
disc.insert();
res = qd.fetch();
assertEquals(1, res.size());
assertEquals(disc, res.get(0));
res = qd.nextPage().fetch();
assertEquals(0, res.size());
res = qd.previousPage().fetch();
assertEquals(1, res.size());
assertEquals(disc, res.get(0));
}
use of siena.base.test.model.DiscoveryModel in project siena by mandubian.
the class BaseModelTest method testFetchPaginateStatefulAsyncAndGetAndResetAsync2Models.
public void testFetchPaginateStatefulAsyncAndGetAndResetAsync2Models() {
QueryAsync<DiscoveryModel> qd = DiscoveryModel.all().stateful().async();
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));
}
}
Aggregations