MethodArgumentTypeMismatchException при работе с OffsetDateTime
Тестирую такой контроллер
@Override
@PostMapping(value = "/postTest")
public Long postTest(
@RequestBody @Valid SomeObject so,
@RequestParam(value = "period", required = true) @NotNull OffsetDateTime period)
throws ApiFault {
return service.post(so, convertToDate(period));
}
тест
@Test
public void createRegistryHeader() throws Exception {
ZoneId cet = ZoneId.of("CET");
OffsetDateTime now = OffsetDateTime.now(cet).truncatedTo(ChronoUnit.MILLIS);
String s = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(period);
SomeObject so = // создание и наполнение объекта
MvcResult result = this.mockMvc.perform(post("/rs/postTest")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(asJsonString(so))
.param("period", s)).andDo(print())
.andExpect(status().isOk())
.andReturn();
// прочая логика
}
падает с
Async:
Async started = false
Async result = null
Resolved Exception:
Type = org.springframework.web.method.annotation.MethodArgumentTypeMismatchException
ModelAndView:
View name = null
View = null
Model = null
FlashMap:
Attributes = null
MockHttpServletResponse:
Status = 400
Error message = null
Headers = {}
Content type = null
Body =
Forwarded URL = null
Redirected URL = null
Cookies = []
Status expected:<200> but was:<400>
Expected :200
Actual :400