use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmObjectTests method getRealm_closedObjectThrows.
@Test
public void getRealm_closedObjectThrows() {
realm.beginTransaction();
AllTypes object = realm.createObject(AllTypes.class);
realm.commitTransaction();
realm.close();
realm = null;
try {
object.getRealm();
fail();
} catch (IllegalStateException e) {
assertEquals(BaseRealm.CLOSED_REALM_MESSAGE, e.getMessage());
}
try {
RealmObject.getRealm(object);
fail();
} catch (IllegalStateException e) {
assertEquals(BaseRealm.CLOSED_REALM_MESSAGE, e.getMessage());
}
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmObjectTests method isValid_unmanagedObject.
@Test
public void isValid_unmanagedObject() {
AllTypes allTypes = new AllTypes();
assertTrue(allTypes.isValid());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmObjectTests method changeListener_triggeredWhenObjectIsDeleted.
@Test
@RunTestInLooperThread
public void changeListener_triggeredWhenObjectIsDeleted() {
final Realm realm = looperThread.getRealm();
realm.beginTransaction();
AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
obj.addChangeListener(new RealmChangeListener<AllTypes>() {
@Override
public void onChange(AllTypes obj) {
assertFalse(obj.isValid());
looperThread.testComplete();
}
});
realm.beginTransaction();
obj.deleteFromRealm();
realm.commitTransaction();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmObjectTests method float_double_NaN.
// Tests NaN value on float and double columns.
@Test
public void float_double_NaN() {
realm.beginTransaction();
AllTypes allTypes = realm.createObject(AllTypes.class);
allTypes.setColumnFloat(Float.NaN);
allTypes.setColumnDouble(Double.NaN);
realm.commitTransaction();
assertEquals(Float.NaN, realm.where(AllTypes.class).findFirst().getColumnFloat(), 0.0F);
assertEquals(Double.NaN, realm.where(AllTypes.class).findFirst().getColumnDouble(), 0.0D);
// NaN != NaN !!!
assertEquals(0, realm.where(AllTypes.class).equalTo("columnFloat", Float.NaN).count());
assertEquals(0, realm.where(AllTypes.class).equalTo("columnDouble", Double.NaN).count());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmObjectTests method getRealmConfiguration_deletedObjectThrows.
@Test
public void getRealmConfiguration_deletedObjectThrows() {
realm.beginTransaction();
AllTypes object = realm.createObject(AllTypes.class);
object.deleteFromRealm();
realm.commitTransaction();
try {
object.getRealm();
fail();
} catch (IllegalStateException e) {
assertEquals(RealmObject.MSG_DELETED_OBJECT, e.getMessage());
}
try {
RealmObject.getRealm(object);
fail();
} catch (IllegalStateException e) {
assertEquals(RealmObject.MSG_DELETED_OBJECT, e.getMessage());
}
}
Aggregations