I'm writing simple test which checks method returning some of interface beneath Collection
. I'm trying to abstract internal representation of this collection as much as possible, so that this test will pass in both cases: when method returns List
and Set
.
The Set
is supposed to be ordered (LinkedHashSet
or LinkedHashMap
backed Set
) so I've got to test order too. So generally I'd like to write test like this:
assertThat(returnedList, containsOrdered('t1", "t2", "t3"));
which will fail iff both collections aren't "the same" (i.e. the same values in the same ordering).
I've found Hamcrest library to be useful in this case, however I'm stuck in it's documentation. Any help would be appreciated, however I'll try to avoid writing CollectionTestUtil or my own Hamcrest Matcher
if it's possible.