Search in sources :

Example 1 with Persistable

use of io.requery.Persistable in project requery by requery.

the class ReactiveTest method testRunInTransaction.

@Test
public void testRunInTransaction() {
    final Person person = randomPerson();
    data.runInTransaction(new io.requery.util.function.Function<BlockingEntityStore<Persistable>, Boolean>() {

        @Override
        public Boolean apply(BlockingEntityStore<Persistable> blocking) {
            blocking.insert(person);
            blocking.update(person);
            blocking.delete(person);
            return true;
        }
    }).blockingGet();
    assertEquals(0, data.count(Person.class).get().value().intValue());
    final Person person2 = randomPerson();
    data.runInTransaction(new io.requery.util.function.Function<BlockingEntityStore<Persistable>, Boolean>() {

        @Override
        public Boolean apply(BlockingEntityStore<Persistable> blocking) {
            blocking.insert(person2);
            return true;
        }
    }).blockingGet();
    assertEquals(1, data.count(Person.class).get().value().intValue());
}
Also used : Function(io.reactivex.functions.Function) Persistable(io.requery.Persistable) BlockingEntityStore(io.requery.BlockingEntityStore) Person(io.requery.test.model.Person) Test(org.junit.Test)

Aggregations

Function (io.reactivex.functions.Function)1 BlockingEntityStore (io.requery.BlockingEntityStore)1 Persistable (io.requery.Persistable)1 Person (io.requery.test.model.Person)1 Test (org.junit.Test)1