Async { public static Func0<Observable<Void>> toAsync(Action0 action) { return toAsync(action, Schedulers.computation()); } private  Async(); static Observable<T> start(Func0<T> func); static Observable<T> start(Func0<T> func, Scheduler scheduler); static Func0<Observable<Void>> toAsync(Action0 action); static Func0<Observable<R>> toAsync(Func0<? extends R> func); static Func1<T1, Observable<Void>> toAsync(Action1<? super T1> action); static Func1<T1, Observable<R>> toAsync(Func1<? super T1, ? extends R> func); static Func2<T1, T2, Observable<Void>> toAsync(Action2<? super T1, ? super T2> action); static Func2<T1, T2, Observable<R>> toAsync(Func2<? super T1, ? super T2, ? extends R> func); static Func3<T1, T2, T3, Observable<Void>> toAsync(Action3<? super T1, ? super T2, ? super T3> action); static Func3<T1, T2, T3, Observable<R>> toAsync(Func3<? super T1, ? super T2, ? super T3, ? extends R> func); static Func4<T1, T2, T3, T4, Observable<Void>> toAsync(Action4<? super T1, ? super T2, ? super T3, ? super T4> action); static Func4<T1, T2, T3, T4, Observable<R>> toAsync(Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> func); static Func5<T1, T2, T3, T4, T5, Observable<Void>> toAsync(Action5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5> action); static Func5<T1, T2, T3, T4, T5, Observable<R>> toAsync(Func5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> func); static Func6<T1, T2, T3, T4, T5, T6, Observable<Void>> toAsync(Action6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6> action); static Func6<T1, T2, T3, T4, T5, T6, Observable<R>> toAsync(Func6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> func); static Func7<T1, T2, T3, T4, T5, T6, T7, Observable<Void>> toAsync(Action7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7> action); static Func7<T1, T2, T3, T4, T5, T6, T7, Observable<R>> toAsync(Func7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> func); static Func8<T1, T2, T3, T4, T5, T6, T7, T8, Observable<Void>> toAsync(Action8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8> action); static Func8<T1, T2, T3, T4, T5, T6, T7, T8, Observable<R>> toAsync(Func8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> func); static Func9<T1, T2, T3, T4, T5, T6, T7, T8, T9, Observable<Void>> toAsync(Action9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9> action); static Func9<T1, T2, T3, T4, T5, T6, T7, T8, T9, Observable<R>> toAsync(Func9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R> func); static FuncN<Observable<Void>> toAsync(ActionN action); static FuncN<Observable<R>> toAsync(FuncN<? extends R> func); static Func0<Observable<Void>> toAsync(final Action0 action, final Scheduler scheduler); static Func0<Observable<R>> toAsync(final Func0<? extends R> func, final Scheduler scheduler); static Func1<T1, Observable<Void>> toAsync(final Action1<? super T1> action, final Scheduler scheduler); static Func1<T1, Observable<R>> toAsync(final Func1<? super T1, ? extends R> func, final Scheduler scheduler); static Func2<T1, T2, Observable<Void>> toAsync(final Action2<? super T1, ? super T2> action, final Scheduler scheduler); static Func2<T1, T2, Observable<R>> toAsync(final Func2<? super T1, ? super T2, ? extends R> func, final Scheduler scheduler); static Func3<T1, T2, T3, Observable<Void>> toAsync(final Action3<? super T1, ? super T2, ? super T3> action, final Scheduler scheduler); static Func3<T1, T2, T3, Observable<R>> toAsync(final Func3<? super T1, ? super T2, ? super T3, ? extends R> func, final Scheduler scheduler); static Func4<T1, T2, T3, T4, Observable<Void>> toAsync(final Action4<? super T1, ? super T2, ? super T3, ? super T4> action, final Scheduler scheduler); static Func4<T1, T2, T3, T4, Observable<R>> toAsync(final Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> func, final Scheduler scheduler); static Func5<T1, T2, T3, T4, T5, Observable<Void>> toAsync(final Action5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5> action, final Scheduler scheduler); static Func5<T1, T2, T3, T4, T5, Observable<R>> toAsync(final Func5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> func, final Scheduler scheduler); static Func6<T1, T2, T3, T4, T5, T6, Observable<Void>> toAsync(final Action6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6> action, final Scheduler scheduler); static Func6<T1, T2, T3, T4, T5, T6, Observable<R>> toAsync(final Func6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> func, final Scheduler scheduler); static Func7<T1, T2, T3, T4, T5, T6, T7, Observable<Void>> toAsync(final Action7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7> action, final Scheduler scheduler); static Func7<T1, T2, T3, T4, T5, T6, T7, Observable<R>> toAsync(final Func7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> func, final Scheduler scheduler); static Func8<T1, T2, T3, T4, T5, T6, T7, T8, Observable<Void>> toAsync(final Action8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8> action, final Scheduler scheduler); static Func8<T1, T2, T3, T4, T5, T6, T7, T8, Observable<R>> toAsync(final Func8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> func, final Scheduler scheduler); static Func9<T1, T2, T3, T4, T5, T6, T7, T8, T9, Observable<Void>> toAsync(final Action9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9> action, final Scheduler scheduler); static Func9<T1, T2, T3, T4, T5, T6, T7, T8, T9, Observable<R>> toAsync(final Func9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R> func, final Scheduler scheduler); static FuncN<Observable<Void>> toAsync(final ActionN action, final Scheduler scheduler); static FuncN<Observable<R>> toAsync(final FuncN<? extends R> func, final Scheduler scheduler); static FuncN<Observable<Void>> asyncAction(final ActionN action); static FuncN<Observable<Void>> asyncAction(final ActionN action, final Scheduler scheduler); static FuncN<Observable<R>> asyncFunc(final FuncN<? extends R> func); static FuncN<Observable<R>> asyncFunc(final FuncN<? extends R> func, final Scheduler scheduler); static Observable<T> startFuture(Func0<? extends Future<? extends T>> functionAsync); static Observable<T> startFuture(Func0<? extends Future<? extends T>> functionAsync,
        Scheduler scheduler); static Observable<T> deferFuture(Func0<? extends Future<? extends Observable<? extends T>>> observableFactoryAsync); static Observable<T> deferFuture(
        Func0<? extends Future<? extends Observable<? extends T>>> observableFactoryAsync,
        Scheduler scheduler); static FutureTask<Void> forEachFuture(
        Observable<? extends T> source,
        Action1<? super T> onNext); static FutureTask<Void> forEachFuture(
        Observable<? extends T> source,
        Action1<? super T> onNext,
        Action1<? super Throwable> onError); static FutureTask<Void> forEachFuture(
        Observable<? extends T> source,
        Action1<? super T> onNext,
        Action1<? super Throwable> onError,
        Action0 onCompleted); static FutureTask<Void> forEachFuture(
        Observable<? extends T> source,
        Action1<? super T> onNext,
        Scheduler scheduler); static FutureTask<Void> forEachFuture(
        Observable<? extends T> source,
        Action1<? super T> onNext,
        Action1<? super Throwable> onError,
        Scheduler scheduler); static FutureTask<Void> forEachFuture(
            Observable<? extends T> source,
            Action1<? super T> onNext,
            Action1<? super Throwable> onError,
            Action0 onCompleted,
            Scheduler scheduler); static Observable<R> fromAction(Action0 action, R result); static Observable<R> fromFunc0(Func0<? extends R> function); static Observable<R> fromCallable(Callable<? extends R> callable); static Observable<R> fromRunnable(final Runnable run, final R result); static Observable<R> fromAction(Action0 action, R result, Scheduler scheduler); static Observable<R> fromFunc0(Func0<? extends R> function, Scheduler scheduler); static Observable<R> fromCallable(Callable<? extends R> callable, Scheduler scheduler); static Observable<R> fromRunnable(final Runnable run, final R result, Scheduler scheduler); static StoppableObservable<T> runAsync(Scheduler scheduler, 
            final Action2<? super Observer<? super T>, ? super Subscription> action); static StoppableObservable<U> runAsync(Scheduler scheduler,
            final Subject<T, U> subject, 
            final Action2<? super Observer<? super T>, ? super Subscription> action);  }
@Test public void testAction0() { final AtomicInteger value = new AtomicInteger(); Action0 action = new Action0() { @Override public void call() { value.incrementAndGet(); } }; Async.toAsync(action, Schedulers.immediate()) .call() .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(1, value.get()); }
@Test public void testAction0Error() { Action0 action = new Action0() { @Override public void call() { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call() .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction1() { final AtomicInteger value = new AtomicInteger(); Action1<Integer> action = new Action1<Integer>() { @Override public void call(Integer t1) { value.set(t1); } }; Async.toAsync(action, Schedulers.immediate()) .call(1) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(1, value.get()); }
@Test public void testAction1Error() { Action1<Integer> action = new Action1<Integer>() { @Override public void call(Integer t1) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction2() { final AtomicInteger value = new AtomicInteger(); Action2<Integer, Integer> action = new Action2<Integer, Integer>() { @Override public void call(Integer t1, Integer t2) { value.set(t1 | t2); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(3, value.get()); }
@Test public void testAction2Error() { Action2<Integer, Integer> action = new Action2<Integer, Integer>() { @Override public void call(Integer t1, Integer t2) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction3() { final AtomicInteger value = new AtomicInteger(); Action3<Integer, Integer, Integer> action = new Action3<Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3) { value.set(t1 | t2 | t3); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(7, value.get()); }
@Test public void testAction3Error() { Action3<Integer, Integer, Integer> action = new Action3<Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction4() { final AtomicInteger value = new AtomicInteger(); Action4<Integer, Integer, Integer, Integer> action = new Action4<Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4) { value.set(t1 | t2 | t3 | t4); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(15, value.get()); }
@Test public void testAction4Error() { Action4<Integer, Integer, Integer, Integer> action = new Action4<Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction5() { final AtomicInteger value = new AtomicInteger(); Action5<Integer, Integer, Integer, Integer, Integer> action = new Action5<Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) { value.set(t1 | t2 | t3 | t4 | t5); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(31, value.get()); }
@Test public void testAction5Error() { Action5<Integer, Integer, Integer, Integer, Integer> action = new Action5<Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction6() { final AtomicInteger value = new AtomicInteger(); Action6<Integer, Integer, Integer, Integer, Integer, Integer> action = new Action6<Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6) { value.set(t1 | t2 | t3 | t4 | t5 | t6); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(63, value.get()); }
@Test public void testAction6Error() { Action6<Integer, Integer, Integer, Integer, Integer, Integer> action = new Action6<Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction7() { final AtomicInteger value = new AtomicInteger(); Action7<Integer, Integer, Integer, Integer, Integer, Integer, Integer> action = new Action7<Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7) { value.set(t1 | t2 | t3 | t4 | t5 | t6 | t7); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(127, value.get()); }
@Test public void testAction7Error() { Action7<Integer, Integer, Integer, Integer, Integer, Integer, Integer> action = new Action7<Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction8() { final AtomicInteger value = new AtomicInteger(); Action8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> action = new Action8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8) { value.set(t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(255, value.get()); }
@Test public void testAction8Error() { Action8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> action = new Action8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testAction9() { final AtomicInteger value = new AtomicInteger(); Action9<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> action = new Action9<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) { value.set(t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128, 256) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(511, value.get()); }
@Test public void testAction9Error() { Action9<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> action = new Action9<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128, 256) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testActionN() { final AtomicInteger value = new AtomicInteger(); ActionN action = new ActionN() { @Override public void call(Object... args) { int i = 0; for (Object o : args) { i = i | (Integer) o; } value.set(i); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128, 256, 512) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(null); verify(observer, times(1)).onCompleted(); Assert.assertEquals(1023, value.get()); }
@Test public void testActionNError() { ActionN action = new ActionN() { @Override public void call(Object... args) { throw new RuntimeException("Forced failure"); } }; Async.toAsync(action, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128, 256, 512) .subscribe(new TestObserver<Object>(observer)); verify(observer, times(1)).onError(any(Throwable.class)); verify(observer, never()).onNext(null); verify(observer, never()).onCompleted(); }
@Test public void testFunc0() { Func0<Integer> func = new Func0<Integer>() { @Override public Integer call() { return 0; } }; Async.toAsync(func, Schedulers.immediate()) .call() .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(0); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc1() { Func1<Integer, Integer> func = new Func1<Integer, Integer>() { @Override public Integer call(Integer t1) { return t1; } }; Async.toAsync(func, Schedulers.immediate()) .call(1) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(1); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc2() { Func2<Integer, Integer, Integer> func = new Func2<Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2) { return t1 | t2; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(3); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc3() { Func3<Integer, Integer, Integer, Integer> func = new Func3<Integer, Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2, Integer t3) { return t1 | t2 | t3; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(7); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc4() { Func4<Integer, Integer, Integer, Integer, Integer> func = new Func4<Integer, Integer, Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2, Integer t3, Integer t4) { return t1 | t2 | t3 | t4; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4, 8) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(15); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc5() { Func5<Integer, Integer, Integer, Integer, Integer, Integer> func = new Func5<Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) { return t1 | t2 | t3 | t4 | t5; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4, 8, 16) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(31); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc6() { Func6<Integer, Integer, Integer, Integer, Integer, Integer, Integer> func = new Func6<Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6) { return t1 | t2 | t3 | t4 | t5 | t6; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(63); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc7() { Func7<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> func = new Func7<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7) { return t1 | t2 | t3 | t4 | t5 | t6 | t7; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(127); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc8() { Func8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> func = new Func8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8) { return t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(255); verify(observer, times(1)).onCompleted(); }
@Test public void testFunc9() { Func9<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> func = new Func9<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>() { @Override public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) { return t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128, 256) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(511); verify(observer, times(1)).onCompleted(); }
@Test public void testFuncN() { FuncN<Integer> func = new FuncN<Integer>() { @Override public Integer call(Object... args) { int i = 0; for (Object o : args) { i = i | (Integer) o; } return i; } }; Async.toAsync(func, Schedulers.immediate()) .call(1, 2, 4, 8, 16, 32, 64, 128, 256, 512) .subscribe(new TestObserver<Object>(observer)); verify(observer, never()).onError(any(Throwable.class)); verify(observer, times(1)).onNext(1023); verify(observer, times(1)).onCompleted(); }