【发布时间】:2016-06-07 07:42:44
【问题描述】:
我对响应体的反序列化有疑问。我需要 sql.Date 但实际上我得到了 lang.String 请帮助我正确设置我的 RestAssure。
这是我的RestAssure.config 的样子:
RestAssured.config =
RestAssuredConfig.config().objectMapperConfig(objectMapperConfig()
.gsonObjectMapperFactory((aClass, s) ->
new GsonBuilder().setDateFormat("yyyy-MM-dd").create()));
这是我的测试:
given()
.contentType("application/json")
.when() .get("some url") .then()
.assertThat().body("birthday", response ->
equalTo(Date.valueOf("2016-06-07")))
我得到了这样的例外:
java.lang.AssertionError:
1 expectation failed.
JSON path birthday doesn't match.
Expected: <1994-12-30> Actual: 1994-12-30
【问题讨论】:
标签: java json rest rest-assured