我在一个测试失败的集成类中工作。该类在下面提供,public class EllaServiceIntegrationTest { private static final String ELLA_JSON_RESPONSE_FRAUD = "{\n" + " \"score\": 707,\n" + " \"reason\": \"DOMAIN_DOES_NOT_EXIST\",\n" + " \"riskBand\": 4,\n" + " \"email\": {\n" + " \"emailAddress\": \"fraudster@fraud.com\",\n" + " \"exists\": 4,\n" + " \"firstVerificationDate\": \"2019-05-31T19:08:20.7713155Z\",\n" + " \"firstVerificationDays\": 0,\n" + " \"totalHits\": 31,\n" + " \"uniqueHits\": 1,\n" + " \"score\": {\n" + " \"reason\": \"DOMAIN_DOES_NOT_EXIST\",\n" + " \"riskLevel\": 6,\n" + " \"relevantInfoId\": 10900\n" + " }\n" + " },\n" + " \"domain\": {},\n" + " \"phone\": {},\n" 我得到下面提供的错误堆栈,
2 回答
慕的地10843
TA贡献1785条经验 获得超8个赞
@JsonDeserialize( using = JavaOffsetDateTimeDeserializer.class )
@JsonSerialize( using = JavaOffsetDateTimeSerializer.class )
private LocalDate created;
反序列化器将字符串转换为 Offsetdatetime,但创建的数据类型是 LocalDate,我认为从测试数据“2019-05-31T19:08:20.7712944Z”(包括区域)来看,您应该使用 OffsetDateTime 而不是 LocalDate
料青山看我应如是
TA贡献1772条经验 获得超8个赞
我找到了解决问题的方法。我需要更改所有 DTO 类的注释
@JsonDeserialize( using = JavaOffsetDateTimeDeserializer.class )
@JsonSerialize( using = JavaOffsetDateTimeSerializer.class )
到
@JsonSerialize( using = LocalDateSerializer.class )
@JsonDeserialize( using = LocalDateDeserializer.class )
现在测试通过了。
添加回答
举报
0/150
提交
取消