Search in sources :

Example 16 with RelationEntity

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

the class RelationEntityTest method testToOneNoMatchLoadDeep.

public void testToOneNoMatchLoadDeep() {
    RelationEntity entity = insertEntityWithRelations(42l);
    assertNotNull(entity.getTestEntity());
    entity.setTestId(23l);
    entity.setTestIdNotNull(-78);
    dao.update(entity);
    entity = dao.loadDeep(entity.getId());
    assertNull(entity.getTestEntity());
    assertNull(entity.getTestNotNull());
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 17 with RelationEntity

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

the class RelationEntityTest method testToOneNoMatch.

public void testToOneNoMatch() {
    RelationEntity entity = insertEntityWithRelations(42l);
    assertNotNull(entity.getTestEntity());
    entity.setTestId(23l);
    entity.setTestIdNotNull(-78);
    assertNull(entity.getTestEntity());
    assertNull(entity.getTestNotNull());
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 18 with RelationEntity

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

the class RelationEntityTest method testToOneUpdateEntity.

public void testToOneUpdateEntity() {
    RelationEntity entity = insertEntityWithRelations(42l);
    TestEntity testEntity = entity.getTestEntity();
    RelationEntity entity2 = insertEntityWithRelations(43l);
    TestEntity testEntity2 = entity2.getTestEntity();
    entity.setTestEntity(testEntity2);
    assertEquals(testEntity2.getId(), entity.getTestId());
    entity.setTestEntity(null);
    assertNull(entity.getTestId());
    entity.setTestEntity(testEntity);
    assertEquals(testEntity.getId(), entity.getTestId());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 19 with RelationEntity

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

the class RelationEntityTestIdentityScope method testToQueryDeepIdentityScope.

public void testToQueryDeepIdentityScope() {
    insertEntityWithRelations(42l);
    RelationEntity entity2 = insertEntityWithRelations(42l);
    String columnName = RelationEntityDao.Properties.SimpleString.columnName;
    List<RelationEntity> entityList = dao.queryDeep("WHERE T." + columnName + "=?", "findMe");
    assertEquals(2, entityList.size());
    RelationEntity entity = entityList.get(0);
    assertTestEntity(entity);
    entity2 = entityList.get(1);
    assertTestEntity(entity2);
    assertSame(entity.getTestEntity(), entity2.getTestEntity());
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 20 with RelationEntity

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

the class RelationEntityTestIdentityScope method testLoadDeepIdentityScope.

public void testLoadDeepIdentityScope() {
    RelationEntity entity = insertEntityWithRelations(42l);
    RelationEntity entity2 = dao.loadDeep(entity.getId());
    RelationEntity entity3 = dao.loadDeep(entity.getId());
    assertSame(entity, entity2);
    assertSame(entity, entity3);
    assertTestEntity(entity);
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Aggregations

RelationEntity (org.greenrobot.greendao.daotest.RelationEntity)20 TestEntity (org.greenrobot.greendao.daotest.TestEntity)5 ArrayList (java.util.ArrayList)1