use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.
the class RxJavaTests method asFlowable_frozenRealmList.
@Test
@RunTestInLooperThread
public void asFlowable_frozenRealmList() {
realm.beginTransaction();
final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
list.add(new Dog("dog"));
realm.commitTransaction();
RealmList<Dog> frozenList = list.freeze();
subscription = frozenList.asFlowable().subscribe(rxList -> {
assertTrue(rxList.isFrozen());
assertEquals(frozenList, rxList);
disposeSuccessfulTest(realm);
});
}
use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.
the class RxJavaTests method asFlowable_frozenRealmObject.
@Test
@RunTestInLooperThread
public void asFlowable_frozenRealmObject() {
realm.beginTransaction();
final AllJavaTypes obj = realm.createObject(AllJavaTypes.class, 42);
realm.commitTransaction();
subscription = obj.<AllJavaTypes>freeze().<AllJavaTypes>asFlowable().subscribe(rxObject -> {
assertTrue(rxObject.isFrozen());
assertNotEquals(rxObject, obj);
assertEquals(rxObject.getFieldId(), obj.getFieldId());
disposeSuccessfulTest(realm);
});
}
use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.
the class RxJavaTests method asChangesetObservable_frozenRealmList.
@Test
@RunTestInLooperThread
public void asChangesetObservable_frozenRealmList() {
realm.beginTransaction();
final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
list.add(new Dog("dog"));
realm.commitTransaction();
RealmList<Dog> frozenList = list.freeze();
subscription = frozenList.asChangesetObservable().subscribe(change -> {
RealmList<Dog> rxList = change.getCollection();
assertTrue(rxList.isFrozen());
assertEquals(frozenList, rxList);
assertNull(change.getChangeset());
disposeSuccessfulTest(realm);
});
}
use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.
the class RxJavaTests method realmList_emittedOnSubscribe.
@Test
@RunTestInLooperThread
public void realmList_emittedOnSubscribe() {
realm.beginTransaction();
final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
list.add(new Dog("dog"));
realm.commitTransaction();
subscription = list.asFlowable().subscribe(rxList -> {
assertTrue(rxList.isFrozen());
assertEquals(1, rxList.size());
assertEquals("dog", rxList.first().getName());
disposeSuccessfulTest(realm);
});
}
use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.
the class RxJavaTests method asFlowable_frozenDynamicRealmList.
@Test
@RunTestInLooperThread
public void asFlowable_frozenDynamicRealmList() {
realm.beginTransaction();
final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
list.add(new Dog("dog"));
realm.commitTransaction();
DynamicRealm dynamicRealm = DynamicRealm.getInstance(looperThread.getConfiguration());
RealmList<DynamicRealmObject> frozenList = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst().getList(AllTypes.FIELD_REALMLIST).freeze();
subscription = frozenList.asFlowable().subscribe(rxList -> {
assertTrue(rxList.isFrozen());
assertEquals(frozenList, rxList);
disposeSuccessfulTest(dynamicRealm);
});
}
Aggregations