use of android.support.test.annotation.UiThreadTest in project realm-java by realm.
the class RxJavaTests method realmResults_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void realmResults_closeInDoOnUnsubscribe() {
Observable<RealmResults<AllTypes>> observable = realm.where(AllTypes.class).findAll().asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
realm.close();
}
});
subscription = observable.subscribe(new Action1<RealmResults<AllTypes>>() {
@Override
public void call(RealmResults<AllTypes> allTypes) {
}
});
subscription.unsubscribe();
assertTrue(realm.isClosed());
}
use of android.support.test.annotation.UiThreadTest in project realm-java by realm.
the class RxJavaTests method dynamicRealm_emittedOnSubscribe.
@Test
@UiThreadTest
public void dynamicRealm_emittedOnSubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = dynamicRealm.asObservable().subscribe(new Action1<DynamicRealm>() {
@Override
public void call(DynamicRealm rxRealm) {
assertTrue(rxRealm == dynamicRealm);
subscribedNotified.set(true);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
throwable.printStackTrace();
}
});
assertTrue(subscribedNotified.get());
dynamicRealm.close();
subscription.unsubscribe();
}
use of android.support.test.annotation.UiThreadTest in project realm-java by realm.
the class RxJavaTests method realm_emittedOnSubscribe.
@Test
@UiThreadTest
public void realm_emittedOnSubscribe() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = realm.asObservable().subscribe(new Action1<Realm>() {
@Override
public void call(Realm rxRealm) {
assertTrue(rxRealm == realm);
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.unsubscribe();
}
use of android.support.test.annotation.UiThreadTest in project realm-java by realm.
the class RxJavaTests method dynamicRealm_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void dynamicRealm_closeInDoOnUnsubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
Observable<DynamicRealm> observable = dynamicRealm.asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
dynamicRealm.close();
}
});
subscription = observable.subscribe(new Action1<DynamicRealm>() {
@Override
public void call(DynamicRealm rxRealm) {
}
});
subscription.unsubscribe();
assertTrue(dynamicRealm.isClosed());
}
use of android.support.test.annotation.UiThreadTest in project realm-java by realm.
the class RxJavaTests method findAllAsync_emittedOnSubscribe.
@Test
@UiThreadTest
public void findAllAsync_emittedOnSubscribe() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<AllTypes> results = realm.where(AllTypes.class).findAllAsync();
subscription = results.asObservable().subscribe(new Action1<RealmResults<AllTypes>>() {
@Override
public void call(RealmResults<AllTypes> rxResults) {
assertTrue(rxResults == results);
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.unsubscribe();
}
Aggregations