From b15c7596854598d50d2126a4ee9055291d3181d6 Mon Sep 17 00:00:00 2001 From: "Trejkaz (pen name)" Date: Fri, 13 Mar 2020 08:41:24 +0900 Subject: [PATCH 1/2] Failing test for issue #152 --- .../hamcrest/beans/HasPropertyWithValueTest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hamcrest/src/test/java/org/hamcrest/beans/HasPropertyWithValueTest.java b/hamcrest/src/test/java/org/hamcrest/beans/HasPropertyWithValueTest.java index d5f427e6b..fde4ec02c 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))); } From 42e69bb1d1431c01f23c8c500e3a4ace63d9ae94 Mon Sep 17 00:00:00 2001 From: "Trejkaz (pen name)" Date: Fri, 13 Mar 2020 08:44:32 +0900 Subject: [PATCH 2/2] Fixing a lost cause for an exception path --- .../src/main/java/org/hamcrest/beans/HasPropertyWithValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hamcrest/src/main/java/org/hamcrest/beans/HasPropertyWithValue.java b/hamcrest/src/main/java/org/hamcrest/beans/HasPropertyWithValue.java index 29b299b88..acd615770 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); } } };