diff --git a/hamcrest/src/main/java/org/hamcrest/beans/HasPropertyWithValue.java b/hamcrest/src/main/java/org/hamcrest/beans/HasPropertyWithValue.java index 29b299b8..acd61577 100644 --- a/hamcrest/src/main/java/org/hamcrest/beans/HasPropertyWithValue.java +++ b/hamcrest/src/main/java/org/hamcrest/beans/HasPropertyWithValue.java @@ -124,7 +124,7 @@ public Condition apply(Method readMethod, Description mismatch) { return notMatched(); } catch (Exception e) { throw new IllegalStateException( - "Calling: '" + readMethod + "' should not have thrown " + e); + "Calling: '" + readMethod + "' should not have thrown", e); } } }; diff --git a/hamcrest/src/test/java/org/hamcrest/beans/HasPropertyWithValueTest.java b/hamcrest/src/test/java/org/hamcrest/beans/HasPropertyWithValueTest.java index d5f427e6..fde4ec02 100644 --- a/hamcrest/src/test/java/org/hamcrest/beans/HasPropertyWithValueTest.java +++ b/hamcrest/src/test/java/org/hamcrest/beans/HasPropertyWithValueTest.java @@ -1,13 +1,19 @@ package org.hamcrest.beans; -import org.hamcrest.*; +import org.hamcrest.AbstractMatcherTest; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.StringDescription; import org.hamcrest.core.IsEqual; import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; import java.beans.SimpleBeanInfo; +import java.nio.file.Path; +import java.nio.file.Paths; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasToString; import static org.hamcrest.Matchers.is; import static org.hamcrest.beans.HasPropertyWithValue.hasProperty; import static org.hamcrest.beans.HasPropertyWithValue.hasPropertyAtPath; @@ -71,6 +77,11 @@ public void testMatchesPath() { assertMismatchDescription("inner.inner.property.was \"not expected\"", hasPropertyAtPath("inner.inner.property", equalTo("something")), new BeanWithInner(new BeanWithInner(shouldNotMatch))); } + public void testMatchesAbstract() { + Path path = Paths.get("hi.txt"); + assertThat(path, hasProperty("fileName", hasToString("hi.txt"))); + } + public void testDescribeTo() { assertDescription("hasProperty(\"property\", )", hasProperty("property", equalTo(true))); }