Search in sources :

Example 1 with TestEntity

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

the class QueryBuilderSimpleTest method testNotIn.

public void testNotIn() {
    ArrayList<TestEntity> inserted = insert(5);
    String value1 = getSimpleString(0);
    String value2 = getSimpleString(2);
    String value3 = getSimpleString(4);
    List<TestEntity> result = dao.queryBuilder().where(Properties.SimpleString.notIn(value1, value2, value3)).orderAsc(Properties.SimpleString).list();
    assertEquals(2, result.size());
    TestEntity resultEntity1 = result.get(0);
    assertEquals(inserted.get(1).getId(), resultEntity1.getId());
    TestEntity resultEntity2 = result.get(1);
    assertEquals(inserted.get(3).getId(), resultEntity2.getId());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 2 with TestEntity

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

the class QueryForThreadTest method testGetForCurrentThread_ParametersAreReset.

public void testGetForCurrentThread_ParametersAreReset() {
    insert(3);
    int value = getSimpleInteger(1);
    Query<TestEntity> query = dao.queryBuilder().where(Properties.SimpleInteger.eq(value)).build();
    query.setParameter(0, value + 1);
    TestEntity entityFor2 = query.unique();
    assertEquals(value + 1, (int) entityFor2.getSimpleInteger());
    query = query.forCurrentThread();
    assertNotNull(query.unique());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 3 with TestEntity

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

the class RawQueryTest method testRawQueryEqualsString.

public void testRawQueryEqualsString() {
    ArrayList<TestEntity> inserted = insert(3);
    String value = getSimpleString(1);
    String sql = "WHERE " + Properties.SimpleString.columnName + "=?";
    List<TestEntity> result = dao.queryRawCreate(sql, value).list();
    assertEquals(1, result.size());
    TestEntity resultEntity = result.get(0);
    assertEquals(value, resultEntity.getSimpleString());
    assertEquals(inserted.get(1).getId(), resultEntity.getId());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 4 with TestEntity

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

the class RxDaoTest method testInsertOrReplace.

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

Example 5 with TestEntity

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

the class RxDaoTest method testInsertOrReplaceInTxList.

public void testInsertOrReplaceInTxList() {
    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.insertOrReplaceInTx(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