Junit java.lang.AssertionError:JSON路径预期不同的结果

Junit java.lang.AssertionError:JSON路径预期不同的结果,junit,jsonpath,mockmvc,Junit,Jsonpath,Mockmvc,我有一个Junit测试,它与mockMvc一起工作,它发生了一些奇怪的事情。 我的测试用例看起来是这样的 @Test public void getSignatureData() throws Exception { String dataXValues = "[0,5,10,15,20]"; String dataYValues1 = "[100.0,20.0,30.0,40.0,50.0]"; String dataYValues2 = "[1.0,2.0,3.0,4

我有一个Junit测试,它与mockMvc一起工作,它发生了一些奇怪的事情。 我的测试用例看起来是这样的

@Test
public void getSignatureData() throws Exception {
    String dataXValues = "[0,5,10,15,20]";
    String dataYValues1 = "[100.0,20.0,30.0,40.0,50.0]";
    String dataYValues2 = "[1.0,2.0,3.0,4.0,5.0]";
    this.mockMvc
    .perform(get("/sources/fmf/actuators/w01.pmv/signatures/1486684800000"))

    .andDo(print())
    .andExpect(status().isOk())
    .andExpect(jsonPath("$.signature.id").value("1486684800000"))
    .andExpect(jsonPath("$.signature.actuatorId").value("w01.pmv"))
    .andExpect(jsonPath("$.signature.operation").value("OPEN"))
        .andExpect(jsonPath("$.signature.timestamp").value("1486684800000"))
        .andExpect(jsonPath("$.signature.ref").value(true))
        .andExpect(jsonPath("$.signature.current").value(false))
        .andExpect(jsonPath("$.signature.valid").value(true))
        .andExpect(jsonPath("$.signature.source").value("A"))
        .andExpect(jsonPath("$.data[0].sensorSource").value("SEMA"))
        .andExpect(jsonPath("$.data[0].sensorType").value("PRESSURE"))
        .andExpect(jsonPath("$.data[0].xValues", is(dataXValues)))
        .andExpect(jsonPath("$.data[0].yValues").value(dataYValues1))
        .andExpect(jsonPath("$.data[1].sensorSource").value("SEMA"))
        .andExpect(jsonPath("$.data[1].sensorType").value("FLOW"))
        .andExpect(jsonPath("$.data[1].xValues").value(dataXValues))
        .andExpect(jsonPath("$.data[1].yValues").value(dataYValues2));
}
我希望它能起作用,但我得到了这个信息

java.lang.AssertionError: JSON path "$.data[0].xValues"
Expected: is "[0,5,10,15,20]"
but: was <[0,5,10,15,20]>
Expected :is "[0,5,10,15,20]"

Actual   :<[0,5,10,15,20]>

导入静态org.hamcrest.Matchers.*

我遇到了同样的问题,并通过使用以下方法将测试中的预期和实际数组转换为列表来解决它:

Arrays.asList()
这为我解决了这个问题

Arrays.asList()