In a test case I perform a call with the following response:
[
{
"ourID": "770050010000000010",
"date": "2019-03-07",
"otherValue": null
},
{
"ourID": "770050010000000020",
"date": "2019-03-07",
"otherValue": null
}
]
The test is performed by Serenity and I use RestAssured to perform the call:
Response response = RestAssuredApiHelper.baseRestCall(headers, baseUrl, path)
.body(requestBody)
.post();
assertThat(response.getBody().jsonPath().get("$.[?(@.ourID=='770050010000000010')].date"), contains("2019-03-07"));
The assertion is not working, probably because RestAssured uses Gpath instead of JsonPath, but in all the docs i've been reading there are examples of ways this could work. What am I missing here?
The error I get is:
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: unexpected token: [ @ line 1, column 29.
$.[?(@.meteringPointEANID=='770050010000000010')].energySource
^
1 error