/** * Delay the emission of the signal of this Solo with the specified * time amount. * @param delay the delay time * @param unit the delay time unit * @return the new Solo instance */ public final Solo<T> delay(long delay, TimeUnit unit) { return delay(delay, unit, Schedulers.computation()); }
/** * Delay the emission of the signal of this Solo with the specified * time amount. * @param delay the delay time * @param unit the delay time unit * @return the new Solo instance */ public final Solo<T> delay(long delay, TimeUnit unit) { return delay(delay, unit, Schedulers.computation()); }
/** * 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)); }
/** * 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)); }
@Test public void delayError() { Solo.error(new IOException()).delay(100, TimeUnit.MILLISECONDS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertFailure(IOException.class); }
@Test public void delay() { Solo.just(1).delay(100, TimeUnit.MILLISECONDS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(1); }
@Test public void delayScheduler() { Solo.just(1).delay(100, TimeUnit.MILLISECONDS, Schedulers.single()) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(1); }
@Test public void delayPublisherError2() { PublishProcessor<Integer> pp = PublishProcessor.create(); TestSubscriber<Integer> ts = Solo.<Integer>error(new IOException()) .delay(pp).test(); ts.assertEmpty(); assertTrue(pp.hasSubscribers()); pp.onError(new IllegalArgumentException()); ts.assertFailure(CompositeException.class); assertFalse(pp.hasSubscribers()); }
@Test public void delayPublisherError() { PublishProcessor<Integer> pp = PublishProcessor.create(); TestSubscriber<Integer> ts = Solo.<Integer>error(new IOException()) .delay(pp).test(); ts.assertEmpty(); assertTrue(pp.hasSubscribers()); pp.onNext(2); ts.assertFailure(IOException.class); assertFalse(pp.hasSubscribers()); }
@Test public void delayPublisher() { PublishProcessor<Integer> pp = PublishProcessor.create(); TestSubscriber<Integer> ts = Solo.just(1).delay(pp).test(); ts.assertEmpty(); assertTrue(pp.hasSubscribers()); pp.onNext(2); ts.assertResult(1); assertFalse(pp.hasSubscribers()); }