use of feign.Response in project feign by OpenFeign.
the class GsonCodecTest method decodes.
@Test
public void decodes() throws Exception {
List<Zone> zones = new LinkedList<Zone>();
zones.add(new Zone("denominator.io."));
zones.add(new Zone("denominator.io.", "ABCD"));
Response response = Response.builder().status(200).reason("OK").headers(Collections.<String, Collection<String>>emptyMap()).body(zonesJson, UTF_8).build();
assertEquals(zones, new GsonDecoder().decode(response, new TypeToken<List<Zone>>() {
}.getType()));
}
use of feign.Response in project feign by OpenFeign.
the class JacksonCodecTest method decodes.
@Test
public void decodes() throws Exception {
List<Zone> zones = new LinkedList<Zone>();
zones.add(new Zone("denominator.io."));
zones.add(new Zone("denominator.io.", "ABCD"));
Response response = Response.builder().status(200).reason("OK").headers(Collections.<String, Collection<String>>emptyMap()).body(zonesJson, UTF_8).build();
assertEquals(zones, new JacksonDecoder().decode(response, new TypeReference<List<Zone>>() {
}.getType()));
}
use of feign.Response in project feign by OpenFeign.
the class DefaultDecoderTest method testDecodesToString.
@Test
public void testDecodesToString() throws Exception {
Response response = knownResponse();
Object decodedObject = decoder.decode(response, String.class);
assertEquals(String.class, decodedObject.getClass());
assertEquals("response body", decodedObject.toString());
}
use of feign.Response in project feign by OpenFeign.
the class DefaultErrorDecoderTest method throwsFeignException.
@Test
public void throwsFeignException() throws Throwable {
thrown.expect(FeignException.class);
thrown.expectMessage("status 500 reading Service#foo()");
Response response = Response.builder().status(500).reason("Internal server error").headers(headers).build();
throw errorDecoder.decode("Service#foo()", response);
}
use of feign.Response in project feign by OpenFeign.
the class DefaultErrorDecoderTest method testFeignExceptionIncludesStatus.
@Test
public void testFeignExceptionIncludesStatus() throws Throwable {
Response response = Response.builder().status(400).reason("Bad request").headers(headers).build();
Exception exception = errorDecoder.decode("Service#foo()", response);
assertThat(exception).isInstanceOf(FeignException.class);
assertThat(((FeignException) exception).status()).isEqualTo(400);
}
Aggregations