@Test
public void singleWithError() {

    // Create subscriber
    final AtomicReference<Throwable> error = new AtomicReference<>();
    final AtomicReference<Object> next = new AtomicReference<>();
    final Subscriber<Object> subscriber = SubscriberFactory.single(new SingleSubscriber<Object>() {
        @Override
        public void onError(@Nonnull final Throwable t) {
            error.set(t);
        }
        @Override
        public void onSuccess(@Nonnull final Object o) {
            next.set(o);
        }
    });
    // Test onSubscribe
    final Subscription subscription = Mockito.mock(Subscription.class);
    subscriber.onSubscribe(subscription);
    Mockito.verify(subscription, Mockito.times(1)).request(1);
    // Test onError
    final RuntimeException exception = new RuntimeException();
    subscriber.onError(exception);
    Assert.assertEquals(exception, error.get());
    Assert.assertNull(next.get());
}