Search in sources :

Example 46 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method testLoad.

public void testLoad() {
    TestEntity foo = insertEntity("foo");
    TestSubscriber<TestEntity> testSubscriber = RxTestHelper.awaitTestSubscriber(rxDao.load(foo.getId()));
    assertEquals(1, testSubscriber.getValueCount());
    TestEntity foo2 = testSubscriber.getOnNextEvents().get(0);
    assertEquals(foo.getSimpleStringNotNull(), foo2.getSimpleStringNotNull());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 47 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method testUpdateInTx.

public void testUpdateInTx() {
    TestEntity foo = insertEntity("foo");
    TestEntity bar = insertEntity("bar");
    foo.setSimpleStringNotNull("foo2");
    bar.setSimpleStringNotNull("bar2");
    assertUpdatedEntities(foo, bar, rxDao.updateInTx(foo, bar));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 48 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method testSaveInTxList.

public void testSaveInTxList() {
    TestEntity foo = insertEntity("foo");
    TestEntity bar = insertEntity("bar");
    foo.setSimpleStringNotNull("foo2");
    List<TestEntity> list = new ArrayList<>();
    list.add(foo);
    list.add(bar);
    assertUpdatedEntities(list, rxDao.saveInTx(list));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) ArrayList(java.util.ArrayList)

Example 49 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method assertUpdatedEntity.

private void assertUpdatedEntity(TestEntity foo, Observable<TestEntity> observable) {
    TestSubscriber<TestEntity> testSubscriber = RxTestHelper.awaitTestSubscriber(observable);
    assertEquals(1, testSubscriber.getValueCount());
    TestEntity bar = testSubscriber.getOnNextEvents().get(0);
    assertSame(foo, bar);
    List<TestEntity> all = dao.loadAll();
    assertEquals(1, all.size());
    assertEquals(foo.getSimpleStringNotNull(), all.get(0).getSimpleStringNotNull());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 50 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method testUpdateInTxList.

public void testUpdateInTxList() {
    TestEntity foo = insertEntity("foo");
    TestEntity bar = insertEntity("bar");
    foo.setSimpleStringNotNull("foo2");
    bar.setSimpleStringNotNull("bar2");
    List<TestEntity> list = new ArrayList<>();
    list.add(foo);
    list.add(bar);
    assertUpdatedEntities(list, rxDao.updateInTx(list));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) ArrayList(java.util.ArrayList)

Aggregations

TestEntity (org.greenrobot.greendao.daotest.TestEntity)72 ArrayList (java.util.ArrayList)16 RelationEntity (org.greenrobot.greendao.daotest.RelationEntity)4 List (java.util.List)3 DaoException (org.greenrobot.greendao.DaoException)2 TestSubscriber (rx.observers.TestSubscriber)2 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Date (java.util.Date)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 WhereCondition (org.greenrobot.greendao.query.WhereCondition)1 Subscription (rx.Subscription)1