Search in sources :

Example 6 with TestEntity

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

the class RxDaoTest method testSave.

public void testSave() {
    TestEntity foo = insertEntity("foo");
    foo.setSimpleStringNotNull("bar");
    assertUpdatedEntity(foo, rxDao.save(foo));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 7 with TestEntity

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

the class RxDaoTest method testDeleteInTxList.

public void testDeleteInTxList() {
    TestEntity foo = insertEntity("foo");
    TestEntity bar = insertEntity("bar");
    List<TestEntity> list = new ArrayList<>();
    list.add(foo);
    list.add(bar);
    assertDeleted(rxDao.deleteInTx(list));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) ArrayList(java.util.ArrayList)

Example 8 with TestEntity

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

the class RxDaoTest method testDelete.

public void testDelete() {
    TestEntity foo = insertEntity("foo");
    assertDeleted(rxDao.delete(foo));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 9 with TestEntity

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

the class RxDaoTest method assertUpdatedEntities.

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

Example 10 with TestEntity

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

the class TestEntityIdentityScopeTest method testDetachAll.

public void testDetachAll() {
    TestEntity entity1 = createEntity(null);
    TestEntity entity2 = createEntity(null);
    dao.insertInTx(entity1, entity2);
    dao.detachAll();
    TestEntity entity1a = dao.load(entity1.getId());
    TestEntity entity2a = dao.load(entity2.getId());
    assertNotSame(entity1, entity1a);
    assertNotSame(entity2, entity2a);
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

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