From 71b5871884cf3de3b675bead82bdf5255574801f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20No=C3=ABl?= Date: Sun, 15 Sep 2019 12:31:31 +0200 Subject: [PATCH] (#133) Fixes Matches and Mismatches type arguments --- src/main/java/org/llorllale/cactoos/matchers/Matches.java | 7 ++++--- .../java/org/llorllale/cactoos/matchers/Mismatches.java | 7 ++++--- .../java/org/llorllale/cactoos/matchers/MatchesTest.java | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/llorllale/cactoos/matchers/Matches.java b/src/main/java/org/llorllale/cactoos/matchers/Matches.java index bb13f434..991bb1c5 100644 --- a/src/main/java/org/llorllale/cactoos/matchers/Matches.java +++ b/src/main/java/org/llorllale/cactoos/matchers/Matches.java @@ -45,10 +45,12 @@ * } * * @param Type of item. + * @param Type of tested matcher. * @since 1.0.0 * @checkstyle ProtectedMethodInFinalClassCheck (200 lines) */ -public final class Matches extends TypeSafeDiagnosingMatcher> { +public final class Matches> extends + TypeSafeDiagnosingMatcher { /** * The testing arguments for the target matcher. @@ -70,8 +72,7 @@ public void describeTo(final Description desc) { } @Override - protected boolean matchesSafely(final Matcher matcher, - final Description dsc) { + protected boolean matchesSafely(final M matcher, final Description dsc) { matcher.describeTo(dsc); return matcher.matches(this.args); } diff --git a/src/main/java/org/llorllale/cactoos/matchers/Mismatches.java b/src/main/java/org/llorllale/cactoos/matchers/Mismatches.java index fdd9a937..57e2b135 100644 --- a/src/main/java/org/llorllale/cactoos/matchers/Mismatches.java +++ b/src/main/java/org/llorllale/cactoos/matchers/Mismatches.java @@ -51,6 +51,7 @@ * } * * @param Type of item. + * @param Type of tested matcher. * @since 1.0.0 * @todo #106:30min Convert all the Matcher tests to use Mismatches * instead of checking directly the output of mismatch methods or @@ -61,7 +62,8 @@ * working and throwing errors. * @checkstyle ProtectedMethodInFinalClassCheck (200 lines) */ -public final class Mismatches extends TypeSafeDiagnosingMatcher> { +public final class Mismatches> extends + TypeSafeDiagnosingMatcher { /** * The testing arguments for the target matcher. @@ -132,8 +134,7 @@ public void describeTo(final Description desc) { // And then introduce some tests to validate that the description // is properly constructed. @Override - protected boolean matchesSafely(final Matcher matcher, - final Description dsc) { + protected boolean matchesSafely(final M matcher, final Description dsc) { boolean mismatch; try { new Assertion<>("", this.args, matcher).affirm(); diff --git a/src/test/java/org/llorllale/cactoos/matchers/MatchesTest.java b/src/test/java/org/llorllale/cactoos/matchers/MatchesTest.java index 6ab6ed01..efbdcceb 100644 --- a/src/test/java/org/llorllale/cactoos/matchers/MatchesTest.java +++ b/src/test/java/org/llorllale/cactoos/matchers/MatchesTest.java @@ -61,7 +61,7 @@ public void matches() { public void matchStatus() { new Assertion<>( "Matcher TextIs(abc) gives negative result for Text(def)", - new Matches(() -> "def").matches(new TextIs("abc")), + new Matches<>(new TextOf("def")).matches(new TextIs("abc")), new IsEqual<>(false) ).affirm(); } @@ -72,7 +72,7 @@ public void matchStatus() { @Test public void describeActual() { final Description description = new StringDescription(); - new Matches(new TextOf("expected")).matchesSafely( + new Matches(new TextOf("expected")).matchesSafely( new TextIs("actual"), description ); new Assertion<>( @@ -88,7 +88,7 @@ public void describeActual() { @Test public void describeExpected() { final Description description = new StringDescription(); - new Matches(new TextOf("expected")).describeTo(description); + new Matches<>(new TextOf("expected")).describeTo(description); new Assertion<>( "describes the expected value", description.toString(),