Search in sources :

Example 1 with RealmModelWithRealmModelField

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

the class RealmModelTests method realmModelWithRealmModelField.

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

Aggregations

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