Ok, what version of Java do you use? What version of JUnit? Do you have
the Hamcrest library in the classpath?
Are you having the SAME classpath for compile and for runtime?
I suspect that you have one classpath for compile time (like in your IDE
(Eclipse, IDEA, etc)) and a slightly different one during run/test time.
The code below works for me, with onlythe (List) cast added. The
additional List<Object> cast should be superfluous. But then again, I
also have the unchecked cast warning.
--- In
junit@..., "Alan" <Alan.Burlison@...> wrote:
>
> > This way works:
> > List<AgreementAndAgreementType> result =
AgreementAndAgreementTypeDAO.listByUser(c, userId);
> > assertThat( (List)result, everyItem(hasProperty("userId",
equalTo(userId))));
> >
> > Adding a cast to raw List makes the parameters uniform, therefore
allowing for the call.
>
> Unfortunately it still doesn't seem to work:
>
> cannot find symbol
> symbol : method
assertThat(java.util.List,org.hamcrest.Matcher<java.lang.Iterable<java.l\
ang.Object>>)
>
> What does (partially) work is this excrescence:
>
> assertThat((List<Object>)(List)result,
> everyItem(hasProperty("userId", equalTo(userId))));
>
> but that generates an 'unchecked cast' warning.
>