@Override public Single<Integer> call() throws Exception { return Single.just(1); } }))
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(v); } })
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(v); } })
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(v); } })
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(v); } })
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(v); } }).subscribe(to);
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(v); } }, 32)
@Override public Single<Object> apply(Single<Object> s) throws Exception { return Single.just((Object)1).delaySubscription(s); } });
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(v).subscribeOn(Schedulers.computation()); } })
@Test public void dispose() { TestHelper.checkDisposed(Single.just(1).flattenAsObservable(new Function<Object, Iterable<Integer>>() { @Override public Iterable<Integer> apply(Object v) throws Exception { return Collections.singleton(1); } })); }
@Test public void manySources() { Single<?>[] sources = new Single[32]; Arrays.fill(sources, Single.never()); sources[31] = Single.just(31); Single.amb(Arrays.asList(sources)) .test() .assertResult(31); }
@Test public void hasNextCrash2() { Single.just(1).flattenAsFlowable(new Function<Integer, Iterable<Integer>>() { @Override public Iterable<Integer> apply(Integer v) throws Exception { return new CrashingIterable(100, 2, 100); } }) .test() .assertFailureAndMessage(TestException.class, "hasNext()", 0); }
@Test public void scalar() { Single.concat(Flowable.just(Single.just(1))) .test() .assertResult(1); }
@Test public void selectorCrash() { Single.just(Notification.createOnNext(1)) .dematerialize(new Function<Notification<Integer>, Notification<Integer>>() { @Override public Notification<Integer> apply(Notification<Integer> v) throws Exception { throw new TestException(); } }) .test() .assertFailure(TestException.class); }
@Test public void error() { Maybe.<Integer>error(new TestException()).switchIfEmpty(Single.just(2)) .test().assertFailure(TestException.class); }
@Test public void delaySubscriptionFlowable() throws Exception { Single.just(1).delaySubscription(Flowable.timer(100, TimeUnit.MILLISECONDS)) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(1); }
@Test public void withObservableError() { Single.just(1) .delaySubscription(Observable.error(new TestException())) .test() .assertFailure(TestException.class); }
@Test public void syncFusedSingle() { Observable.range(1, 5).hide() .switchMap(Functions.justFunction( Single.just(1).toObservable() )) .test() .assertResult(1, 1, 1, 1, 1); }
@Test public void delayedErrorOnSuccess() { final TestScheduler scheduler = new TestScheduler(); final TestObserver<Integer> observer = Single.just(1) .delay(5, TimeUnit.SECONDS, scheduler, true) .test(); scheduler.advanceTimeTo(2, TimeUnit.SECONDS); observer.assertNoValues(); scheduler.advanceTimeTo(5, TimeUnit.SECONDS); observer.assertValue(1); }