use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class DynamicRealmObjectTests method isNull_true.
@Test
public void isNull_true() {
realm.beginTransaction();
AllJavaTypes obj = realm.createObject(AllJavaTypes.class, 0);
realm.commitTransaction();
assertTrue(new DynamicRealmObject(obj).isNull(AllJavaTypes.FIELD_OBJECT));
}
use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class DynamicRealmObjectTests method hashcode.
@Test
public void hashcode() {
AllJavaTypes standardObj = realm.where(AllJavaTypes.class).findFirst();
DynamicRealmObject dObj1 = new DynamicRealmObject(standardObj);
assertEquals(standardObj.hashCode(), dObj1.hashCode());
}
use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class DynamicRealmObjectTests method setObject_wrongTypeThrows.
@Test
public void setObject_wrongTypeThrows() {
realm.beginTransaction();
AllJavaTypes obj = realm.createObject(AllJavaTypes.class, 0);
Dog otherObj = realm.createObject(Dog.class);
DynamicRealmObject dynamicObj = new DynamicRealmObject(obj);
DynamicRealmObject dynamicWrongType = new DynamicRealmObject(otherObj);
thrown.expect(IllegalArgumentException.class);
dynamicObj.setObject(AllJavaTypes.FIELD_OBJECT, dynamicWrongType);
}
use of io.realm.entities.AllJavaTypes 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.AllJavaTypes in project realm-java by realm.
the class OrderedRealmCollectionIteratorTests method iterator_oneElement.
@Test
public void iterator_oneElement() {
collection = createCollection(realm, collectionClass, 1);
Iterator<AllJavaTypes> it = collection.iterator();
//noinspection WhileLoopReplaceableByForEach
int i = 0;
while (it.hasNext()) {
AllJavaTypes item = it.next();
assertEquals(0, item.getFieldLong());
i++;
}
assertEquals(1, collection.size());
assertEquals(1, i);
}
Aggregations