我有一个使用Spring REST文档的springBoot 2.1.9.RELEASE应用程序。
我的TestController中有此方法,该方法返回ResponseEntity<HttpStatus>
(HttpStatus.OK)
mockMvc.perform(post("/reservation-event")
.content(convertToString(reservation))
.contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("create-reservation-event",
但是当我运行测试时,出现此错误:
org.springframework.restdocs.snippet.ModelCreationException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.LinkedHashMap` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('OK')
at [Source: (byte[])""OK""; line: 1, column: 1]
我已更改为.andExpect(status().isCreated())
,返回类型为return ok().body(HttpStatus.CREATED);
,但随后出现此错误:
java.lang.AssertionError: Status
Expected :201
Actual :200