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());
}
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());
}
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());
}
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);
}
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()));
}
Aggregations