use of io.servicetalk.concurrent.api.LegacyTestCompletable in project servicetalk by apple.
the class RetryWhenTest method setUp.
@SuppressWarnings("unchecked")
@BeforeEach
void setUp() {
source = new LegacyTestSingle<>(false, false);
shouldRetry = (BiIntFunction<Throwable, Completable>) mock(BiIntFunction.class);
retrySignal = new LegacyTestCompletable();
when(shouldRetry.apply(anyInt(), any())).thenAnswer(invocation -> {
retrySignal = new LegacyTestCompletable();
return retrySignal;
});
toSource(source.retryWhen(shouldRetry)).subscribe(subscriberRule);
}
use of io.servicetalk.concurrent.api.LegacyTestCompletable in project servicetalk by apple.
the class RetryWhenTest method setUp.
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
shouldRetry = (BiIntFunction<Throwable, Completable>) mock(BiIntFunction.class);
retrySignal = new LegacyTestCompletable();
when(shouldRetry.apply(anyInt(), any())).thenAnswer(invocation -> {
retrySignal = new LegacyTestCompletable();
return retrySignal;
});
toSource(source.retryWhen(shouldRetry)).subscribe(subscriber);
}
use of io.servicetalk.concurrent.api.LegacyTestCompletable in project servicetalk by apple.
the class AbstractWhenCancelTest method testCallbackThrowsError.
@Test
void testCallbackThrowsError() {
LegacyTestCompletable completable = new LegacyTestCompletable();
DeliberateException e = assertThrows(DeliberateException.class, () -> {
try {
toSource(doCancel(completable, () -> {
throw DELIBERATE_EXCEPTION;
})).subscribe(listener);
listener.awaitSubscription().cancel();
} finally {
completable.verifyCancelled();
}
});
assertThat(e, is(sameInstance(DELIBERATE_EXCEPTION)));
}
use of io.servicetalk.concurrent.api.LegacyTestCompletable in project servicetalk by apple.
the class AbstractWhenCancelTest method testCancelNoEmissions.
@Test
void testCancelNoEmissions() {
Runnable onCancel = Mockito.mock(Runnable.class);
LegacyTestCompletable completable = new LegacyTestCompletable();
toSource(doCancel(completable, onCancel)).subscribe(listener);
listener.awaitSubscription().cancel();
verify(onCancel).run();
completable.verifyCancelled();
}
use of io.servicetalk.concurrent.api.LegacyTestCompletable in project servicetalk by apple.
the class AbstractWhenFinallyTest method testCallbackThrowsErrorWhenCancel.
@Test
void testCallbackThrowsErrorWhenCancel() {
TerminalSignalConsumer mock = throwableMock(DELIBERATE_EXCEPTION);
LegacyTestCompletable completable = new LegacyTestCompletable();
try {
toSource(doFinally(completable, mock)).subscribe(listener);
Exception e = assertThrows(DeliberateException.class, () -> listener.awaitSubscription().cancel());
assertThat(e, is(sameInstance(DELIBERATE_EXCEPTION)));
} finally {
completable.verifyCancelled();
verify(mock).cancel();
verifyNoMoreInteractions(mock);
}
}
Aggregations