use of io.github.resilience4j.retry.RetryConfig in project resilience4j by resilience4j.
the class RetryTransformerTest method shouldNotRetryFromPredicateUsingSingle.
@Test
public void shouldNotRetryFromPredicateUsingSingle() {
// Given
RetryConfig config = RetryConfig.custom().retryOnException(t -> t instanceof IOException).maxAttempts(3).build();
Retry retry = Retry.of("testName", config);
given(helloWorldService.returnHelloWorld()).willThrow(new WebServiceException("BAM!"));
// When
Single.fromCallable(helloWorldService::returnHelloWorld).compose(RetryTransformer.of(retry)).test().assertError(WebServiceException.class).assertNotComplete().assertSubscribed();
// Then
BDDMockito.then(helloWorldService).should(Mockito.times(1)).returnHelloWorld();
Retry.Metrics metrics = retry.getMetrics();
assertThat(metrics.getNumberOfFailedCallsWithoutRetryAttempt()).isEqualTo(1);
assertThat(metrics.getNumberOfFailedCallsWithRetryAttempt()).isEqualTo(0);
}
Aggregations