use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmObjectTests method createCyclicData.
private CyclicType createCyclicData(Realm realm) {
CyclicType foo = realm.createObject(CyclicType.class);
foo.setName("Foo");
CyclicType bar = realm.createObject(CyclicType.class);
bar.setName("Bar");
// Setups cycle on normal object references.
foo.setObject(bar);
bar.setObject(foo);
return foo;
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmObjectTests method equals_afterModification.
@Test
public void equals_afterModification() {
realm.beginTransaction();
CyclicType ct = realm.createObject(CyclicType.class);
ct.setName("Foo");
realm.commitTransaction();
CyclicType ct1 = realm.where(CyclicType.class).findFirst();
CyclicType ct2 = realm.where(CyclicType.class).findFirst();
realm.beginTransaction();
ct1.setName("Baz");
realm.commitTransaction();
assertTrue(ct1.equals(ct2));
assertTrue(ct2.equals(ct1));
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmObjectTests method setter_list_withDeletedObject.
@Test
public void setter_list_withDeletedObject() {
realm.beginTransaction();
try {
CyclicType target = realm.createObject(CyclicType.class);
CyclicType removed = realm.createObject(CyclicType.class);
removed.deleteFromRealm();
RealmList<CyclicType> list = new RealmList<CyclicType>();
list.add(realm.createObject(CyclicType.class));
// List contains a deleted object.
list.add(removed);
list.add(realm.createObject(CyclicType.class));
try {
target.setObjects(list);
fail();
} catch (IllegalArgumentException ignored) {
}
} finally {
realm.cancelTransaction();
}
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmObjectTests method setter_link_null.
@Test
public void setter_link_null() {
realm.beginTransaction();
CyclicType objA = realm.createObject(CyclicType.class);
objA.setName("Foo");
CyclicType objB = realm.createObject(CyclicType.class);
objB.setName("Bar");
objA.setObject(objB);
assertNotNull(objA.getObject());
try {
objA.setObject(null);
} catch (NullPointerException nullPointer) {
fail();
}
realm.commitTransaction();
assertNull(objA.getObject());
}
Aggregations