I have the following object graph:
Order --> List of Lines --> List of Shipments object
The Line object has an attribute called lineNumber. The Shipment object also has an attribute called lineNumber. I don't know why they have it on both, but those are the cards I have been dealt with.
Would it be possible to compare that the line.getLineNumber().equals(shipment.getLineNumber())
for each line?
So in effect, I want to test the following:
for(Line line : order.getLines(){
for(Shipment ship : line.getShipments()) {
assertEquals(line.getLineNumber(), shipment.getLineNumber());
}
}
I tried the following, but it didn't work:
assertThat(order.getLines(), everyItem(Matchers.<Line>hasProperty("shipments", everyItem(Matchers.<Shipment>hasProperty("lineNumber", is(line.getLineNumber())))))
Obviously, I don't have a reference to line, so how would I compare the values in this case?