@Override public Solo<Integer> call() throws Exception { if (++counter[0] == 5) { return Solo.just(1); } return Solo.<Integer>error(new IOException()); } })
@Test public void subscribeTwoArgError() { Solo.error(new IOException()).subscribe(this, this); assertEquals(1, count); }
@Test public void onErrorResumeNextErrorThrows() { Solo.<Integer>error(new IOException()) .onErrorResumeNext(new Function<Throwable, Solo<Integer>>() { @Override public Solo<Integer> apply(Throwable e) throws Exception { throw new IOException(); } }) .test() .assertFailure(CompositeException.class); }
@SuppressWarnings("unchecked") @Test public void zipError1() { Solo.zip(Arrays.asList(Solo.error(new IOException()), Solo.just(2)), new Function<Object[], Object>() { @Override public Object apply(Object[] a) throws Exception { return "" + a[0] + a[1]; } }) .test() .assertFailure(IOException.class); }
@Test public void ignoreElementError() { Solo.error(new IOException()) .ignoreElement() .test() .assertFailure(IOException.class); }
@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 hideError() { Solo.error(new IOException()) .hide() .test() .assertFailure(IOException.class); }
@Test public void retryPredicateThrows() { Solo.error(new IOException()) .retry(new Predicate<Throwable>() { @Override public boolean test(Throwable e) throws Exception { throw new IllegalArgumentException(); } }) .test() .assertFailure(CompositeException.class); }
@SuppressWarnings("unchecked") @Test public void zipArrayError1() { Solo.zipArray(new Function<Object[], Object>() { @Override public Object apply(Object[] a) throws Exception { return "" + a[0] + a[1]; } }, Solo.error(new IOException()), Solo.just(2)) .test() .assertFailure(IOException.class); }
@SuppressWarnings("unchecked") @Test public void zipArrayError2() { Solo.zipArray(new Function<Object[], Object>() { @Override public Object apply(Object[] a) throws Exception { return "" + a[0] + a[1]; } }, Solo.just(1), Solo.error(new IOException())) .test() .assertFailure(IOException.class); }
@Test public void concatWithError() { Solo.just(1).concatWith(Solo.<Integer>error(new IOException())) .test() .assertFailure(IOException.class, 1); }
@Test public void mergeWithError() { Solo.just(1).mergeWith(Solo.<Integer>error(new IOException())) .test() .assertFailure(IOException.class, 1); }
@Test public void delayError() { Solo.error(new IOException()).delay(100, TimeUnit.MILLISECONDS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertFailure(IOException.class); }
@SuppressWarnings("unchecked") @Test public void concatArrayError() { Solo.concatArray(Solo.just(1), Solo.error(new IOException())) .test() .assertFailure(IOException.class, 1); }
@SuppressWarnings("unchecked") @Test public void mergeArrayError() { Solo.mergeArray(Solo.just(1), Solo.error(new IOException())) .test() .assertFailure(IOException.class, 1); }
@Test public void flatMapError() { Solo.just(1).flatMap(Functions.justFunction(Solo.error(new IOException()))) .test() .assertFailure(IOException.class); }
@Test public void flatMapPublisherError() { Solo.error(new IOException()).flatMapPublisher(Functions.justFunction(Flowable.range(1, 5))) .test() .assertFailure(IOException.class); }
@Test public void concatDelayErrorPublisherError() { Solo.concatDelayError(Flowable.just(Solo.just(1), Solo.error(new IOException()))) .test() .assertFailure(IOException.class, 1); }
@Test public void usingEagerError() { Solo.using(Functions.justCallable(1), Functions.justFunction(Solo.error(new IOException())), this) .test() .assertFailure(IOException.class); assertEquals(1, count); }
@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()); }