use of reactivefeign.testcase.domain.OrderGenerator in project feign-reactive by kptfh.
the class RetryingTest method shouldSuccessOnRetriesWoRetryAfter.
@Test
public void shouldSuccessOnRetriesWoRetryAfter() throws JsonProcessingException {
IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
String orderStr = TestUtils.MAPPER.writeValueAsString(orderGenerated);
mockResponseAfterSeveralAttempts(wireMockRule, 2, "testRetrying_success", "/icecream/orders/1", aResponse().withStatus(SC_SERVICE_UNAVAILABLE), aResponse().withStatus(SC_OK).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();
}
use of reactivefeign.testcase.domain.OrderGenerator in project feign-reactive by kptfh.
the class CompressionTest method testCompression.
@Test
public void testCompression() throws JsonProcessingException {
IceCreamOrder order = new OrderGenerator().generate(20);
Bill billExpected = Bill.makeBill(order);
wireMockRule.stubFor(post(urlEqualTo("/icecream/orders")).withHeader("Accept-Encoding", containing("gzip")).withRequestBody(equalTo(TestUtils.MAPPER.writeValueAsString(order))).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withHeader("Content-Encoding", "gzip").withBody(Gzip.gzip(TestUtils.MAPPER.writeValueAsString(billExpected)))));
IcecreamServiceApi client = builder(new ReactiveOptions.Builder().setTryUseCompression(true).build()).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
Mono<Bill> bill = client.makeOrder(order);
StepVerifier.create(bill).expectNextMatches(equalsComparingFieldByFieldRecursively(billExpected)).verifyComplete();
}
Aggregations