当我测试 EP 并获取 JSON 响应时,没有精度的 BigDecimal 值会转换为 Integer,并且我不能期望使用 MockMvcResultMatchers.jsonPath 得到 BigDecimal。当有精度时,它会转换为 Double,当没有精度时,它会转换为 Integer。
我如何期望只有 BigDecimal 值,通过 ResultActions.andExpect 在测试中检查它?
这是一个java代码示例:
performGet()
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.data. value", equalTo(expectedValue)));