Spring's @WebMvcTest doesn't work with Java 8 types

Viewed 686

In the spring boot app I have a rest controller which takes a payload containing a Java 8 type LocalDate. Also I have this library plugged in:

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

Controller works fine when called however a @WebMvcTest integration test fails on that field with 400 HTTP code and this exception:

Resolved Exception:
             Type = org.springframework.http.converter.HttpMessageNotReadableException 

Date in the production call and the test call is passed as:

"date":"2017-03-21"

if that matters.

Is there a way to make @WebMvcTest work with Java8 types?

3 Answers
Related