Sorry for the long title, but my problem is as follows;
I have these classes;
public class A {
int a1;
int a2;
List<B> listOfB;
}
and
public class B {
int b1;
int b2;
List<C> listOfC;
}
and
public class C {
int c1;
int c2;
}
If it were only for B
to assert the list of C
it has, I would use the following custom matcher;
Matcher<Iterable<C>> cMatcher = Matchers.hasItems(allOf(hasProperty("c1", equalTo(c1)), hasProperty("c2", equalTo(c2))))
But how can I do the assertion from A
? I want to use this C
list matcher in a larger scope matcher that does the following;
Matchers.hasItems(allOf(hasProperty("b1", equalTo(b1)), hasProperty("b2", equalTo(b2)), hasProperty("listOfC", cMatcher)))
So in a way I wish to match a B
in listOfB
where has given b1
, and b2
values, together with its listOfC
containing a specific C
with values c1
and c2
.