Search in sources :

Example 41 with TestEntity

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

the class QueryBuilderOrderTest method testOrderUmlauts.

public void testOrderUmlauts() {
    List<TestEntity> list = new ArrayList<TestEntity>();
    TestEntity entityV = addEntity(list, "V");
    TestEntity entityB = addEntity(list, "B");
    TestEntity entityUE = addEntity(list, "Ü");
    TestEntity entityAE = addEntity(list, "Ä");
    dao.insertInTx(list);
    List<TestEntity> result = dao.queryBuilder().preferLocalizedStringOrder().orderAsc(Properties.SimpleString).list();
    assertEquals(list.size(), result.size());
    assertEquals(entityAE.getId(), result.get(0).getId());
    assertEquals(entityB.getId(), result.get(1).getId());
    assertEquals(entityUE.getId(), result.get(2).getId());
    assertEquals(entityV.getId(), result.get(3).getId());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) ArrayList(java.util.ArrayList)

Example 42 with TestEntity

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

the class QueryBuilderSimpleTest method testEqStringAndInteger.

public void testEqStringAndInteger() {
    ArrayList<TestEntity> inserted = insert(3);
    String valueStr = getSimpleString(1);
    int valueInt = getSimpleInteger(1);
    List<TestEntity> result = dao.queryBuilder().where(Properties.SimpleString.eq(valueStr), Properties.SimpleInteger.eq(valueInt)).list();
    assertEquals(1, result.size());
    TestEntity resultEntity = result.get(0);
    assertEquals(inserted.get(1).getId(), resultEntity.getId());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 43 with TestEntity

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

the class QueryBuilderSimpleTest method testIn.

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

Example 44 with TestEntity

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

the class RxDaoTest method testLoadAll.

public void testLoadAll() {
    insertEntity("foo");
    insertEntity("bar");
    TestSubscriber<List<TestEntity>> testSubscriber = RxTestHelper.awaitTestSubscriber(rxDao.loadAll());
    assertEquals(1, testSubscriber.getValueCount());
    List<TestEntity> entities = testSubscriber.getOnNextEvents().get(0);
    // Order of entities is unspecified
    int foo = 0, bar = 0;
    for (TestEntity entity : entities) {
        String value = entity.getSimpleStringNotNull();
        if (value.equals("foo")) {
            foo++;
        } else if (value.equals("bar")) {
            bar++;
        } else {
            fail(value);
        }
    }
    assertEquals(1, foo);
    assertEquals(1, bar);
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) List(java.util.List) ArrayList(java.util.ArrayList)

Example 45 with TestEntity

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

the class RxDaoTest method testDeleteByKey.

public void testDeleteByKey() {
    TestEntity foo = insertEntity("foo");
    assertDeleted(rxDao.deleteByKey(foo.getId()));
}
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