use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class LazyListTest method testUncached.
public void testUncached() {
insert(1);
LazyList<TestEntity> listLazy = dao.queryBuilder().build().listLazyUncached();
assertFalse(listLazy.isEmpty());
assertFalse(listLazy.isClosed());
TestEntity entity1 = listLazy.get(0);
TestEntity entity2 = listLazy.get(0);
assertEquals(entity1.getId(), entity2.getId());
if (identityScopeForDao == null) {
assertNotSame(entity1, entity2);
} else {
assertSame(entity1, entity2);
}
assertFalse(listLazy.isClosed());
try {
listLazy.loadRemaining();
fail("Not empty");
} catch (DaoException expected) {
// Expected, OK
}
listLazy.close();
assertTrue(listLazy.isClosed());
}
use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class QueryBuilderOrderTest method testOrderDesc.
public void testOrderDesc() {
ArrayList<TestEntity> inserted = insert(2);
TestEntity entity = inserted.get(1);
List<TestEntity> result = dao.queryBuilder().orderDesc(Properties.SimpleInteger).list();
assertEquals(2, result.size());
assertEquals(entity.getId(), result.get(0).getId());
result = dao.queryBuilder().orderDesc(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 addEntity.
private TestEntity addEntity(List<TestEntity> list, String simpleString) {
TestEntity entityAB = createEntity(42, simpleString);
list.add(entityAB);
return entityAB;
}
use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class QueryBuilderOrderTest method testOrderCustom.
public void testOrderCustom() {
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().orderCustom(Properties.SimpleString, "ASC").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 QueryBuilderOrderTest method testOrderUpperLowercase.
public void testOrderUpperLowercase() {
List<TestEntity> list = new ArrayList<TestEntity>();
TestEntity entityAA = addEntity(list, "aa");
TestEntity entityAB = addEntity(list, "Ab");
TestEntity entityAC = addEntity(list, "ac");
TestEntity entityZA = addEntity(list, "ZA");
TestEntity entityZB = addEntity(list, "zB");
TestEntity entityZC = addEntity(list, "ZC");
Collections.shuffle(list);
dao.insertInTx(list);
List<TestEntity> result = dao.queryBuilder().orderAsc(Properties.SimpleString).list();
assertEquals(list.size(), result.size());
assertEquals(entityAA.getId(), result.get(0).getId());
assertEquals(entityAB.getId(), result.get(1).getId());
assertEquals(entityAC.getId(), result.get(2).getId());
assertEquals(entityZA.getId(), result.get(3).getId());
assertEquals(entityZB.getId(), result.get(4).getId());
assertEquals(entityZC.getId(), result.get(5).getId());
}
Aggregations