Search in sources :

Example 36 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class LambdaObserverTest method disposedObserverShouldReportErrorOnGlobalErrorHandler.

@Test
public void disposedObserverShouldReportErrorOnGlobalErrorHandler() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        final List<Throwable> observerErrors = Collections.synchronizedList(new ArrayList<>());
        LambdaObserver<Integer> o = new LambdaObserver<>(Functions.<Integer>emptyConsumer(), new Consumer<Throwable>() {

            @Override
            public void accept(Throwable t) {
                observerErrors.add(t);
            }
        }, Functions.EMPTY_ACTION, Functions.<Disposable>emptyConsumer());
        o.dispose();
        o.onError(new IOException());
        o.onError(new IOException());
        assertTrue(observerErrors.isEmpty());
        TestHelper.assertUndeliverable(errors, 0, IOException.class);
        TestHelper.assertUndeliverable(errors, 1, IOException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : IOException(java.io.IOException) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 37 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class ObservableDematerializeTest method honorsContractWhenThrows.

@Test
public void honorsContractWhenThrows() {
    Observable<Integer> source = Observable.error(new TestException());
    Observable<Integer> result = source.materialize().dematerialize(Functions.<Notification<Integer>>identity());
    Observer<Integer> o = TestHelper.mockObserver();
    result.subscribe(o);
    verify(o, never()).onNext(any(Integer.class));
    verify(o, never()).onComplete();
    verify(o).onError(any(TestException.class));
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 38 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class ObservableDematerializeTest method eventsAfterDematerializedTerminal.

@Test
public void eventsAfterDematerializedTerminal() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        new Observable<Notification<Object>>() {

            @Override
            protected void subscribeActual(Observer<? super Notification<Object>> observer) {
                observer.onSubscribe(Disposable.empty());
                observer.onNext(Notification.createOnComplete());
                observer.onNext(Notification.<Object>createOnNext(1));
                observer.onNext(Notification.createOnError(new TestException("First")));
                observer.onError(new TestException("Second"));
            }
        }.dematerialize(Functions.<Notification<Object>>identity()).test().assertResult();
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
        TestHelper.assertUndeliverable(errors, 1, TestException.class, "Second");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 39 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class SingleSubscribeTest method consumerDispose.

@Test
public void consumerDispose() {
    PublishSubject<Integer> ps = PublishSubject.create();
    Disposable d = ps.single(-99).subscribe(Functions.<Integer>emptyConsumer());
    assertFalse(d.isDisposed());
    d.dispose();
    assertTrue(d.isDisposed());
    assertFalse(ps.hasObservers());
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)30 TestException (io.reactivex.rxjava3.exceptions.TestException)24 RxMethod (io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod)6 IOException (java.io.IOException)6 Observable (io.reactivex.rxjava3.core.Observable)5 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)5 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)4 Maps (com.google.common.collect.Maps)2 String.format (java.lang.String.format)2 ByteBuffer (java.nio.ByteBuffer)2 CharacterCodingException (java.nio.charset.CharacterCodingException)2 java.util (java.util)2 TimeUnit (java.util.concurrent.TimeUnit)2 Pattern (java.util.regex.Pattern)2 Collectors (java.util.stream.Collectors)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 org.apache.cassandra.config (org.apache.cassandra.config)2 org.apache.cassandra.cql3 (org.apache.cassandra.cql3)2 QueryProcessor.executeInternal (org.apache.cassandra.cql3.QueryProcessor.executeInternal)2