From 7ba32cc144c8ca1b5c6944cda0554ab1b65e7075 Mon Sep 17 00:00:00 2001 From: prmr Date: Thu, 20 Jun 2019 09:59:22 -0400 Subject: [PATCH 1/3] #182 Supply Javadoc comments for MatcherAssert --- .../main/java/org/hamcrest/MatcherAssert.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java index 049e1df3..33ccb619 100644 --- a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java +++ b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java @@ -1,11 +1,37 @@ package org.hamcrest; +/** + * Utility class that contains static methods for verifying that assertions + * hold and reporting the violation when they do not. + */ public class MatcherAssert { + + /** + * Verifies that matcher matches actual. + * Convenience method for performing an assertion without supplying a reason. + * Equivalent to assertThat("", actual, matcher). + * + * @see {@link MatcherAssert#assertThat(String, Object, Matcher)} + * + * @param The type of the actual value to match. + * @param actual A value to test. + * @param matcher The matcher to use for matching the actual value + */ public static void assertThat(T actual, Matcher matcher) { assertThat("", actual, matcher); } + /** + * Verifies that matcher matches actual. If the matcher + * does not match the actual value, this method throws an AssertionError + * with a description of the mismatch. + * + * @param The type of the actual value to match. + * @param reason A reason for explaining the mismatch. + * @param actual A value to test. + * @param matcher The matcher to use for matching the actual value + */ public static void assertThat(String reason, T actual, Matcher matcher) { if (!matcher.matches(actual)) { Description description = new StringDescription(); @@ -19,6 +45,14 @@ public static void assertThat(String reason, T actual, Matcher ma } } + /** + * Verifies that assertion evaluates to true, and + * throws an AssertionError with the message reason + * if it does not. + * + * @param reason The message use to report an assertion failure. + * @param assertion An expression expected to evaluate to true. + */ public static void assertThat(String reason, boolean assertion) { if (!assertion) { throw new AssertionError(reason); From 9fe30fecf7341c5c7b06ec80c8e46cddc40d6267 Mon Sep 17 00:00:00 2001 From: prmr Date: Thu, 20 Jun 2019 09:59:22 -0400 Subject: [PATCH 2/3] #182 Correct indentation --- .../main/java/org/hamcrest/MatcherAssert.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java index 049e1df3..33ccb619 100644 --- a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java +++ b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java @@ -1,11 +1,37 @@ package org.hamcrest; +/** + * Utility class that contains static methods for verifying that assertions + * hold and reporting the violation when they do not. + */ public class MatcherAssert { + + /** + * Verifies that matcher matches actual. + * Convenience method for performing an assertion without supplying a reason. + * Equivalent to assertThat("", actual, matcher). + * + * @see {@link MatcherAssert#assertThat(String, Object, Matcher)} + * + * @param The type of the actual value to match. + * @param actual A value to test. + * @param matcher The matcher to use for matching the actual value + */ public static void assertThat(T actual, Matcher matcher) { assertThat("", actual, matcher); } + /** + * Verifies that matcher matches actual. If the matcher + * does not match the actual value, this method throws an AssertionError + * with a description of the mismatch. + * + * @param The type of the actual value to match. + * @param reason A reason for explaining the mismatch. + * @param actual A value to test. + * @param matcher The matcher to use for matching the actual value + */ public static void assertThat(String reason, T actual, Matcher matcher) { if (!matcher.matches(actual)) { Description description = new StringDescription(); @@ -19,6 +45,14 @@ public static void assertThat(String reason, T actual, Matcher ma } } + /** + * Verifies that assertion evaluates to true, and + * throws an AssertionError with the message reason + * if it does not. + * + * @param reason The message use to report an assertion failure. + * @param assertion An expression expected to evaluate to true. + */ public static void assertThat(String reason, boolean assertion) { if (!assertion) { throw new AssertionError(reason); From e2c8bd80349e94279f39a4a9e1ed0f119b8c4d24 Mon Sep 17 00:00:00 2001 From: prmr Date: Thu, 20 Jun 2019 10:03:34 -0400 Subject: [PATCH 3/3] #182 Correct indentation --- hamcrest/src/main/java/org/hamcrest/MatcherAssert.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java index 33ccb619..b6c6166a 100644 --- a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java +++ b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java @@ -7,7 +7,7 @@ */ public class MatcherAssert { - /** + /** * Verifies that matcher matches actual. * Convenience method for performing an assertion without supplying a reason. * Equivalent to assertThat("", actual, matcher).