I changed the return type of my controller from list to page, now some of my tests fail.
Test:
@Test
public void shouldGetGlobalTopicsForUnloggedUser() throws Exception {
MvcResult mvcResult = mockMvc.perform(get("/topics/"))
.andExpect(status().isOk())
.andReturn();
List<TopicOutputDTO> topicDTOs = objectMapper.readValue(mvcResult.getResponse()
.getContentAsString(), new TypeReference<List<TopicOutputDTO>>() {
});
assertThat(topicDTOs.size()).isEqualTo(1);
}
Error that I get:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot
construct instance of `org.springframework.data.domain.Page` (no
Creators, like default construct, exist): abstract types either need to
be mapped to concrete types, have custom deserializer, or contain
additional type information
at [Source: (String)"{"content":[{"uuid":"da4c1ebc-eecf-428a-8791-
31a22bc07c2f","title":"Test global topic","type":"GLOBAL","createdBy":{"uuid":"2018047e-42c5-4587-8308-7227836b8f44","username":"admin","role":"SUPERADMIN"}}],"pageable":{"sort":{"sorted":false,"unsorted":true},"offset":0,"pageSize":15,"pageNumber":0,"paged":true,"unpaged":false},"totalElements":1,"totalPages":1,"last":true,"size":15,"number":0,"numberOfElements":1,"first":true,"sort":{"sorted":false,"unsorted":true}}"; line: 1, column: 1]
Aucun commentaire:
Enregistrer un commentaire