I have a Junit test which works with mockMvc, and it happens something weird. My test case looks like that...
@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));
}
And I expect it works, but I got this message.
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]>
are there someone can help me? In this case, I use those..
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import static org.hamcrest.Matchers.*;