use of io.realm.entities.CyclicType in project realm-java by realm.
the class DynamicRealmObjectTests method untypedSetter_listMixedTypesThrows.
@Test
public void untypedSetter_listMixedTypesThrows() {
realm.beginTransaction();
AllJavaTypes obj1 = realm.createObject(AllJavaTypes.class, 2);
CyclicType obj2 = realm.createObject(CyclicType.class);
RealmList<DynamicRealmObject> list = new RealmList<DynamicRealmObject>();
list.add(new DynamicRealmObject(obj1));
list.add(new DynamicRealmObject(obj2));
thrown.expect(IllegalArgumentException.class);
dObjTyped.set(AllJavaTypes.FIELD_LIST, list);
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class DynamicRealmObjectTests method untypedSetter_listRealmAnyTypesThrows.
@Test
public void untypedSetter_listRealmAnyTypesThrows() {
realm.beginTransaction();
AllJavaTypes obj1 = realm.createObject(AllJavaTypes.class, 2);
CyclicType obj2 = realm.createObject(CyclicType.class);
RealmList<DynamicRealmObject> list = new RealmList<DynamicRealmObject>();
list.add(new DynamicRealmObject(obj1));
list.add(new DynamicRealmObject(obj2));
thrown.expect(IllegalArgumentException.class);
dObjTyped.set(AllJavaTypes.FIELD_LIST, list);
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class BulkInsertTests method insert_cyclicType.
@Test
public void insert_cyclicType() {
CyclicType oneCyclicType = new CyclicType();
oneCyclicType.setName("One");
CyclicType anotherCyclicType = new CyclicType();
anotherCyclicType.setName("Two");
oneCyclicType.setObject(anotherCyclicType);
anotherCyclicType.setObject(oneCyclicType);
realm.beginTransaction();
realm.insert(Arrays.asList(oneCyclicType, anotherCyclicType));
realm.commitTransaction();
RealmResults<CyclicType> realmObjects = realm.where(CyclicType.class).sort(CyclicType.FIELD_NAME).findAll();
assertNotNull(realmObjects);
assertEquals(2, realmObjects.size());
assertEquals("One", realmObjects.get(0).getName());
assertEquals("Two", realmObjects.get(0).getObject().getName());
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmListTests method setList_clearsOldItems.
@Test
public void setList_clearsOldItems() {
realm.beginTransaction();
CyclicType one = realm.copyToRealm(new CyclicType());
CyclicType two = realm.copyToRealm(new CyclicType());
assertEquals(0, two.getObjects().size());
two.setObjects(new RealmList<CyclicType>(one));
assertEquals(1, two.getObjects().size());
two.setObjects(new RealmList<CyclicType>(one, two));
assertEquals(2, two.getObjects().size());
}
use of io.realm.entities.CyclicType in project realm-java by realm.
the class RealmListTests method add_unmanagedObjectToManagedList.
// Tests that add correctly uses Realm.copyToRealm() on unmanaged objects.
@Test
public void add_unmanagedObjectToManagedList() {
realm.beginTransaction();
CyclicType parent = realm.createObject(CyclicType.class);
RealmList<CyclicType> children = parent.getObjects();
children.add(new CyclicType());
realm.commitTransaction();
assertEquals(1, realm.where(CyclicType.class).findFirst().getObjects().size());
}
Aggregations