Search in sources :

Example 6 with IGNORE_CANCEL

use of io.servicetalk.concurrent.Cancellable.IGNORE_CANCEL in project servicetalk by apple.

the class SourceAdaptersTest method singleFromSourceError.

@Test
void singleFromSourceError() {
    SingleSource<Integer> src = s -> {
        s.onSubscribe(IGNORE_CANCEL);
        s.onError(DELIBERATE_EXCEPTION);
    };
    Future<Integer> future = fromSource(src).toFuture();
    Exception e = assertThrows(ExecutionException.class, () -> future.get());
    assertThat(e.getCause(), sameInstance(DELIBERATE_EXCEPTION));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) SingleSource(io.servicetalk.concurrent.SingleSource) Cancellable(io.servicetalk.concurrent.Cancellable) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) Future(java.util.concurrent.Future) ArgumentCaptor(org.mockito.ArgumentCaptor) EMPTY_SUBSCRIPTION(io.servicetalk.concurrent.internal.EmptySubscriptions.EMPTY_SUBSCRIPTION) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) Single.succeeded(io.servicetalk.concurrent.api.Single.succeeded) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) PublisherSource(io.servicetalk.concurrent.PublisherSource) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) SourceAdapters.toSource(io.servicetalk.concurrent.api.SourceAdapters.toSource) CompletableSource(io.servicetalk.concurrent.CompletableSource) ScalarValueSubscription(io.servicetalk.concurrent.internal.ScalarValueSubscription) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) ExecutionException(java.util.concurrent.ExecutionException) IGNORE_CANCEL(io.servicetalk.concurrent.Cancellable.IGNORE_CANCEL) ArgumentCaptor.forClass(org.mockito.ArgumentCaptor.forClass) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) Completable.completed(io.servicetalk.concurrent.api.Completable.completed) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test)

Aggregations

IGNORE_CANCEL (io.servicetalk.concurrent.Cancellable.IGNORE_CANCEL)6 Test (org.junit.jupiter.api.Test)6 CompletableSource (io.servicetalk.concurrent.CompletableSource)5 DELIBERATE_EXCEPTION (io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION)5 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 Matchers.is (org.hamcrest.Matchers.is)5 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)5 Mockito.mock (org.mockito.Mockito.mock)5 Cancellable (io.servicetalk.concurrent.Cancellable)4 PublisherSource (io.servicetalk.concurrent.PublisherSource)4 SingleSource (io.servicetalk.concurrent.SingleSource)4 Publisher.from (io.servicetalk.concurrent.api.Publisher.from)4 Single.succeeded (io.servicetalk.concurrent.api.Single.succeeded)4 SourceAdapters.fromSource (io.servicetalk.concurrent.api.SourceAdapters.fromSource)4 SourceAdapters.toSource (io.servicetalk.concurrent.api.SourceAdapters.toSource)4 EMPTY_SUBSCRIPTION (io.servicetalk.concurrent.internal.EmptySubscriptions.EMPTY_SUBSCRIPTION)4 ScalarValueSubscription (io.servicetalk.concurrent.internal.ScalarValueSubscription)4 ExecutionException (java.util.concurrent.ExecutionException)4 Future (java.util.concurrent.Future)4 Matchers.sameInstance (org.hamcrest.Matchers.sameInstance)4