/** * Signal the events of this or the other Solo whichever * signals first. * @param other the other Solo * @return the new Solo instance */ @SuppressWarnings("unchecked") public final Solo<T> ambWith(Solo<? extends T> other) { return ambArray(this, other); }
/** * Blocks until this Solo terminates and calls the onNext with the success value. * @param onNext the callback to call when this Solo completes with a success value */ public final void blockingSubscribe(Consumer<? super T> onNext) { blockingSubscribe(onNext, Functions.ERROR_CONSUMER, Functions.EMPTY_ACTION); }
/** * Concatenate the values in order from a sequence of Solo sources. * @param <T> the common base value type * @param sources the sequence of sources * @return the new Flowable instance */ public static <T> Flowable<T> concat(Publisher<? extends Solo<? extends T>> sources) { return concat(sources, 2); }
/** * Delay the subscription to this Solo until the specified delay elapses. * @param delay the delay time * @param unit the delay unit * @param scheduler the scheduler to wait on * @return the new Solo type */ public final Solo<T> delaySubscription(long delay, TimeUnit unit, Scheduler scheduler) { return delaySubscription(timer(delay, unit, scheduler)); }
/** * Delay the emission of the signal of this Solo with the specified * time amount on the specified scheduler. * @param delay the delay time * @param unit the delay time unit * @param scheduler the scheduler to wait on * @return the new Solo instance */ public final Solo<T> delay(long delay, TimeUnit unit, Scheduler scheduler) { ObjectHelper.requireNonNull(unit, "unit is null"); ObjectHelper.requireNonNull(scheduler, "scheduler is null"); return delay(timer(delay, unit, scheduler)); }
@SuppressWarnings("unchecked") @Test public void ambArray1Error() { SoloProcessor<Integer> sp1 = SoloProcessor.create(); SoloProcessor<Integer> sp2 = SoloProcessor.create(); TestSubscriber<Integer> ts = Solo.ambArray(sp1, sp2) .test(); assertTrue(sp1.hasSubscribers()); assertTrue(sp2.hasSubscribers()); ts.assertEmpty(); sp1.onError(new IOException()); ts.assertFailure(IOException.class); assertFalse(sp1.hasSubscribers()); assertFalse(sp2.hasSubscribers()); }
@SuppressWarnings("unchecked") @Test public void concatIterableDelayErrorError() { Solo.concatDelayError(Arrays.asList(Solo.just(1), Solo.error(new IOException()))) .test() .assertFailure(IOException.class, 1); }
@SuppressWarnings("unchecked") @Test public void mergeIterableDelayErrorError() { Solo.mergeDelayError(Arrays.asList(Solo.just(1), Solo.error(new IOException()))) .test() .assertFailure(IOException.class, 1); }
@Test public void delaySubscription() { Solo.just(1) .delaySubscription(100, TimeUnit.MILLISECONDS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(1); }
@SuppressWarnings("unchecked") @Test public void concatIterableDelayError() { Solo.concatDelayError(Arrays.asList(Solo.just(1), Solo.just(2))) .test() .assertResult(1, 2); }
@SuppressWarnings("unchecked") @Test public void mergeIterableDelayError() { Solo.mergeDelayError(Arrays.asList(Solo.just(1), Solo.just(2))) .test() .assertResult(1, 2); }
@SuppressWarnings("unchecked") @Test public void mergeArrayError() { Solo.mergeArray(Solo.just(1), Solo.error(new IOException())) .test() .assertFailure(IOException.class, 1); }
@SuppressWarnings("unchecked") @Test public void mergeArrayDelayErrorError() { Solo.mergeArrayDelayError(Solo.just(1), Solo.error(new IOException())) .test() .assertFailure(IOException.class, 1); }
@Test public void blockingSubscribeZeroArg() { Solo.just(1) .doOnNext(this) .blockingSubscribe(); assertEquals(1, count); }