use of feign.RequestTemplate in project feign by OpenFeign.
the class JacksonJaxbCodecTest method encodeTest.
@Test
public void encodeTest() {
JacksonJaxbJsonEncoder encoder = new JacksonJaxbJsonEncoder();
RequestTemplate template = new RequestTemplate();
encoder.encode(new MockObject("Test"), MockObject.class, template);
assertThat(template).hasBody("{\"value\":\"Test\"}");
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class GsonCodecTest method customEncoder.
@Test
public void customEncoder() throws Exception {
GsonEncoder encoder = new GsonEncoder(Arrays.<TypeAdapter<?>>asList(upperZone));
List<Zone> zones = new LinkedList<Zone>();
zones.add(new Zone("denominator.io."));
zones.add(new Zone("denominator.io.", "abcd"));
RequestTemplate template = new RequestTemplate();
encoder.encode(zones, new TypeToken<List<Zone>>() {
}.getType(), template);
assertThat(template).hasBody(//
"" + //
"[\n" + //
" {\n" + //
" \"name\": \"DENOMINATOR.IO.\"\n" + //
" },\n" + //
" {\n" + //
" \"name\": \"DENOMINATOR.IO.\",\n" + //
" \"id\": \"ABCD\"\n" + //
" }\n" + "]");
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class GsonCodecTest method encodesMapObjectNumericalValuesAsInteger.
@Test
public void encodesMapObjectNumericalValuesAsInteger() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("foo", 1);
RequestTemplate template = new RequestTemplate();
new GsonEncoder().encode(map, map.getClass(), template);
assertThat(template).hasBody(//
"" + //
"{\n" + //
" \"foo\": 1\n" + "}");
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class GsonCodecTest method encodesFormParams.
@Test
public void encodesFormParams() throws Exception {
Map<String, Object> form = new LinkedHashMap<String, Object>();
form.put("foo", 1);
form.put("bar", Arrays.asList(2, 3));
RequestTemplate template = new RequestTemplate();
new GsonEncoder().encode(form, new TypeToken<Map<String, ?>>() {
}.getType(), template);
assertThat(template).hasBody(//
"" + //
"{\n" + //
" \"foo\": 1,\n" + //
" \"bar\": [\n" + //
" 2,\n" + //
" 3\n" + //
" ]\n" + "}");
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class DefaultEncoderTest method testRefusesToEncodeOtherTypes.
@Test
public void testRefusesToEncodeOtherTypes() throws Exception {
thrown.expect(EncodeException.class);
thrown.expectMessage("is not a type supported by this encoder.");
encoder.encode(new Date(), Date.class, new RequestTemplate());
}
Aggregations