Search in sources :

Example 86 with Observable

use of io.reactivex.Observable in project RxJava by ReactiveX.

the class ObservableDelayTest method testDelayWithObservableSubscriptionRunCompletion.

@Test
public void testDelayWithObservableSubscriptionRunCompletion() {
    PublishSubject<Integer> source = PublishSubject.create();
    final PublishSubject<Integer> sdelay = PublishSubject.create();
    final PublishSubject<Integer> delay = PublishSubject.create();
    Callable<Observable<Integer>> subFunc = new Callable<Observable<Integer>>() {

        @Override
        public Observable<Integer> call() {
            return sdelay;
        }
    };
    Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {

        @Override
        public Observable<Integer> apply(Integer t1) {
            return delay;
        }
    };
    Observer<Object> o = TestHelper.mockObserver();
    InOrder inOrder = inOrder(o);
    source.delay(Observable.defer(subFunc), delayFunc).subscribe(o);
    source.onNext(1);
    sdelay.onComplete();
    source.onNext(2);
    delay.onNext(2);
    inOrder.verify(o).onNext(2);
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onError(any(Throwable.class));
    verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder) Observable(io.reactivex.Observable)

Example 87 with Observable

use of io.reactivex.Observable in project RxJava by ReactiveX.

the class ObservableDelayTest method testDelayWithObservableSubscriptionThrows.

@Test
public void testDelayWithObservableSubscriptionThrows() {
    PublishSubject<Integer> source = PublishSubject.create();
    final PublishSubject<Integer> delay = PublishSubject.create();
    Callable<Observable<Integer>> subFunc = new Callable<Observable<Integer>>() {

        @Override
        public Observable<Integer> call() {
            return delay;
        }
    };
    Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {

        @Override
        public Observable<Integer> apply(Integer t1) {
            return delay;
        }
    };
    Observer<Object> o = TestHelper.mockObserver();
    InOrder inOrder = inOrder(o);
    source.delay(Observable.defer(subFunc), delayFunc).subscribe(o);
    source.onNext(1);
    delay.onError(new TestException());
    source.onNext(2);
    inOrder.verify(o).onError(any(TestException.class));
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder) TestException(io.reactivex.exceptions.TestException) Observable(io.reactivex.Observable)

Example 88 with Observable

use of io.reactivex.Observable in project RxJava by ReactiveX.

the class ObservableDelayTest method testDelayWithObservableEmptyDelayer.

@Test
public void testDelayWithObservableEmptyDelayer() {
    PublishSubject<Integer> source = PublishSubject.create();
    Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {

        @Override
        public Observable<Integer> apply(Integer t1) {
            return Observable.empty();
        }
    };
    Observer<Object> o = TestHelper.mockObserver();
    InOrder inOrder = inOrder(o);
    source.delay(delayFunc).subscribe(o);
    source.onNext(1);
    source.onComplete();
    inOrder.verify(o).onNext(1);
    inOrder.verify(o).onComplete();
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder) Observable(io.reactivex.Observable)

Example 89 with Observable

use of io.reactivex.Observable in project RxJava by ReactiveX.

the class ObservableDelayTest method testDelayWithObservableDelayFunctionThrows.

@Test
public void testDelayWithObservableDelayFunctionThrows() {
    PublishSubject<Integer> source = PublishSubject.create();
    Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {

        @Override
        public Observable<Integer> apply(Integer t1) {
            throw new TestException();
        }
    };
    Observer<Object> o = TestHelper.mockObserver();
    InOrder inOrder = inOrder(o);
    source.delay(delayFunc).subscribe(o);
    source.onNext(1);
    inOrder.verify(o).onError(any(TestException.class));
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder) TestException(io.reactivex.exceptions.TestException) Observable(io.reactivex.Observable)

Example 90 with Observable

use of io.reactivex.Observable in project RxJava by ReactiveX.

the class ObservableDelayTest method testDelayWithObservableSingleSend1.

@Test
public void testDelayWithObservableSingleSend1() {
    PublishSubject<Integer> source = PublishSubject.create();
    final PublishSubject<Integer> delay = PublishSubject.create();
    Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {

        @Override
        public Observable<Integer> apply(Integer t1) {
            return delay;
        }
    };
    Observer<Object> o = TestHelper.mockObserver();
    InOrder inOrder = inOrder(o);
    source.delay(delayFunc).subscribe(o);
    source.onNext(1);
    delay.onNext(1);
    delay.onNext(2);
    inOrder.verify(o).onNext(1);
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder) Observable(io.reactivex.Observable)

Aggregations

Observable (io.reactivex.Observable)170 List (java.util.List)54 ArrayList (java.util.ArrayList)39 Test (org.junit.Test)36 Collectors (java.util.stream.Collectors)29 InOrder (org.mockito.InOrder)27 TestException (io.reactivex.exceptions.TestException)24 Page (io.nem.symbol.sdk.api.Page)19 Address (io.nem.symbol.sdk.model.account.Address)18 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)18 Disposable (io.reactivex.disposables.Disposable)18 Bundle (android.os.Bundle)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 Function (io.reactivex.functions.Function)15 TestObserver (io.reactivex.observers.TestObserver)15 Schedulers (io.reactivex.schedulers.Schedulers)15 Nullable (android.support.annotation.Nullable)14 MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)14 ApiClient (io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient)14 AsyncResult (io.vertx.core.AsyncResult)14