use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class QueryBuilderOrderTest method testOrderAsc.
public void testOrderAsc() {
ArrayList<TestEntity> inserted = insert(2);
TestEntity entity = inserted.get(0);
List<TestEntity> result = dao.queryBuilder().orderAsc(Properties.SimpleInteger).list();
assertEquals(2, result.size());
assertEquals(entity.getId(), result.get(0).getId());
result = dao.queryBuilder().orderAsc(Properties.SimpleInteger, Properties.SimpleString).list();
assertEquals(2, result.size());
assertEquals(entity.getId(), result.get(0).getId());
}
use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class QueryBuilderOrderTest method testOrderCustom_stringOrderCollation.
public void testOrderCustom_stringOrderCollation() {
List<TestEntity> list = new ArrayList<TestEntity>();
TestEntity entityAA = addEntity(list, "Aa");
TestEntity entityAB = addEntity(list, "ab");
TestEntity entityAC = addEntity(list, "Ac");
dao.insertInTx(list);
List<TestEntity> result = dao.queryBuilder().stringOrderCollation(null).orderAsc(Properties.SimpleString).list();
assertEquals(list.size(), result.size());
assertEquals(entityAA.getId(), result.get(0).getId());
assertEquals(entityAC.getId(), result.get(1).getId());
assertEquals(entityAB.getId(), result.get(2).getId());
result = dao.queryBuilder().stringOrderCollation("COLLATE BINARY").orderAsc(Properties.SimpleString).list();
assertEquals(list.size(), result.size());
assertEquals(entityAA.getId(), result.get(0).getId());
assertEquals(entityAC.getId(), result.get(1).getId());
assertEquals(entityAB.getId(), result.get(2).getId());
}
use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class QueryBuilderSimpleTest method testIsNullIsNotNull.
public void testIsNullIsNotNull() {
ArrayList<TestEntity> inserted = insert(2);
TestEntity testEntityNull = inserted.get(0);
TestEntity testEntityNotNull = inserted.get(1);
testEntityNull.setSimpleInteger(null);
testEntityNotNull.setSimpleInteger(42);
dao.update(testEntityNull);
dao.update(testEntityNotNull);
TestEntity testEntityNull2 = dao.queryBuilder().where(Properties.SimpleInteger.isNull()).uniqueOrThrow();
assertEquals(testEntityNull.getId(), testEntityNull2.getId());
TestEntity testEntityNotNull2 = dao.queryBuilder().where(Properties.SimpleInteger.isNotNull()).uniqueOrThrow();
assertEquals(testEntityNotNull.getId(), testEntityNotNull2.getId());
}
use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class QueryBuilderSimpleTest method testDistinct.
public void testDistinct() {
TestEntity entity = insert(3).get(1);
Query<TestEntity> query = dao.queryBuilder().distinct().where(Properties.SimpleString.eq(entity.getSimpleString())).build();
TestEntity entity2 = query.uniqueOrThrow();
assertEquals(entity.getId(), entity2.getId());
// TODO improve test to check functionality
}
use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class QueryBuilderSimpleTest method testEqInteger.
public void testEqInteger() {
ArrayList<TestEntity> inserted = insert(3);
int value = getSimpleInteger(1);
List<TestEntity> result = dao.queryBuilder().where(Properties.SimpleInteger.eq(value)).list();
assertEquals(1, result.size());
TestEntity resultEntity = result.get(0);
assertEquals(value, (int) resultEntity.getSimpleInteger());
assertEquals(inserted.get(1).getId(), resultEntity.getId());
}
Aggregations