From 68e24d63617517ed7d675c4d2218f1af4f177d29 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Sat, 27 Feb 2021 08:49:25 -0500 Subject: [PATCH 1/5] readability of .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a436cfa..67af4db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # Maven pom.xml.versionsBackup +target # Eclipse .project .classpath .settings -target From 8c7ba890275cda15162519c58aa4bb5436745cce Mon Sep 17 00:00:00 2001 From: Brian Long Date: Sat, 27 Feb 2021 08:49:41 -0500 Subject: [PATCH 2/5] added javadoc comments --- .../inteligr8/junit5/AssertCollection.java | 44 +++++++ .../com/inteligr8/junit5/AssertRegex.java | 112 ++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/src/main/java/com/inteligr8/junit5/AssertCollection.java b/src/main/java/com/inteligr8/junit5/AssertCollection.java index 7834d83..ad17b00 100644 --- a/src/main/java/com/inteligr8/junit5/AssertCollection.java +++ b/src/main/java/com/inteligr8/junit5/AssertCollection.java @@ -4,29 +4,73 @@ import java.util.Collection; import org.junit.jupiter.api.Assertions; +/** + * This class implements JUnit4 assertion methods focused on collections. + * + * @author brian@inteligr8.com + */ public class AssertCollection { + /** + * This method evaluates the size of a collection. + * + * @param expectedCount The expected size of the collection + * @param actualCollection The collection to evaluate + */ public static void assertSize(int expectedCount, Collection actualCollection) { assertSize(expectedCount, actualCollection, null); } + /** + * This method evaluates the size of a collection. + * + * @param message A message to record on failure + * @param expectedCount The expected size of the collection + * @param actualCollection The collection to evaluate + */ public static void assertSize(int expectedCount, Collection actualCollection, String message) { if (expectedCount == 0) Assertions.assertTrue(actualCollection == null || actualCollection.isEmpty(), message); else Assertions.assertTrue(actualCollection != null && actualCollection.size() == expectedCount, message); } + /** + * This method evaluates the contents of a collection + * + * @param expectedElement A expected element in the collection + * @param actualCollection A collection to search/inspect + */ public static void assertContains(T expectedElement, Collection actualCollection) { assertContains(expectedElement, actualCollection, null); } + /** + * This method evaluates the contents of a collection + * + * @param expectedElements A subset of the expected elements in the collection + * @param actualCollection A collection to search/inspect + */ public static void assertContains(Collection expectedElements, Collection actualCollection) { assertContains(expectedElements, actualCollection, null); } + /** + * This method evaluates the contents of a collection + * + * @param message A message to record on failure + * @param expectedElement A expected element in the collection + * @param actualCollection A collection to search/inspect + */ public static void assertContains(T expectedElement, Collection actualCollection, String message) { Assertions.assertTrue(actualCollection != null && actualCollection.contains(expectedElement), message); } + /** + * This method evaluates the contents of a collection + * + * @param message A message to record on failure + * @param expectedElements A subset of the expected elements in the collection + * @param actualCollection A collection to search/inspect + */ public static void assertContains(Collection expectedElements, Collection actualCollection, String message) { Assertions.assertTrue(actualCollection != null && actualCollection.containsAll(expectedElements), message); } diff --git a/src/main/java/com/inteligr8/junit5/AssertRegex.java b/src/main/java/com/inteligr8/junit5/AssertRegex.java index 53e019d..285f3b5 100644 --- a/src/main/java/com/inteligr8/junit5/AssertRegex.java +++ b/src/main/java/com/inteligr8/junit5/AssertRegex.java @@ -5,38 +5,112 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Assertions; +/** + * This class implements JUnit4 assertion methods focused on regular expression matching. + * + * @author brian@inteligr8.com + */ public class AssertRegex { + /** + * This method evaluates the format of the specified value using the + * specified regular expression. + * + * @param expectedRegex A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertNotMatches(String, String) + */ public static void assertMatches(String expectedRegex, String actual) { assertMatches(expectedRegex, actual, null); } + /** + * This method evaluates the format of the specified value using the + * specified regular expression. + * + * @param message A message to record on failure + * @param expectedRegex A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertNotMatches(String, String, String) + */ public static void assertMatches(String expectedRegex, String actual, String message) { Pattern pattern = Pattern.compile(expectedRegex); assertMatches(pattern, actual, message); } + /** + * This method evaluates the format of the specified value using the + * specified regular expression. + * + * @param expected A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertNotMatches(Pattern, String) + */ public static void assertMatches(Pattern expected, String actual) { assertMatches(expected, actual, null); } + /** + * This method evaluates the format of the specified value using the + * specified regular expression. + * + * @param message A message to record on failure + * @param expected A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertNotMatches(String, Pattern, String) + */ + public st public static void assertMatches(Pattern expected, String actual, String message) { assertMatches(false, expected, actual, message); } + /** + * This method negates the evaluation of the format of the specified value + * using the specified regular expression. + * + * @param expectedRegex A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(String, String) + */ public static void assertNotMatches(String expectedRegex, String actual) { assertNotMatches(expectedRegex, actual, null); } + /** + * This method negates the evaluation of the format of the specified value + * using the specified regular expression. + * + * @param message A message to record on failure + * @param expectedRegex A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(String, String, String) + */ public static void assertNotMatches(String expectedRegex, String actual, String message) { Pattern pattern = Pattern.compile(expectedRegex); assertNotMatches(pattern, actual, message); } + /** + * This method negates the evaluation of the format of the specified value + * using the specified regular expression. + * + * @param expected A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(Pattern, String) + */ public static void assertNotMatches(Pattern expected, String actual) { assertNotMatches(expected, actual, null); } + /** + * This method negates the evaluation of the format of the specified value + * using the specified regular expression. + * + * @param message A message to record on failure + * @param expected A regular expression + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(String, Pattern, String) + */ public static void assertNotMatches(Pattern expected, String actual, String message) { assertMatches(true, expected, actual, message); } @@ -52,19 +126,57 @@ public class AssertRegex { + /** + * This method counts the matches of the specified value against the + * specified regular expression. + * + * @param expectedRegex A regular expression + * @param expectedCount The count of an expected regex match + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(String, String) + */ public static void assertFind(String expectedRegex, int expectedCount, String actual) { assertFind(expectedRegex, expectedCount, actual, null); } + /** + * This method counts the matches of the specified value against the + * specified regular expression. + * + * @param message A message to record on failure + * @param expectedRegex A regular expression + * @param expectedCount The count of an expected regex match + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(String, String, String) + */ public static void assertFind(String expectedRegex, int expectedCount, String actual, String message) { Pattern pattern = Pattern.compile(expectedRegex); assertFind(pattern, expectedCount, actual, message); } + /** + * This method counts the matches of the specified value against the + * specified regular expression. + * + * @param expected A regular expression + * @param expectedCount The count of an expected regex match + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(Pattern, String) + */ public static void assertFind(Pattern expected, int expectedCount, String actual) { assertFind(expected, expectedCount, actual, null); } + /** + * This method counts the matches of the specified value against the + * specified regular expression. + * + * @param message A message to record on failure + * @param expected A regular expression + * @param expectedCount The count of an expected regex match + * @param actual A text value to evaluate + * @see AssertRegex#assertMatches(Pattern, String) + */ public static void assertFind(Pattern expected, int expectedCount, String actual, String message) { Matcher matcher = expected.matcher(actual); int count = 0; From 517d6854a74061d167e29cc8f65d2a048fd4d5ae Mon Sep 17 00:00:00 2001 From: Brian Long Date: Sat, 27 Feb 2021 08:49:51 -0500 Subject: [PATCH 3/5] added pom metadata --- pom.xml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4c3a463..46e1c27 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,21 @@ Reusable JUnit5 Extensions + + https://bitbucket.org/inteligr8/junit5-ext + + + Inteligr8 + https://www.inteligr8.com + + + + Brian Long + brian@inteligr8.com + https://twitter.com/brianmlong + + + 1.8 1.8 @@ -27,6 +42,7 @@ + maven-surefire-plugin 2.22.2 @@ -43,6 +59,21 @@ + + + maven-javadoc-plugin + + + javadoc + package + jar + + true + public + + + + @@ -50,7 +81,7 @@ inteligr8-releases Inteligr8 Releases - http://repos.yateslong.us/nexus/repository/inteligr8-public + http://repos.inteligr8.com/nexus/repository/inteligr8-public default From 8e771f73b91abdb0c27a68929b1faaccba349465 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Sat, 27 Feb 2021 08:59:43 -0500 Subject: [PATCH 4/5] fixed copy/paste issues --- src/main/java/com/inteligr8/junit5/AssertRegex.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/inteligr8/junit5/AssertRegex.java b/src/main/java/com/inteligr8/junit5/AssertRegex.java index 285f3b5..319fe46 100644 --- a/src/main/java/com/inteligr8/junit5/AssertRegex.java +++ b/src/main/java/com/inteligr8/junit5/AssertRegex.java @@ -57,9 +57,8 @@ public class AssertRegex { * @param message A message to record on failure * @param expected A regular expression * @param actual A text value to evaluate - * @see AssertRegex#assertNotMatches(String, Pattern, String) + * @see AssertRegex#assertNotMatches(Pattern, String, String) */ - public st public static void assertMatches(Pattern expected, String actual, String message) { assertMatches(false, expected, actual, message); } @@ -109,7 +108,7 @@ public class AssertRegex { * @param message A message to record on failure * @param expected A regular expression * @param actual A text value to evaluate - * @see AssertRegex#assertMatches(String, Pattern, String) + * @see AssertRegex#assertMatches(Pattern, String, String) */ public static void assertNotMatches(Pattern expected, String actual, String message) { assertMatches(true, expected, actual, message); From 1d314c4c0532ed69e44bd43577772c4ffb110632 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Sat, 27 Feb 2021 08:59:55 -0500 Subject: [PATCH 5/5] fixed build warnings --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 46e1c27..e16e448 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ + utf-8 1.8 1.8 5.7.0 [1.3, 1.4) - org.junit.jupiter @@ -62,13 +62,13 @@ maven-javadoc-plugin + 3.2.0 javadoc package jar - true public