Search in sources :

Example 11 with TestEntity

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

the class TestEntityIdentityScopeTest method testLoadIdScope.

public void testLoadIdScope() {
    TestEntity entity = createEntity(null);
    dao.insert(entity);
    TestEntity entity2 = dao.load(entity.getId());
    TestEntity entity3 = dao.load(entity.getId());
    assertSame(entity, entity2);
    assertSame(entity2, entity3);
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 12 with TestEntity

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

the class TestEntityTest method testRefreshIllegal.

public void testRefreshIllegal() {
    TestEntity entity = createEntity(1l);
    try {
        dao.refresh(entity);
        fail("Exception expected");
    } catch (DaoException expected) {
    }
    dao.insert(entity);
    dao.delete(entity);
    try {
        dao.refresh(entity);
        fail("Exception expected");
    } catch (DaoException expected) {
    }
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) DaoException(org.greenrobot.greendao.DaoException)

Example 13 with TestEntity

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

the class TestEntityTest method testRefresh.

public void testRefresh() {
    TestEntity entity = createEntity(1l);
    entity.setSimpleInteger(42);
    entity.setSimpleString(null);
    dao.insert(entity);
    entity.setSimpleInteger(null);
    entity.setSimpleString("temp");
    dao.refresh(entity);
    assertEquals(42, (int) entity.getSimpleInteger());
    assertNull(entity.getSimpleString());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 14 with TestEntity

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

the class TestEntityTestBase method assertIds.

protected void assertIds(List<TestEntity> list, List<TestEntity> list2) {
    for (int i = 0; i < list.size(); i++) {
        TestEntity entity = list.get(i);
        TestEntity lazyEntity = list2.get(i);
        assertIds(entity, lazyEntity);
    }
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 15 with TestEntity

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

the class TestEntityTestBase method insert.

protected ArrayList<TestEntity> insert(int count) {
    ArrayList<TestEntity> list = new ArrayList<TestEntity>();
    for (int i = 0; i < count; i++) {
        TestEntity entity = createEntity(getSimpleInteger(i), getSimpleString(i));
        list.add(entity);
    }
    dao.insertInTx(list);
    return 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