Search in sources :

Example 1 with JSON

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()));
}
Also used : Response(feign.Response) JSON(com.fasterxml.jackson.jr.ob.JSON) Collections.singletonList(java.util.Collections.singletonList) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

JSON (com.fasterxml.jackson.jr.ob.JSON)1 Response (feign.Response)1 LocalDate (java.time.LocalDate)1 Collections.singletonList (java.util.Collections.singletonList)1 Test (org.junit.Test)1