@Override public Integer apply(Integer a, Long b) throws Exception { return a + b.intValue(); } })
@Test public void testSynchronousNext() { assertEquals(1, BehaviorProcessor.createDefault(1).take(1).blockingSingle().intValue()); assertEquals(2, BehaviorProcessor.createDefault(2).blockingIterable().iterator().next().intValue()); assertEquals(3, BehaviorProcessor.createDefault(3).blockingNext().iterator().next().intValue()); }
@SuppressWarnings("unchecked") @Test public void scalarCallable() { Maybe<Integer> m = Maybe.just(1); assertTrue(m.getClass().toString(), m instanceof ScalarCallable); assertEquals(1, ((ScalarCallable<Integer>)m).call().intValue()); } }
@Test public void testBackpressureWithInitialValue() throws InterruptedException { Observable<Integer> source = Observable.just(1, 2, 3, 4, 5, 6); Single<Integer> reduced = source.reduce(0, sum); Integer r = reduced.blockingGet(); assertEquals(21, r.intValue()); }
@Test public void testBackpressureWithNoInitialValue() throws InterruptedException { Observable<Integer> source = Observable.just(1, 2, 3, 4, 5, 6); Maybe<Integer> reduced = source.reduce(sum); Integer r = reduced.blockingGet(); assertEquals(21, r.intValue()); }
@Test public void testBackpressureWithInitialValueObservable() throws InterruptedException { Observable<Integer> source = Observable.just(1, 2, 3, 4, 5, 6); Observable<Integer> reduced = source.reduce(0, sum).toObservable(); Integer r = reduced.blockingFirst(); assertEquals(21, r.intValue()); }
@Test public void blockingFirst() { assertEquals(1, Observable.range(1, 10) .subscribeOn(Schedulers.computation()).blockingFirst().intValue()); }
@Test public void firstFgnoredCancelAndOnNext() { Flowable<Integer> source = Flowable.fromPublisher(new Publisher<Integer>() { @Override public void subscribe(Subscriber<? super Integer> s) { s.onSubscribe(new BooleanSubscription()); s.onNext(1); s.onNext(2); } }); assertEquals(1, source.blockingFirst().intValue()); }
@Test public void testElementAt() { assertEquals(2, Observable.fromArray(1, 2).elementAt(1).blockingGet() .intValue()); }
@Test public void onNext() throws Exception { fo.onNext(1); fo.onComplete(); assertEquals(1, fo.get(5, TimeUnit.MILLISECONDS).intValue()); }
@Test public void completeAsync() throws Exception { Schedulers.single().scheduleDirect(new Runnable() { @Override public void run() { fs.onNext(1); fs.onComplete(); } }, 500, TimeUnit.MILLISECONDS); assertEquals(1, fs.get().intValue()); }
@Test public void testElementAt() { assertEquals(2, Flowable.fromArray(1, 2).elementAt(1).blockingGet() .intValue()); }
@Test public void await() throws Exception { Schedulers.single().scheduleDirect(new Runnable() { @Override public void run() { fo.onNext(1); fo.onComplete(); } }, 100, TimeUnit.MILLISECONDS); assertEquals(1, fo.get(5, TimeUnit.SECONDS).intValue()); }
@Test public void testBackpressureWithInitialValue() throws InterruptedException { Flowable<Integer> source = Flowable.just(1, 2, 3, 4, 5, 6); Single<Integer> reduced = source.reduce(0, sum); Integer r = reduced.blockingGet(); assertEquals(21, r.intValue()); }
@Test public void completeAsync() throws Exception { Schedulers.single().scheduleDirect(new Runnable() { @Override public void run() { fo.onNext(1); fo.onComplete(); } }, 500, TimeUnit.MILLISECONDS); assertEquals(1, fo.get().intValue()); }
@Test public void onNextThenOnCompleteTwice() throws Exception { fo.onNext(1); fo.onComplete(); fo.onComplete(); assertEquals(1, fo.get(5, TimeUnit.MILLISECONDS).intValue()); }
@Test public void testBackpressureWithInitialValueFlowable() throws InterruptedException { Flowable<Integer> source = Flowable.just(1, 2, 3, 4, 5, 6); Flowable<Integer> reduced = source.reduce(0, sum).toFlowable(); Integer r = reduced.blockingFirst(); assertEquals(21, r.intValue()); }
@Test public void blockingFirst() { assertEquals(1, Flowable.range(1, 10) .subscribeOn(Schedulers.computation()).blockingFirst().intValue()); }
@Test public void nextObserverOnNext() throws Exception { NextSubscriber<Integer> no = new NextSubscriber<Integer>(); no.setWaiting(); no.onNext(Notification.createOnNext(1)); no.setWaiting(); no.onNext(Notification.createOnNext(1)); assertEquals(1, no.takeNext().getValue().intValue()); }