Search in sources :

Example 11 with OrderGenerator

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();
}
Also used : IcecreamServiceApi(reactivefeign.testcase.IcecreamServiceApi) IceCreamOrder(reactivefeign.testcase.domain.IceCreamOrder) OrderGenerator(reactivefeign.testcase.domain.OrderGenerator) Test(org.junit.Test)

Example 12 with OrderGenerator

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();
}
Also used : IcecreamServiceApi(reactivefeign.testcase.IcecreamServiceApi) Bill(reactivefeign.testcase.domain.Bill) IceCreamOrder(reactivefeign.testcase.domain.IceCreamOrder) OrderGenerator(reactivefeign.testcase.domain.OrderGenerator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 OrderGenerator (reactivefeign.testcase.domain.OrderGenerator)12 IceCreamOrder (reactivefeign.testcase.domain.IceCreamOrder)11 IcecreamServiceApi (reactivefeign.testcase.IcecreamServiceApi)10 Bill (reactivefeign.testcase.domain.Bill)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 WireMockConfiguration.wireMockConfig (com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig)3 WireMockClassRule (com.github.tomakehurst.wiremock.junit.WireMockClassRule)3 Before (org.junit.Before)3 ClassRule (org.junit.ClassRule)3 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)2 WireMock.equalTo (com.github.tomakehurst.wiremock.client.WireMock.equalTo)2 WireMock.get (com.github.tomakehurst.wiremock.client.WireMock.get)2 WireMock.urlEqualTo (com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo)2 Java6Assertions.assertThat (org.assertj.core.api.Java6Assertions.assertThat)2 Rule (org.junit.Rule)2 ExpectedException (org.junit.rules.ExpectedException)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 WebClient (org.springframework.web.reactive.function.client.WebClient)2 AllFeaturesApi (reactivefeign.allfeatures.AllFeaturesApi)2