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
diff --git a/pom.xml b/pom.xml
index 87bc1f8..034a16b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,14 +9,29 @@
Reusable JUnit5 Extensions
+
+ https://bitbucket.org/inteligr8/junit5-ext
+
+
+ Inteligr8
+ https://www.inteligr8.com
+
+
+
+ Brian Long
+ brian@inteligr8.com
+ https://twitter.com/brianmlong
+
+
+
+ utf-8
1.8
1.8
5.7.0
[1.3, 1.4)
-
org.junit.jupiter
@@ -27,6 +42,7 @@
+
maven-surefire-plugin
2.22.2
@@ -43,6 +59,21 @@
+
+
+ maven-javadoc-plugin
+ 3.2.0
+
+
+ javadoc
+ package
+ jar
+
+ 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
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..319fe46 100644
--- a/src/main/java/com/inteligr8/junit5/AssertRegex.java
+++ b/src/main/java/com/inteligr8/junit5/AssertRegex.java
@@ -5,38 +5,111 @@ 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(Pattern, String, String)
+ */
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(Pattern, String, String)
+ */
public static void assertNotMatches(Pattern expected, String actual, String message) {
assertMatches(true, expected, actual, message);
}
@@ -52,19 +125,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;