I managed to get it working by adding:
@Before
public void before() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
JacksonJsonProvider provider = new JacksonJsonProvider();
provider.setMapper(objectMapper);
APP.client().register(provider);
}
Not sure if I should open an issue for this or not.
keskiviikko 27. syyskuuta 2017 19.57.00 UTC+3 Antti Pohjanpalo kirjoitti:
>
> Hi!
>
> I'm having problem with the following test class:
>
> public class NotesApplicationTest {
>
> @ClassRule
> public static final DropwizardAppRule<NotesConfiguration> APP = new
> DropwizardAppRule<>(
> NotesApplication.class,
> ResourceHelpers.resourceFilePath("test-config.yml")
> );
>
> private final String BASE_URI = String.format("http://localhost:%d",
> APP.getLocalPort());
>
> @Test
> public void shouldGetNotes() {
> Response response = APP.client()
> .target(BASE_URI + "/notes/1")
> .request(MediaType.APPLICATION_JSON_TYPE)
> .get();
>
> assertThat(response.getStatus()).isEqualTo(200);
> NoteResponse note = response.readEntity(NoteResponse.class); //
> this line throws error
> }
>
> }
>
> The error I get is this:
>
> Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not
> deserialize instance of java.time.LocalDate out of START_ARRAY token
> at [Source: org.glassfish.jersey.message.internal.
> ReaderInterceptorExecutor$UnCloseableInputStream@28b286c0; line: 1, column
> : 16] (through reference chain: anttipp.notes.rest.api.NoteResponse["date"
> ])
> at com.fasterxml.jackson.databind.JsonMappingException.from(
> JsonMappingException.java:270)
> at com.fasterxml.jackson.databind.DeserializationContext.
> reportMappingException(DeserializationContext.java:1234)
>
> The application itself works fine and testing with ResourceTestRule
> <http://dropwizard.readthedocs.io/en/latest/manual/testing.html#testing-resources>
> is
> also working fine. I'm using Dropwizard 1.1.4. How should I setup my test
> case to get it working? Could this be something similar than in
> https://github.com/dropwizard/dropwizard-java8/issues/8 ?
>
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.