use of com.fasterxml.jackson.jr.ob.JSON in project feign by OpenFeign.
the class JacksonCodecTest method customDecoderExpressedAsMapper.
@Test
public void customDecoderExpressedAsMapper() throws Exception {
JSON mapper = JSON.builder().register(new JavaLocalDateExtension()).build();
JacksonJrDecoder decoder = new JacksonJrDecoder(mapper);
List<LocalDate> dates = new LinkedList<>();
dates.add(LocalDate.of(2020, 1, 2));
dates.add(LocalDate.of(2021, 2, 3));
Response response = Response.builder().status(200).reason("OK").request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8)).headers(Collections.emptyMap()).body(DATES_JSON, UTF_8).build();
assertEquals(dates, decoder.decode(response, new TypeReference<List<LocalDate>>() {
}.getType()));
}
Aggregations