use of reactivefeign.testcase.domain.OrderGenerator in project feign-reactive by kptfh.
the class DefaultMethodTest method shouldWrapExceptionWithFlux.
@Test
public void shouldWrapExceptionWithFlux() throws JsonProcessingException {
IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
IcecreamServiceApi client = ReactiveFeign.<IcecreamServiceApi>builder().webClient(WebClient.create()).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
IceCreamOrder errorOrder = client.throwExceptionFlux().onErrorReturn(throwable -> throwable.equals(IcecreamServiceApi.RUNTIME_EXCEPTION), orderGenerated).blockFirst();
assertThat(errorOrder).isEqualToComparingFieldByField(orderGenerated);
}
use of reactivefeign.testcase.domain.OrderGenerator in project feign-reactive by kptfh.
the class DefaultMethodTest method shouldWrapExceptionWithMono.
@Test
public void shouldWrapExceptionWithMono() throws JsonProcessingException {
IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
IcecreamServiceApi client = ReactiveFeign.<IcecreamServiceApi>builder().webClient(WebClient.create()).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
IceCreamOrder errorOrder = client.throwExceptionMono().onErrorReturn(throwable -> throwable.equals(IcecreamServiceApi.RUNTIME_EXCEPTION), orderGenerated).block();
assertThat(errorOrder).isEqualToComparingFieldByField(orderGenerated);
}
use of reactivefeign.testcase.domain.OrderGenerator in project feign-reactive by kptfh.
the class ReactiveHttpClientTest method testPayBill_success.
@Test
public void testPayBill_success() {
Bill bill = Bill.makeBill(new OrderGenerator().generate(30));
client.payBill(bill).block();
}
use of reactivefeign.testcase.domain.OrderGenerator in project feign-reactive by kptfh.
the class DefaultMethodTest method shouldNotWrapException.
@Test(expected = RuntimeException.class)
public void shouldNotWrapException() {
IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
IcecreamServiceApi client = builder().target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
client.throwsException().onErrorReturn(throwable -> throwable.equals(IcecreamServiceApi.RUNTIME_EXCEPTION), orderGenerated).block();
}
use of reactivefeign.testcase.domain.OrderGenerator in project feign-reactive by kptfh.
the class RetryingTest method shouldSuccessOnRetriesMono.
@Test
public void shouldSuccessOnRetriesMono() throws JsonProcessingException {
IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
String orderStr = TestUtils.MAPPER.writeValueAsString(orderGenerated);
mockResponseAfterSeveralAttempts(wireMockRule, 2, "testRetrying_success", "/icecream/orders/1", aResponse().withStatus(503).withHeader(RETRY_AFTER, "1"), aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(orderStr));
IcecreamServiceApi client = builder().retryWhen(ReactiveRetryers.retryWithBackoff(3, 0)).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
StepVerifier.create(client.findOrder(1)).expectNextMatches(equalsComparingFieldByFieldRecursively(orderGenerated)).verifyComplete();
}
Aggregations