我有以下JSON,我需要使用JSONPath检查total的值是否为10:
{
"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"
}
]
}
我正在尝试使用
mockMvc.perform(get("/garage/equalParkingSpaces?levels=2&mSpaces=2&cSpaces=3"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.total", is(10)));
但它不起作用,我的测试失败了。请告诉我如何检查总值。