Reputation: 4931
rules=[{type:"path", value:"abc"},{type:"cookie", value:"xyz"}, ...]
I want to find if the array contains an object with properties (type=path
and value=abc
)
I tried something like this:
assertThat(rules, hasItem(hasProperty("type", equals("path"))));
But I didn't find a way to combine two hasProperty
methods. Can someone help me
Upvotes: 2
Views: 3151
Reputation: 10931
The following will try to apply each Matcher in the allOf()
check to each item in rules
:
assertThat(rules,
hasItem(allOf(hasProperty("type", equalTo("path")),
hasProperty("value", equalTo("abc")))));
Upvotes: 6