Search in sources :

Example 1 with ResponseMapper

use of feign.ResponseMapper in project feign by OpenFeign.

the class ReactiveFeignIntegrationTest method testResponseMappers.

@Test
public void testResponseMappers() throws Exception {
    this.webServer.enqueue(new MockResponse().setBody("1.0"));
    ResponseMapper responseMapper = mock(ResponseMapper.class);
    Decoder decoder = mock(Decoder.class);
    given(responseMapper.map(any(Response.class), any(Type.class))).willAnswer(AdditionalAnswers.returnsFirstArg());
    given(decoder.decode(any(Response.class), any(Type.class))).willReturn("1.0");
    TestReactorService service = ReactorFeign.builder().mapAndDecode(responseMapper, decoder).target(TestReactorService.class, this.getServerUrl());
    StepVerifier.create(service.version()).expectNext("1.0").expectComplete().verify();
    verify(responseMapper, times(1)).map(any(Response.class), any(Type.class));
    verify(decoder, times(1)).decode(any(Response.class), any(Type.class));
}
Also used : Response(feign.Response) MockResponse(okhttp3.mockwebserver.MockResponse) MockResponse(okhttp3.mockwebserver.MockResponse) Type(java.lang.reflect.Type) ResponseMapper(feign.ResponseMapper) ErrorDecoder(feign.codec.ErrorDecoder) Decoder(feign.codec.Decoder) JacksonDecoder(feign.jackson.JacksonDecoder) Test(org.junit.Test)

Aggregations

Response (feign.Response)1 ResponseMapper (feign.ResponseMapper)1 Decoder (feign.codec.Decoder)1 ErrorDecoder (feign.codec.ErrorDecoder)1 JacksonDecoder (feign.jackson.JacksonDecoder)1 Type (java.lang.reflect.Type)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 Test (org.junit.Test)1