Reputation: 14678
I tried the following code, for matching a single ComplexObject in a List
assertThat(complexObjectList, Matchers.<ComplexObject>hasItems(
hasProperty("lang", equalTo(lang)),
hasProperty("name", equalTo(name)),
hasProperty("desc", equalTo(desc)));
I want to have a filter of
match(lang) && match(name) && match(desc)
but with the above code, i get
match(lang) || match(name) || match(desc)
How can I verify those three different hasProperty
matchers?
Upvotes: 3
Views: 3241
Reputation: 24510
You can use the allOf
matcher.
assertThat(complexObjectList,
Matchers.<ComplexObject>hasItem(allOf(
hasProperty("lang", equalTo(lang)),
hasProperty("name", equalTo(name)),
hasProperty("desc", equalTo(desc))));
Upvotes: 11