I have the following JSON and I need to check if the value of total is 10 using JSONPath:
{
"total": 10,
"parkingSlots": [
{
"type": "MOTORCYCLE",
"empty": true,
"spaceId": "1m60"
},
{
"type": "MOTORCYCLE",
"empty": true,
"spaceId": "1m61"
},
{
"type": "CAR",
"empty": true,
"spaceId": "1c62"
},
{
"type": "CAR",
"empty": true,
"spaceId": "1c63"
},
{
"type": "CAR",
"empty": true,
"spaceId": "1c64"
},
{
"type": "MOTORCYCLE",
"empty": true,
"spaceId": "2m65"
},
{
"type": "MOTORCYCLE",
"empty": true,
"spaceId": "2m66"
},
{
"type": "CAR",
"empty": true,
"spaceId": "2c67"
},
{
"type": "CAR",
"empty": true,
"spaceId": "2c68"
},
{
"type": "CAR",
"empty": true,
"spaceId": "2c69"
}
]
}
I am trying to use
mockMvc.perform(get("/garage/equalParkingSpaces?levels=2&mSpaces=2&cSpaces=3"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.total", is(10)));
But it does not work and my test fails. Please tell me how else I could check for the value of total.