/** * Creates a matcher that matches when the examined object has a JavaBean property * with the specified name. * <p/> * For example: * <pre>assertThat(myBean, hasProperty("foo"))</pre> * * @param propertyName * the name of the JavaBean property that examined beans should possess */ public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName) { return org.hamcrest.beans.HasProperty.<T>hasProperty(propertyName); }
/** * Creates a matcher that matches when the examined object has a JavaBean property * with the specified name. * For example: * <pre>assertThat(myBean, hasProperty("foo"))</pre> * * @param propertyName * the name of the JavaBean property that examined beans should possess */ public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName) { return org.hamcrest.beans.HasProperty.hasProperty(propertyName); }
@Test public void describesAMismatch() { assertMismatchDescription("no \"aNonExistentProp\" in <[Person: a bean]>", hasProperty("aNonExistentProp"), bean); } }
@Test public void doesNotMatchIfPropertyDoesNotExist() { assertDoesNotMatch(hasProperty("aNonExistentProp"), bean); }
@Test public void matchesWhenThePropertyExists() { assertMatches(hasProperty("writeOnlyProperty"), bean); }
@Test public void describesItself() { assertDescription("hasProperty(\"property\")", hasProperty("property")); }
@Test public void copesWithNullsAndUnknownTypes() { Matcher<Object> matcher = hasProperty("irrelevant"); assertNullSafe(matcher); assertUnknownTypeSafe(matcher); }
/** * Creates a matcher that matches when the examined object has a JavaBean property * with the specified name. * For example: * <pre>assertThat(myBean, hasProperty("foo"))</pre> * * @param propertyName * the name of the JavaBean property that examined beans should possess */ public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName) { return org.hamcrest.beans.HasProperty.<T>hasProperty(propertyName); }
/** * Creates a matcher that matches when the examined object has a JavaBean property * with the specified name. * For example: * <pre>assertThat(myBean, hasProperty("foo"))</pre> * * @param propertyName * the name of the JavaBean property that examined beans should possess */ public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName) { return org.hamcrest.beans.HasProperty.hasProperty(propertyName); }
public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName) { return org.hamcrest.beans.HasProperty.hasProperty(propertyName); }