use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class ObservableDematerializeTest method dematerialize3.
@Test
public void dematerialize3() {
Exception exception = new Exception("test");
Observable<Integer> o = Observable.error(exception);
Observable<Integer> dematerialize = o.materialize().dematerialize(Functions.<Notification<Integer>>identity());
Observer<Integer> observer = TestHelper.mockObserver();
dematerialize.subscribe(observer);
verify(observer, times(1)).onError(exception);
verify(observer, times(0)).onComplete();
verify(observer, times(0)).onNext(any(Integer.class));
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class ObservableDematerializeTest method errorPassThru.
@Test
public void errorPassThru() {
Exception exception = new Exception("test");
Observable<Notification<Integer>> o = Observable.error(exception);
Observable<Integer> dematerialize = o.dematerialize(Functions.<Notification<Integer>>identity());
Observer<Integer> observer = TestHelper.mockObserver();
dematerialize.subscribe(observer);
verify(observer, times(1)).onError(exception);
verify(observer, times(0)).onComplete();
verify(observer, times(0)).onNext(any(Integer.class));
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class ObservableGroupByTest method newGroupValueSelectorFails.
@Test
public void newGroupValueSelectorFails() {
TestObserver<Object> to1 = new TestObserver<>();
final TestObserver<Object> to2 = new TestObserver<>();
Observable.just(1).groupBy(Functions.<Integer>identity(), new Function<Integer, Object>() {
@Override
public Object apply(Integer v) throws Throwable {
throw new TestException();
}
}).doOnNext(new Consumer<GroupedObservable<Integer, Object>>() {
@Override
public void accept(GroupedObservable<Integer, Object> g) throws Throwable {
g.subscribe(to2);
}
}).subscribe(to1);
to1.assertValueCount(1).assertError(TestException.class).assertNotComplete();
to2.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class TestObserverExTest method assertFailure.
@Test
public void assertFailure() {
TestObserverEx<Integer> to = new TestObserverEx<>();
to.onSubscribe(Disposable.empty());
to.onError(new TestException("Forced failure"));
to.assertFailure(TestException.class);
to.assertFailure(Functions.<Throwable>alwaysTrue());
to.assertFailureAndMessage(TestException.class, "Forced failure");
to.onNext(1);
to.assertFailure(TestException.class, 1);
to.assertFailure(Functions.<Throwable>alwaysTrue(), 1);
to.assertFailureAndMessage(TestException.class, "Forced failure", 1);
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class TestObserverExTest method assertError.
@Test
public void assertError() {
TestObserverEx<Integer> to = new TestObserverEx<>();
try {
to.assertError(TestException.class);
throw new RuntimeException("Should have thrown");
} catch (AssertionError ex) {
// expected
}
try {
to.assertError(new TestException());
throw new RuntimeException("Should have thrown");
} catch (AssertionError ex) {
// expected
}
try {
to.assertError(Functions.<Throwable>alwaysTrue());
throw new RuntimeException("Should have thrown");
} catch (AssertionError ex) {
// expected
}
try {
to.assertErrorMessage("");
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
try {
to.assertSubscribed();
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
try {
to.assertTerminated();
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
to.onSubscribe(Disposable.empty());
to.assertSubscribed();
to.assertNoErrors();
TestException ex = new TestException("Forced failure");
to.onError(ex);
to.assertError(ex);
to.assertError(TestException.class);
to.assertError(Functions.<Throwable>alwaysTrue());
to.assertError(new Predicate<Throwable>() {
@Override
public boolean test(Throwable t) throws Exception {
return t.getMessage() != null && t.getMessage().contains("Forced");
}
});
to.assertErrorMessage("Forced failure");
try {
to.assertErrorMessage("");
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
try {
to.assertError(new RuntimeException());
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
try {
to.assertError(IOException.class);
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
try {
to.assertError(Functions.<Throwable>alwaysFalse());
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
try {
to.assertNoErrors();
throw new RuntimeException("Should have thrown");
} catch (AssertionError exc) {
// expected
}
to.assertTerminated();
to.assertValueCount(0);
to.assertNoValues();
}
Aggregations