@Test public void testNonResubscribeableSingle() { TestSingle<String> source = new TestSingle.Builder<String>() .singleSubscriber() .build(); source.subscribe(subscriber1); assertTrue(subscriber1.cancellableReceived()); source.onSuccess("a"); assertThat(subscriber1.takeResult(), is("a")); source.subscribe(subscriber2); expected.expect(RuntimeException.class); expected.expectMessage("Unexpected exception(s) encountered"); expected.expectCause(allOf(instanceOf(IllegalStateException.class), hasProperty("message", startsWith("Duplicate subscriber")))); source.onSuccess("b"); }
public final Cancellable subscribe(Consumer<? super T> resultConsumer) { SimpleSingleSubscriber<T> subscriber = new SimpleSingleSubscriber<>(resultConsumer); subscribeInternal(subscriber); return subscriber; }
Single { public final Cancellable subscribe(Consumer<? super T> resultConsumer) { SimpleSingleSubscriber<T> subscriber = new SimpleSingleSubscriber<>(resultConsumer); subscribeInternal(subscriber); return subscriber; } }
Single { public final Cancellable subscribe(Consumer<? super T> resultConsumer) { SimpleSingleSubscriber<T> subscriber = new SimpleSingleSubscriber<>(resultConsumer); subscribeInternal(subscriber); return subscriber; } protected  Single();   Single(Executor executor);   Single(Executor executor, boolean shareContextOnSubscribe); }
Single { public final Cancellable subscribe(Consumer<? super T> resultConsumer) { SimpleSingleSubscriber<T> subscriber = new SimpleSingleSubscriber<>(resultConsumer); subscribeInternal(subscriber); return subscriber; } protected  Single();   Single(Executor executor);   Single(Executor executor, boolean shareContextOnSubscribe); final Single<R> map(Function<? super T, ? extends R> mapper); final Single<T> recoverWith(Function<Throwable, ? extends Single<? extends T>> nextFactory); final Single<R> flatMap(Function<? super T, ? extends Single<? extends R>> next); final Completable flatMapCompletable(Function<? super T, ? extends Completable> next); final Publisher<R> flatMapPublisher(Function<? super T, ? extends Publisher<? extends R>> next); final Single<T> whenOnSuccess(Consumer<? super T> onSuccess); final Single<T> whenOnError(Consumer<Throwable> onError); final Single<T> whenFinally(Runnable doFinally); final Single<T> whenFinally(TerminalSignalConsumer doFinally); final Single<T> whenFinally(SingleTerminalSignalConsumer<? super T> doFinally); final Single<T> whenCancel(Runnable onCancel); final Single<T> idleTimeout(long duration, TimeUnit unit); final Single<T> idleTimeout(long duration, TimeUnit unit, Executor timeoutExecutor); final Single<T> idleTimeout(Duration duration); final Single<T> idleTimeout(Duration duration, Executor timeoutExecutor); final Publisher<T> concat(Single<? extends T> next); final Single<T> concat(Completable next); final Publisher<T> concat(Publisher<? extends T> next); final Single<T> retry(BiIntPredicate<Throwable> shouldRetry); final Single<T> retryWhen(BiIntFunction<Throwable, ? extends Completable> retryWhen); final Publisher<T> repeat(IntPredicate shouldRepeat); final Publisher<T> repeatWhen(IntFunction<? extends Completable> repeatWhen); final Single<T> beforeOnSubscribe(Consumer<Cancellable> onSubscribe); final Single<T> beforeOnSuccess(Consumer<? super T> onSuccess); final Single<T> beforeOnError(Consumer<Throwable> onError); final Single<T> beforeCancel(Runnable onCancel); final Single<T> beforeFinally(Runnable doFinally); final Single<T> beforeFinally(TerminalSignalConsumer doFinally); final Single<T> beforeFinally(SingleTerminalSignalConsumer<? super T> doFinally); final Single<T> beforeSubscriber(Supplier<? extends Subscriber<? super T>> subscriberSupplier); final Single<T> afterOnSubscribe(Consumer<Cancellable> onSubscribe); final Single<T> whenOnSubscribe(Consumer<Cancellable> onSubscribe); final Single<T> afterOnSuccess(Consumer<? super T> onSuccess); final Single<T> afterOnError(Consumer<Throwable> onError); final Single<T> afterCancel(Runnable onCancel); final Single<T> afterFinally(Runnable doFinally); final Single<T> afterFinally(TerminalSignalConsumer doFinally); final Single<T> afterFinally(SingleTerminalSignalConsumer<? super T> doFinally); final Single<T> afterSubscriber(Supplier<? extends Subscriber<? super T>> subscriberSupplier); final Single<T> whenSubscriber(Supplier<? extends Subscriber<? super T>> subscriberSupplier); final Single<T> publishOn(Executor executor); final Single<T> publishOnOverride(Executor executor); final Single<T> subscribeOn(Executor executor); final Single<T> subscribeOnOverride(Executor executor); final Single<T> publishAndSubscribeOn(Executor executor); final Single<T> publishAndSubscribeOnOverride(Executor executor); final Single<T> subscribeShareContext(); final Single<R> liftSync(SingleOperator<? super T, ? extends R> operator); final Single<R> liftAsync(SingleOperator<? super T, ? extends R> operator); final Single<T> ambWith(final Single<T> other); final Publisher<T> toPublisher(); final Completable toCompletable(); final Completable ignoreElement(); final CompletionStage<T> toCompletionStage(); final Future<T> toFuture(); final Cancellable subscribe(Consumer<? super T> resultConsumer); static Single<T> succeeded(@Nullable T value); static Single<T> fromCallable(final Callable<T> callable); static Single<T> fromSupplier(final Supplier<T> supplier); static Single<T> failed(Throwable cause); static Single<T> never(); static Single<T> defer(Supplier<? extends Single<? extends T>> singleSupplier); static Single<T> fromFuture(Future<? extends T> future); static Single<Collection<T>> collectUnordered(Iterable<? extends Single<? extends T>> singles); @SafeVarargs static Single<Collection<T>> collectUnordered(Single<? extends T>... singles); static Single<Collection<T>> collectUnordered(Iterable<? extends Single<? extends T>> singles,
                                                             int maxConcurrency); @SafeVarargs static Single<Collection<T>> collectUnordered(int maxConcurrency, Single<? extends T>... singles); static Single<Collection<T>> collectUnorderedDelayError(
            Iterable<? extends Single<? extends T>> singles); @SafeVarargs static Single<Collection<T>> collectUnorderedDelayError(Single<? extends T>... singles); static Single<Collection<T>> collectUnorderedDelayError(Iterable<? extends Single<? extends T>> singles,
                                                                       int maxConcurrency); @SafeVarargs static Single<Collection<T>> collectUnorderedDelayError(int maxConcurrency,
                                                                       Single<? extends T>... singles); static Single<T> fromStage(CompletionStage<? extends T> stage); @SafeVarargs static Single<T> amb(final Single<? extends T>... singles); static Single<T> amb(final Iterable<Single<? extends T>> singles); @SafeVarargs static Single<T> anyOf(final Single<? extends T>... singles); static Single<T> anyOf(final Iterable<Single<? extends T>> singles); }
Single { public final Cancellable subscribe(Consumer<? super T> resultConsumer) { SimpleSingleSubscriber<T> subscriber = new SimpleSingleSubscriber<>(resultConsumer); subscribeInternal(subscriber); return subscriber; } protected  Single();   Single(Executor executor);   Single(Executor executor, boolean shareContextOnSubscribe); final Single<R> map(Function<? super T, ? extends R> mapper); final Single<T> recoverWith(Function<Throwable, ? extends Single<? extends T>> nextFactory); final Single<R> flatMap(Function<? super T, ? extends Single<? extends R>> next); final Completable flatMapCompletable(Function<? super T, ? extends Completable> next); final Publisher<R> flatMapPublisher(Function<? super T, ? extends Publisher<? extends R>> next); final Single<T> whenOnSuccess(Consumer<? super T> onSuccess); final Single<T> whenOnError(Consumer<Throwable> onError); final Single<T> whenFinally(Runnable doFinally); final Single<T> whenFinally(TerminalSignalConsumer doFinally); final Single<T> whenFinally(SingleTerminalSignalConsumer<? super T> doFinally); final Single<T> whenCancel(Runnable onCancel); final Single<T> idleTimeout(long duration, TimeUnit unit); final Single<T> idleTimeout(long duration, TimeUnit unit, Executor timeoutExecutor); final Single<T> idleTimeout(Duration duration); final Single<T> idleTimeout(Duration duration, Executor timeoutExecutor); final Publisher<T> concat(Single<? extends T> next); final Single<T> concat(Completable next); final Publisher<T> concat(Publisher<? extends T> next); final Single<T> retry(BiIntPredicate<Throwable> shouldRetry); final Single<T> retryWhen(BiIntFunction<Throwable, ? extends Completable> retryWhen); final Publisher<T> repeat(IntPredicate shouldRepeat); final Publisher<T> repeatWhen(IntFunction<? extends Completable> repeatWhen); final Single<T> beforeOnSubscribe(Consumer<Cancellable> onSubscribe); final Single<T> beforeOnSuccess(Consumer<? super T> onSuccess); final Single<T> beforeOnError(Consumer<Throwable> onError); final Single<T> beforeCancel(Runnable onCancel); final Single<T> beforeFinally(Runnable doFinally); final Single<T> beforeFinally(TerminalSignalConsumer doFinally); final Single<T> beforeFinally(SingleTerminalSignalConsumer<? super T> doFinally); final Single<T> beforeSubscriber(Supplier<? extends Subscriber<? super T>> subscriberSupplier); final Single<T> afterOnSubscribe(Consumer<Cancellable> onSubscribe); final Single<T> whenOnSubscribe(Consumer<Cancellable> onSubscribe); final Single<T> afterOnSuccess(Consumer<? super T> onSuccess); final Single<T> afterOnError(Consumer<Throwable> onError); final Single<T> afterCancel(Runnable onCancel); final Single<T> afterFinally(Runnable doFinally); final Single<T> afterFinally(TerminalSignalConsumer doFinally); final Single<T> afterFinally(SingleTerminalSignalConsumer<? super T> doFinally); final Single<T> afterSubscriber(Supplier<? extends Subscriber<? super T>> subscriberSupplier); final Single<T> whenSubscriber(Supplier<? extends Subscriber<? super T>> subscriberSupplier); final Single<T> publishOn(Executor executor); final Single<T> publishOnOverride(Executor executor); final Single<T> subscribeOn(Executor executor); final Single<T> subscribeOnOverride(Executor executor); final Single<T> publishAndSubscribeOn(Executor executor); final Single<T> publishAndSubscribeOnOverride(Executor executor); final Single<T> subscribeShareContext(); final Single<R> liftSync(SingleOperator<? super T, ? extends R> operator); final Single<R> liftAsync(SingleOperator<? super T, ? extends R> operator); final Single<T> ambWith(final Single<T> other); final Publisher<T> toPublisher(); final Completable toCompletable(); final Completable ignoreElement(); final CompletionStage<T> toCompletionStage(); final Future<T> toFuture(); final Cancellable subscribe(Consumer<? super T> resultConsumer); static Single<T> succeeded(@Nullable T value); static Single<T> fromCallable(final Callable<T> callable); static Single<T> fromSupplier(final Supplier<T> supplier); static Single<T> failed(Throwable cause); static Single<T> never(); static Single<T> defer(Supplier<? extends Single<? extends T>> singleSupplier); static Single<T> fromFuture(Future<? extends T> future); static Single<Collection<T>> collectUnordered(Iterable<? extends Single<? extends T>> singles); @SafeVarargs static Single<Collection<T>> collectUnordered(Single<? extends T>... singles); static Single<Collection<T>> collectUnordered(Iterable<? extends Single<? extends T>> singles,
                                                             int maxConcurrency); @SafeVarargs static Single<Collection<T>> collectUnordered(int maxConcurrency, Single<? extends T>... singles); static Single<Collection<T>> collectUnorderedDelayError(
            Iterable<? extends Single<? extends T>> singles); @SafeVarargs static Single<Collection<T>> collectUnorderedDelayError(Single<? extends T>... singles); static Single<Collection<T>> collectUnorderedDelayError(Iterable<? extends Single<? extends T>> singles,
                                                                       int maxConcurrency); @SafeVarargs static Single<Collection<T>> collectUnorderedDelayError(int maxConcurrency,
                                                                       Single<? extends T>... singles); static Single<T> fromStage(CompletionStage<? extends T> stage); @SafeVarargs static Single<T> amb(final Single<? extends T>... singles); static Single<T> amb(final Iterable<Single<? extends T>> singles); @SafeVarargs static Single<T> anyOf(final Single<? extends T>... singles); static Single<T> anyOf(final Iterable<Single<? extends T>> singles);  }