use of io.github.resilience4j.feign.test.TestServiceFallbackWithException in project resilience4j by resilience4j.
the class Resilience4jFeignFallbackFactoryTest method should_go_to_fallback_and_consume_exception.
@Test
public void should_go_to_fallback_and_consume_exception() {
setupStub(400);
TestService testService = buildTestService(TestServiceFallbackWithException::new);
String result = testService.greeting();
assertThat(result).isEqualTo("Message from exception: status 400 reading TestService#greeting()");
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
use of io.github.resilience4j.feign.test.TestServiceFallbackWithException in project resilience4j by resilience4j.
the class Resilience4jFeignFallbackFactoryTest method should_go_to_fallback_and_consume_exception_with_predicate.
@Test
public void should_go_to_fallback_and_consume_exception_with_predicate() {
setupStub(400);
TestService uselessFallback = spy(TestService.class);
when(uselessFallback.greeting()).thenReturn("I should not be called");
FeignDecorators decorators = FeignDecorators.builder().withFallbackFactory(TestServiceFallbackWithException::new, FeignException.class::isInstance).withFallbackFactory(e -> uselessFallback).build();
TestService testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
String result = testService.greeting();
assertThat(result).isEqualTo("Message from exception: status 400 reading TestService#greeting()");
verify(uselessFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
use of io.github.resilience4j.feign.test.TestServiceFallbackWithException in project resilience4j by resilience4j.
the class Resilience4jFeignFallbackFactoryTest method should_go_to_fallback_and_consume_exception_with_exception_filter.
@Test
public void should_go_to_fallback_and_consume_exception_with_exception_filter() {
setupStub(400);
TestService uselessFallback = spy(TestService.class);
when(uselessFallback.greeting()).thenReturn("I should not be called");
FeignDecorators decorators = FeignDecorators.builder().withFallbackFactory(TestServiceFallbackWithException::new, FeignException.class).withFallbackFactory(e -> uselessFallback).build();
TestService testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
String result = testService.greeting();
assertThat(result).isEqualTo("Message from exception: status 400 reading TestService#greeting()");
verify(uselessFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
Aggregations