@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); } }, true, Integer.MAX_VALUE)
@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); } }, true)
@Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(1).subscribeOn(Schedulers.computation()); } })
@Test public void dispose() { TestHelper.checkDisposed(Single.just(1).flatMap(new Function<Integer, SingleSource<Integer>>() { @Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.just(2); } })); }
@Test public void hasNextThrowsUnbounded() { flattenAsFlowable(Single.just(1) , new Function<Object, Iterable<Integer>>() { @Override public Iterable<Integer> apply(Object v) throws Exception { return new CrashingIterable(100, 2, 100); } }) .test() .assertFailureAndMessage(TestException.class, "hasNext()", 0); }
@Test public void singleToMaybe() { Single.just(1) .toMaybe() .test() .assertResult(1); }
@Test public void hasNextCrash() { Single.just(1).flattenAsObservable(new Function<Integer, Iterable<Integer>>() { @Override public Iterable<Integer> apply(Integer v) throws Exception { return new CrashingIterable(100, 1, 100); } }) .test() .assertFailureAndMessage(TestException.class, "hasNext()"); }
@SuppressWarnings("unchecked") @Test public void secondError() { Single.zip(Arrays.asList(Single.just(1), Single.<Integer>error(new TestException())), addString) .test() .assertFailure(TestException.class); }
@Test public void mainSuccess() { Single.just(1) .timeout(1, TimeUnit.DAYS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(1); }
@Test public void mappedSingleOnError() { Single.just(1).flatMap(new Function<Integer, SingleSource<Integer>>() { @Override public SingleSource<Integer> apply(Integer v) throws Exception { return Single.error(new TestException()); } }) .test() .assertFailure(TestException.class); } }
@Test public void comparerThrows() { Single.just(1) .contains(2, new BiPredicate<Object, Object>() { @Override public boolean test(Object a, Object b) throws Exception { throw new TestException(); } }) .test() .assertFailure(TestException.class); }
@Test public void delaySubscriptionObservable() throws Exception { Single.just(1).delaySubscription(Observable.timer(100, TimeUnit.MILLISECONDS)) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(1); }
@Test public void withPublisherError() { Single.just(1) .delaySubscription(Observable.error(new TestException())) .test() .assertFailure(TestException.class); }
@Test public void withObservableError() { Single.just(1) .delaySubscription(Observable.error(new TestException())) .test() .assertFailure(TestException.class); }
@Test public void withSingleErrors() { Single.just(1) .delaySubscription(Single.error(new TestException())) .test() .assertFailure(TestException.class); }