use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class JoinTest method testJoinSimpleParameterValue.
public void testJoinSimpleParameterValue() {
prepareData();
QueryBuilder<RelationEntity> queryBuilder = createQueryBuilder(-1);
Query<RelationEntity> query = queryBuilder.build();
for (int i = 0; i < 10; i++) {
query.setParameter(0, i + 1);
RelationEntity unique = query.uniqueOrThrow();
assertEquals("entity-" + (i + 1), unique.getSimpleString());
}
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class RelationEntityTest method createEntity.
@Override
protected RelationEntity createEntity(Long key) {
RelationEntity entity = new RelationEntity();
entity.setId(key);
return entity;
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class RelationEntityTest method testToOneSelf.
public void testToOneSelf() {
RelationEntity entity = createEntity(1l);
dao.insert(entity);
entity = dao.load(1l);
assertNull(entity.getParent());
entity.setParentId(entity.getId());
dao.update(entity);
entity = dao.load(1l);
RelationEntity parent = entity.getParent();
assertEquals(entity.getId(), parent.getId());
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class RelationEntityTest method testToOne.
public void testToOne() {
RelationEntity entity = insertEntityWithRelations(42l);
entity = dao.load(entity.getId());
assertTestEntity(entity);
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class RelationEntityTest method testToOneUpdateKey.
public void testToOneUpdateKey() {
RelationEntity entity = insertEntityWithRelations(42l);
TestEntity testEntity = entity.getTestEntity();
RelationEntity entity2 = insertEntityWithRelations(43l);
TestEntity testEntity2 = entity2.getTestEntity();
entity.setTestId(testEntity2.getId());
assertEquals(testEntity2.getId(), entity.getTestEntity().getId());
entity.setTestId(null);
assertNull(entity.getTestEntity());
entity.setTestId(testEntity.getId());
assertEquals(testEntity.getId(), entity.getTestEntity().getId());
}
Aggregations