Search in sources :

Example 61 with TestEntity

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

the class RxDaoTest method testDeleteInTx.

public void testDeleteInTx() {
    TestEntity foo = insertEntity("foo");
    TestEntity bar = insertEntity("bar");
    assertDeleted(rxDao.deleteInTx(foo, bar));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 62 with TestEntity

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

the class RxDaoTest method testRefresh.

public void testRefresh() {
    TestEntity entity = insertEntity("foo");
    entity.setSimpleStringNotNull("temp");
    RxTestHelper.awaitTestSubscriber(rxDao.refresh(entity));
    assertEquals("foo", entity.getSimpleStringNotNull());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 63 with TestEntity

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

the class DeleteQueryTest method testDeleteQueryChangeParameter.

public void testDeleteQueryChangeParameter() {
    insert(3);
    String value = getSimpleString(1);
    DeleteQuery<TestEntity> deleteQuery = dao.queryBuilder().where(Properties.SimpleString.eq(value)).buildDelete();
    deleteQuery.executeDeleteWithoutDetachingEntities();
    assertEquals(2, dao.count());
    deleteQuery.setParameter(0, getSimpleString(0));
    deleteQuery.executeDeleteWithoutDetachingEntities();
    assertEquals(1, dao.count());
    TestEntity remaining = dao.loadAll().get(0);
    assertEquals(getSimpleString(2), remaining.getSimpleString());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 64 with TestEntity

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

the class JoinTest method prepareData.

private void prepareData() {
    List<TestEntity> targetEntities = new ArrayList<TestEntity>();
    for (int i = 0; i < 10; i++) {
        TestEntity testEntity = new TestEntity();
        testEntity.setSimpleInt(i + 1);
        testEntity.setSimpleStringNotNull("string-" + (i + 1));
        targetEntities.add(testEntity);
    }
    testEntityDao.insertInTx(targetEntities);
    List<RelationEntity> entities = new ArrayList<RelationEntity>();
    for (int i = 0; i < 10; i++) {
        RelationEntity entity = new RelationEntity();
        entity.setSimpleString("entity-" + (i + 1));
        entity.setTestNotNull(targetEntities.get(i));
        entities.add(entity);
    }
    relationEntityDao.insertInTx(entities);
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) ArrayList(java.util.ArrayList) RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 65 with TestEntity

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

the class TestEntityIdentityScopeTest method testDetachOther.

public void testDetachOther() {
    TestEntity entity = createEntity(null);
    dao.insert(entity);
    dao.detach(entity);
    TestEntity entity2 = dao.load(entity.getId());
    dao.detach(entity);
    TestEntity entity3 = dao.load(entity.getId());
    assertSame(entity2, entity3);
}
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