use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmObjectTests method setter_link_deletedObject.
@Test
public void setter_link_deletedObject() {
realm.beginTransaction();
try {
CyclicType target = realm.createObject(CyclicType.class);
CyclicType removed = realm.createObject(CyclicType.class);
removed.deleteFromRealm();
try {
target.setObject(removed);
fail();
} catch (IllegalArgumentException ignored) {
}
} finally {
realm.cancelTransaction();
}
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmObjectTests method toString_cyclicObject.
@Test
public void toString_cyclicObject() {
realm.beginTransaction();
CyclicType foo = createCyclicData();
realm.commitTransaction();
assertEquals("CyclicType = proxy[{id:0},{name:Foo},{date:null},{object:CyclicType},{otherObject:null},{objects:RealmList<CyclicType>[0]}]", foo.toString());
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmObjectTests method setter_link_closedObject.
@Test
public void setter_link_closedObject() {
realm.beginTransaction();
CyclicType closed = realm.createObject(CyclicType.class);
realm.commitTransaction();
realm.close();
assertTrue(realm.isClosed());
realm = Realm.getInstance(realmConfig);
realm.beginTransaction();
try {
CyclicType target = realm.createObject(CyclicType.class);
try {
target.setObject(closed);
fail();
} catch (IllegalArgumentException ignored) {
}
} finally {
realm.cancelTransaction();
}
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class CollectionTests method populateCollectionOnDeletedLinkView.
// Creates a collection that is based on a RealmList that was deleted.
protected OrderedRealmCollection<CyclicType> populateCollectionOnDeletedLinkView(Realm realm, ManagedCollection collectionClass) {
realm.beginTransaction();
CyclicType parent = realm.createObject(CyclicType.class);
for (int i = 0; i < 10; i++) {
CyclicType child = new CyclicType();
child.setName("name_" + i);
child.setObject(parent);
parent.getObjects().add(child);
}
realm.commitTransaction();
OrderedRealmCollection<CyclicType> result;
switch(collectionClass) {
case MANAGED_REALMLIST:
result = parent.getObjects();
break;
case REALMRESULTS:
result = parent.getObjects().where().equalTo(CyclicType.FIELD_NAME, "name_0").findAll();
break;
default:
throw new AssertionError("Unknown collection: " + collectionClass);
}
realm.beginTransaction();
parent.deleteFromRealm();
realm.commitTransaction();
return result;
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmTests method copyFromRealm_checkMaxDepth.
// Tests that for (A -> B -> C) for maxDepth = 1, result is (A -> B -> null).
@Test
public void copyFromRealm_checkMaxDepth() {
realm.beginTransaction();
CyclicType objA = realm.createObject(CyclicType.class);
objA.setName("A");
CyclicType objB = realm.createObject(CyclicType.class);
objB.setName("B");
CyclicType objC = realm.createObject(CyclicType.class);
objC.setName("C");
objA.setObject(objB);
objC.setObject(objC);
objA.getObjects().add(objB);
objA.getObjects().add(objC);
realm.commitTransaction();
CyclicType copyA = realm.copyFromRealm(objA, 1);
assertNull(copyA.getObject().getObject());
}
Aggregations