use of io.realm.entities.AllTypes 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();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RxJavaTests method realmResults_emittedOnSubscribe.
@Test
@UiThreadTest
public void realmResults_emittedOnSubscribe() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<AllTypes> results = realm.where(AllTypes.class).findAll();
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();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RxJavaTests method findFirst_emittedOnSubscribe.
@Test
@UiThreadTest
public void findFirst_emittedOnSubscribe() {
realm.beginTransaction();
realm.createObject(AllTypes.class).setColumnLong(42);
realm.commitTransaction();
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = realm.where(AllTypes.class).equalTo(AllTypes.FIELD_LONG, 42).findFirst().<AllTypes>asObservable().subscribe(new Action1<AllTypes>() {
@Override
public void call(AllTypes rxObject) {
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.unsubscribe();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RxJavaTests method wrongGenericClassThrows.
@Test
@UiThreadTest
public void wrongGenericClassThrows() {
realm.beginTransaction();
final AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
Observable<CyclicType> obs = obj.asObservable();
obs.subscribe(new Action1<CyclicType>() {
@Override
public void call(CyclicType cyclicType) {
fail();
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable ignored) {
}
});
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RxJavaTests method findFirstAsync_emittedOnDelete.
@Test
@RunTestInLooperThread
public void findFirstAsync_emittedOnDelete() {
final AtomicInteger subscriberCalled = new AtomicInteger(0);
final Realm realm = looperThread.realm;
realm.beginTransaction();
final AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
subscription = realm.where(AllTypes.class).findFirstAsync().<AllTypes>asObservable().subscribe(new Action1<AllTypes>() {
@Override
public void call(final AllTypes rxObject) {
switch(subscriberCalled.incrementAndGet()) {
case 1:
assertFalse(rxObject.isLoaded());
break;
case 2:
assertTrue(rxObject.isLoaded());
assertTrue(rxObject.isValid());
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.delete(AllTypes.class);
}
});
break;
case 3:
assertTrue(rxObject.isLoaded());
assertFalse(rxObject.isValid());
looperThread.testComplete();
break;
default:
fail();
}
}
});
}
Aggregations