use of io.reactivex.rxjava3.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.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.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();
}
use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.
the class TestObserverTest method assertErrorMultiple.
@Test
public void assertErrorMultiple() {
TestObserver<Integer> to = new TestObserver<>();
TestException e = new TestException();
to.onError(e);
to.onError(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
}
}
use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.
the class ConnectableFlowable method connect.
/**
* Instructs the {@code ConnectableFlowable} to begin emitting the items from its underlying
* {@link Flowable} to its {@link Subscriber}s.
* <p>
* To disconnect from a synchronous source, use the {@link #connect(io.reactivex.rxjava3.functions.Consumer)} method.
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>The behavior is determined by the implementor of this abstract class.</dd>
* </dl>
*
* @return the subscription representing the connection
* @see <a href="http://reactivex.io/documentation/operators/connect.html">ReactiveX documentation: Connect</a>
*/
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable connect() {
ConnectConsumer cc = new ConnectConsumer();
connect(cc);
return cc.disposable;
}
Aggregations