use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class TestObserverExTest method assertErrorMultiple.
@Test
public void assertErrorMultiple() {
TestObserverEx<Integer> to = new TestObserverEx<>();
TestException e = new TestException();
to.errors().add(e);
to.errors().add(new TestException());
try {
to.assertError(TestException.class);
throw new RuntimeException("Should have thrown!");
} catch (AssertionError ex) {
// expected
}
try {
to.assertError(e);
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 ex) {
// expected
}
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class FlowableSubscriberTest method doubleSubscribe.
@Test
public void doubleSubscribe() {
ForEachWhileSubscriber<Integer> s = new ForEachWhileSubscriber<>(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
return true;
}
}, Functions.<Throwable>emptyConsumer(), Functions.EMPTY_ACTION);
List<Throwable> list = TestHelper.trackPluginErrors();
try {
s.onSubscribe(new BooleanSubscription());
BooleanSubscription bs = new BooleanSubscription();
s.onSubscribe(bs);
assertTrue(bs.isCancelled());
TestHelper.assertError(list, 0, IllegalStateException.class, "Subscription already set!");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class ParallelSortedJoinTest method error3.
@Test
public void error3() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.<Integer>error(new TestException()).parallel().sorted(Functions.<Integer>naturalComparator()).test(0).assertFailure(TestException.class);
assertTrue(errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class ParallelSortedJoinTest method error.
@Test
public void error() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.<Integer>error(new TestException()).parallel().sorted(Functions.<Integer>naturalComparator()).test().assertFailure(TestException.class);
assertTrue(errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.
the class TestObserverTest method assertError.
@Test
public void assertError() {
TestObserver<Integer> to = TestObserver.create();
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.assertSubscribed();
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");
}
});
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.assertValueCount(0);
to.assertNoValues();
}
Aggregations