public final class ReflectionMatchers extends Object
Modifier and Type | Method and Description |
---|---|
static <T> org.hamcrest.Matcher<? super T> |
hasProperty(String chain,
org.hamcrest.Matcher<?> valueMatcher)
This matcher is similar to
Matchers.hasProperty(java.lang.String) but better! |
static <T> org.hamcrest.Matcher<? super T> |
propertiesMatcher(Map<String,org.hamcrest.Matcher<Object>> values) |
public static <T> org.hamcrest.Matcher<? super T> hasProperty(String chain, org.hamcrest.Matcher<?> valueMatcher)
Matchers.hasProperty(java.lang.String)
but better!
Sometimes you need to assert on a property that is deep down in the object, and then you would do:
hasProperty("a", hasProperty("b", hasProperty("c", equalTo("abc")))
But with this matcher you can just write:
hasProperty("a.b.c", equalTo("abc"))
It's worth noting that the two above calls are completely equivalent, i.e. this method
is implemented in terms of Matchers.hasProperty(java.lang.String)
.
T
- type of the thing we assert onchain
- property to check, can be chained (e.g. "a.b.c")valueMatcher
- matcher on the propertyCopyright © 2002-2018 Atlassian. All Rights Reserved.