rest-driver/rest-driver — Issue #82: hasJsonPath should not match if the json path result is empty
Author: kelveden
Created: 2011-10-19 09:06:56+00:00
State: open

Consider the following JSON:

{
items: [
{ id: 1 },
{ id: 2 }
]
}

And now consider the following JSON path:

$.items.id

Using the JsonPath component, this JSON path will match against multiple nodes (i.e. will return a JSONArray). However, now consider the following JSON:

{
items: []
}

The JsonPath component will still return a JSON array but it will be empty. However, because _hasJsonPath_ considers the match to be successful as long as JsonPath returns a non-null value this is considered a "match" - i.e. _assertThat(myJson, not(hasJsonPath("$.items.id")))_ would fail.

hasJsonPath should not match if the JSON array returned by JsonPath is empty.