use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.
the class StatusHandlerTest method shouldThrowRetryException.
@Test
public void shouldThrowRetryException() {
wireMockRule.stubFor(get(urlEqualTo("/icecream/orders/1")).withHeader("Accept", equalTo("application/json")).willReturn(aResponse().withStatus(HttpStatus.SC_SERVICE_UNAVAILABLE)));
IcecreamServiceApi client = builder().statusHandler(throwOnStatus(status -> status == HttpStatus.SC_SERVICE_UNAVAILABLE, (methodTag, response) -> new RetryableException("Should retry on next node", null))).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
StepVerifier.create(client.findFirstOrder()).expectError(RetryableException.class);
}
use of reactivefeign.testcase.IcecreamServiceApi 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