public final class SubComponentDeepExtractor extends java.lang.Object
Recursively extracts sub components from a Component, wrapping them in an
Components are extracted in a depth-first way so that they match the hierarchy indices when going from top to bottom.
In most cases you will want to use the
|Modifier and Type||Method and Description|
Verify that a component tree contains a component that matches the provided condition at any level in its tree.
Extract sub components recursively, from a provided Component in a depth-first manner.
public static SubComponentDeepExtractor subComponentsDeeply(ComponentContext c)
public static <any> deepSubComponentWith(ComponentContext c, <any> inner)
Note that asserting on indirect children breaks encapsulation and can lead to Change
Detector Tests. Prefer
Condition) over this whenever possible.
MyWrapperComponentSpecthat creates a
Cardwhich contains a
textprop that your component accepts.
You want to ensure that the text truncation logic correctly applies to the text that sits
inside the card. Using
Condition) won't work here as it will only be able to make assertions on the
Card but not the
For more applicable combinators, see below:
mComponent = MyWrapperComponent.create(c).text("I'm Mr. Meeseeks! Look at me!").build(); assertThat(c, mComponent) .has(deepSubComponentWith(c, textEquals("I'm Mr. Meeseeks!"))) .doesNotHave(deepSubComponentWith(c, text(containsString("wubba lubba dub dub"))));
c- The ComponentContext used to create the tree.
inner- The condition that at least one sub component needs to match.