У меня есть приложение springBoot 2.1.9.RELEASE, которое использует Spring REST Docs.
У меня есть этот метод в моем TestController
@Test
public void createOK() throws Exception {
String content = ResourceUtils.getResourceFileAsString ("/new_hostel.json");
mockMvc.perform(post("/hostel")
.content(content)
.contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("create-hostel",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
links(halLinks(),
linkWithRel("ld:GetHostel").
description("Get Hostel"),
linkWithRel("curies").
description("Documentation")),
requestFields(
fieldWithPath("description").description("The description"),
fieldWithPath("name").description("The name"),
fieldWithPath("id").description("The id")
)
));
}
но когда я запускаю его, у меня есть эта ошибка:
org.springframework.restdocs.snippet.ModelCreationException: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
at [Source: (byte[])""; line: 1, column: 0]
at org.springframework.restdocs.hypermedia.LinksSnippet.createModel(LinksSnippet.java:127)
at org.springframework.restdocs.snippet.TemplatedSnippet.document(TemplatedSnippet.java:81)
at org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:201)
at org.springframework.restdocs.mockmvc.RestDocumentationResultHandler.handle(RestDocumentationResultHandler.java:55)
at org.springframework.test.web.servlet.MockMvc$1.andDo(MockMvc.java:200)
at com.bendiciones.buenas.noches.HostelControllerIT.createOK(HostelControllerIT.java:88)