Search in sources :

Example 1 with RealmObjectWithRealmModelField

use of io.realm.entities.pojo.RealmObjectWithRealmModelField in project realm-java by realm.

the class RealmModelTests method realmObjectWithRealmModelField.

// Tests the behaviour of a RealmObject, containing a RealmModel field.
@Test
public void realmObjectWithRealmModelField() {
    RealmObjectWithRealmModelField realmObjectWithRealmModelField = new RealmObjectWithRealmModelField();
    AllTypesRealmModel allTypePojo = new AllTypesRealmModel();
    allTypePojo.columnLong = 42;
    realmObjectWithRealmModelField.setAllTypesRealmModel(allTypePojo);
    realm.beginTransaction();
    realm.copyToRealm(realmObjectWithRealmModelField);
    realm.commitTransaction();
    RealmResults<RealmObjectWithRealmModelField> all = realm.where(RealmObjectWithRealmModelField.class).findAll();
    assertEquals(1, all.size());
    assertEquals(42, all.first().getAllTypesRealmModel().columnLong);
}
Also used : AllTypesRealmModel(io.realm.entities.pojo.AllTypesRealmModel) RealmObjectWithRealmModelField(io.realm.entities.pojo.RealmObjectWithRealmModelField) Test(org.junit.Test)

Aggregations

AllTypesRealmModel (io.realm.entities.pojo.AllTypesRealmModel)1 RealmObjectWithRealmModelField (io.realm.entities.pojo.RealmObjectWithRealmModelField)1 Test (org.junit.Test)1