Let's say I have a List<A>
where
class A {
private Integer val;
private String name;
}
and in my test case I get this list, with uncertain size, and content. What I wish to do is to compare val
field of two list elements that I know has to be in the list with given name
fields;
List<A> list = logic.getList();
assertThat(list, allOf(hasItems(hasProperty("name", equalTo("first")),
hasItems(hasProperty("val", equalTo(***value from another member with name = "second"))));
How can I achieve this, or is this even possible with Hamcrest Matchers?