use of feign.Response in project feign by OpenFeign.
the class AbstractClientTest method postWithSpacesInPath.
@Test
public void postWithSpacesInPath() throws IOException, InterruptedException {
server.enqueue(new MockResponse().setBody("foo"));
TestInterface api = newBuilder().target(TestInterface.class, "http://localhost:" + server.getPort());
Response response = api.post("current documents", "foo");
MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("POST").hasPath("/path/current%20documents/resource").hasBody("foo");
}
use of feign.Response in project feign by OpenFeign.
the class JacksonCodecTest method nullBodyDecodesToNull.
@Test
public void nullBodyDecodesToNull() throws Exception {
Response response = Response.builder().status(204).reason("OK").headers(Collections.<String, Collection<String>>emptyMap()).build();
assertNull(new JacksonDecoder().decode(response, String.class));
}
use of feign.Response in project feign by OpenFeign.
the class JacksonCodecTest method emptyBodyDecodesToNull.
@Test
public void emptyBodyDecodesToNull() throws Exception {
Response response = Response.builder().status(204).reason("OK").headers(Collections.<String, Collection<String>>emptyMap()).body(new byte[0]).build();
assertNull(new JacksonDecoder().decode(response, String.class));
}
use of feign.Response in project feign by OpenFeign.
the class JacksonCodecTest method notFoundDecodesToEmpty.
/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmpty() throws Exception {
Response response = Response.builder().status(404).reason("NOT FOUND").headers(Collections.<String, Collection<String>>emptyMap()).build();
assertThat((byte[]) new JacksonDecoder().decode(response, byte[].class)).isEmpty();
}
use of feign.Response in project feign by OpenFeign.
the class JacksonCodecTest method customDecoder.
@Test
public void customDecoder() throws Exception {
JacksonDecoder decoder = new JacksonDecoder(Arrays.<Module>asList(new SimpleModule().addDeserializer(Zone.class, new ZoneDeserializer())));
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, decoder.decode(response, new TypeReference<List<Zone>>() {
}.getType()));
}
Aggregations