use of feign.Response in project feign by OpenFeign.
the class JsonDecoderTest method decodesArray.
@Test
public void decodesArray() throws IOException {
String json = "[{\"a\":\"b\",\"c\":1},123]";
Response response = Response.builder().status(204).reason("OK").headers(Collections.emptyMap()).body(json, UTF_8).request(request).build();
assertTrue(jsonArray.similar(new JsonDecoder().decode(response, JSONArray.class)));
}
use of feign.Response in project feign by OpenFeign.
the class JsonDecoderTest method decodesObject.
@Test
public void decodesObject() throws IOException {
String json = "{\"a\":\"b\",\"c\":1}";
Response response = Response.builder().status(204).reason("OK").headers(Collections.emptyMap()).body(json, UTF_8).request(request).build();
assertTrue(jsonObject.similar(new JsonDecoder().decode(response, JSONObject.class)));
}
use of feign.Response in project feign by OpenFeign.
the class JsonDecoderTest method causedByIOException.
@Test
public void causedByIOException() throws IOException {
Response.Body body = mock(Response.Body.class);
when(body.asReader(any())).thenThrow(new JSONException("test exception", new IOException("test cause exception")));
Response response = Response.builder().status(204).reason("OK").headers(Collections.emptyMap()).body(body).request(request).build();
Exception exception = assertThrows(IOException.class, () -> new JsonDecoder().decode(response, JSONArray.class));
assertEquals("test cause exception", exception.getMessage());
}
use of feign.Response in project feign by OpenFeign.
the class JsonDecoderTest method decodeExtendedObject.
@Test
public void decodeExtendedObject() throws IOException {
String json = "{\"a\":\"b\",\"c\":1}";
Response response = Response.builder().status(204).reason("OK").headers(Collections.emptyMap()).body(json, UTF_8).request(request).build();
assertTrue(jsonObject.similar(new JsonDecoder().decode(response, ExtendedJSONObject.class)));
}
use of feign.Response in project feign by OpenFeign.
the class JsonDecoderTest method decodesExtendedArray.
@Test
public void decodesExtendedArray() throws IOException {
String json = "[{\"a\":\"b\",\"c\":1},123]";
Response response = Response.builder().status(204).reason("OK").headers(Collections.emptyMap()).body(json, UTF_8).request(request).build();
assertTrue(jsonArray.similar(new JsonDecoder().decode(response, ExtendedJSONArray.class)));
}
Aggregations