use of org.apache.cassandra.cql3.functions.Function in project RxJava by ReactiveX.
the class ObservableDebounceTest method debounceSelectorNormal1.
@Test
public void debounceSelectorNormal1() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> debouncer = PublishSubject.create();
Function<Integer, Observable<Integer>> debounceSel = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return debouncer;
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.debounce(debounceSel).subscribe(o);
source.onNext(1);
debouncer.onNext(1);
source.onNext(2);
source.onNext(3);
source.onNext(4);
debouncer.onNext(2);
source.onNext(5);
source.onComplete();
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(4);
inOrder.verify(o).onNext(5);
inOrder.verify(o).onComplete();
verify(o, never()).onError(any(Throwable.class));
}
use of org.apache.cassandra.cql3.functions.Function in project RxJava by ReactiveX.
the class ObservableConcatMapCompletableTest method onErrorRace.
@Test
public void onErrorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishSubject<Integer> ps1 = PublishSubject.create();
final PublishSubject<Integer> ps2 = PublishSubject.create();
TestObserver<Void> to = ps1.concatMapCompletable(new Function<Integer, CompletableSource>() {
@Override
public CompletableSource apply(Integer v) throws Exception {
return Completable.fromObservable(ps2);
}
}).test();
final TestException ex1 = new TestException();
final TestException ex2 = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
ps1.onError(ex1);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
ps2.onError(ex2);
}
};
TestHelper.race(r1, r2);
to.assertFailure(TestException.class);
if (!errors.isEmpty()) {
TestHelper.assertError(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of org.apache.cassandra.cql3.functions.Function in project RxJava by ReactiveX.
the class ObservableDebounceTest method debounceSelectorObservableThrows.
@Test
public void debounceSelectorObservableThrows() {
PublishSubject<Integer> source = PublishSubject.create();
Function<Integer, Observable<Integer>> debounceSel = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return Observable.error(new TestException());
}
};
Observer<Object> o = TestHelper.mockObserver();
source.debounce(debounceSel).subscribe(o);
source.onNext(1);
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
verify(o).onError(any(TestException.class));
}
Aggregations