Given a Collection
or Iterable
of items, is there any Matcher
(or combination of matchers) that will assert every item matches a single Matcher
?
For example, given this item type:
public interface Person {
public String getGender();
}
I'd like to write an assertion that all items in a collection of Person
s have a specific gender
value. I'm thinking something like this:
Iterable<Person> people = ...;
assertThat(people, each(hasProperty("gender", "Male")));
Is there any way to do this without writing the each
matcher myself?