public final class ComponentConditions extends Object
InspectableComponent
s. This is to be used with SubComponentExtractor#subComponentWith(ComponentContext, Condition)
and SubComponentDeepExtractor#deepSubComponentWith(ComponentContext, Condition)
.Modifier and Type | Method and Description |
---|---|
static <any> |
text(<any> condition)
Matcher that succeeds if a
InspectableComponent has text content that matches the
provided condition. |
static <any> |
text(<any> matcher)
Matcher that succeeds if a
InspectableComponent has text content that matches the
provided hamcrest matcher. |
static <any> |
textEquals(CharSequence text)
Matcher that succeeds if a
InspectableComponent has a text content that exactly matches
the provided string. |
static <any> |
textEquals(String text) |
static <any> |
typeIs(Class<? extends ComponentLifecycle> clazz)
Matcher that succeeds if the class of an
InspectableComponent exactly matches the
provided component class. |
public static <any> typeIs(Class<? extends ComponentLifecycle> clazz)
InspectableComponent
exactly matches the
provided component class.
Note that this won't match sub-types. This should not have any real-world implications as Components are not sub-classed.
assertThat(c, mComponent)
.has(
allOf(
deepSubComponentWith(c, typeIs(Text.class)),
subComponentWith(c, typeIs(MyCustomComponent.class))));
public static <any> textEquals(CharSequence text)
InspectableComponent
has a text content that exactly matches
the provided string.public static <any> textEquals(String text)
textEquals(CharSequence)
public static <any> text(<any> condition)
InspectableComponent
has text content that matches the
provided condition.
N.B. We are implicitly casting the CharSequence
to a String
when matching so
that more powerful matchers can be applied like sub-string matching.
mComponent = MyComponent.create(c).text("Cells interlinked within cells interlinked").build();
assertThat(c, mComponent)
.has(subComponentWith(c, startsWith("Cells")))
.doesNotHave(subComponentWith(c, text(containsString("A Tall White Fountain Played."))));
public static <any> text(<any> matcher)
InspectableComponent
has text content that matches the
provided hamcrest matcher.
#text(Condition)