public final class ComponentConditions
extends java.lang.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> |
inspectedTypeIs(java.lang.Class<? extends Component> clazz)
Matcher that succeeds if the class of an
InspectableComponent exactly matches the
provided component class. |
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(java.lang.CharSequence text)
Matcher that succeeds if a
InspectableComponent has a text content that exactly matches
the provided string. |
static <any> |
textEquals(java.lang.String text) |
static <any> |
typeIs(<any> clazz) |
static <any> |
typeIs(java.lang.Class<? extends Component> clazz)
Matcher that succeeds if the class of an
Component exactly matches the provided
component class. |
public static <any> inspectedTypeIs(java.lang.Class<? extends Component> 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> typeIs(java.lang.Class<? extends Component> clazz)
Component
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> typeIs(<any> clazz)
public static <any> textEquals(java.lang.CharSequence text)
InspectableComponent
has a text content that exactly matches
the provided string.public static <any> textEquals(java.lang.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)