This Hamcrest assert checks that the list contains at least one Stakeholder object whose name is "Health Associates". This is clearly much nicer than having to iterate through the result list and test each Stakeholder object individually.
Unfortunatly, this doesn't work: you get a compilation error along the following lines:
The method assertThat(T, Matcher) in the type MatcherAssert is not applicable for the arguments (List<Stakeholder>, Matcher>)
Indeed, Hamcrest seems to be having trouble with the idea that a List of Stakeholders is also a List of Objects.
So can't we just cast the result (a List object) to a List
My friend Eduard Letifov pointed out the following solution, which will work both within Eclipse and using a normal JDK: