diff options
author | Arturo Bernal <arturobernalg@gmail.com> | 2021-08-29 21:47:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-29 15:47:30 -0400 |
commit | 0a73261eefd00b3431466f26e5600a0f3e80b18a (patch) | |
tree | 4b9344de2c2c255a8be200b73b433f642ff73771 /src/test/java/org/apache/commons/lang3/exception | |
parent | 5afd54ce6754de7963563ce755ff3cbeb5d5aed3 (diff) | |
download | apache-commons-lang-0a73261eefd00b3431466f26e5600a0f3e80b18a.tar.gz |
Simplify assertions with equivalent but more simple. (#792)
Diffstat (limited to 'src/test/java/org/apache/commons/lang3/exception')
-rw-r--r-- | src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java index 8a4d65247..acbc438bd 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -562,73 +563,73 @@ public class ExceptionUtilsTest { @Test public void testThrowableOf_ThrowableClass() { - assertEquals(null, ExceptionUtils.throwableOfThrowable(null, null)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(null, NestableException.class)); + assertNull(ExceptionUtils.throwableOfThrowable(null, null)); + assertNull(ExceptionUtils.throwableOfThrowable(null, NestableException.class)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withoutCause, null)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withoutCause, ExceptionWithCause.class)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withoutCause, NestableException.class)); + assertNull(ExceptionUtils.throwableOfThrowable(withoutCause, null)); + assertNull(ExceptionUtils.throwableOfThrowable(withoutCause, ExceptionWithCause.class)); + assertNull(ExceptionUtils.throwableOfThrowable(withoutCause, NestableException.class)); assertEquals(withoutCause, ExceptionUtils.throwableOfThrowable(withoutCause, ExceptionWithoutCause.class)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(nested, null)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(nested, ExceptionWithCause.class)); + assertNull(ExceptionUtils.throwableOfThrowable(nested, null)); + assertNull(ExceptionUtils.throwableOfThrowable(nested, ExceptionWithCause.class)); assertEquals(nested, ExceptionUtils.throwableOfThrowable(nested, NestableException.class)); assertEquals(nested.getCause(), ExceptionUtils.throwableOfThrowable(nested, ExceptionWithoutCause.class)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, null)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, null)); assertEquals(withCause, ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class)); assertEquals(withCause.getCause(), ExceptionUtils.throwableOfThrowable(withCause, NestableException.class)); assertEquals(withCause.getCause().getCause(), ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithoutCause.class)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, Exception.class)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, Throwable.class)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, Exception.class)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, Throwable.class)); } @Test public void testThrowableOf_ThrowableClassInt() { - assertEquals(null, ExceptionUtils.throwableOfThrowable(null, null, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(null, NestableException.class, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(null, null, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(null, NestableException.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withoutCause, null)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withoutCause, ExceptionWithCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withoutCause, NestableException.class, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(withoutCause, null)); + assertNull(ExceptionUtils.throwableOfThrowable(withoutCause, ExceptionWithCause.class, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(withoutCause, NestableException.class, 0)); assertEquals(withoutCause, ExceptionUtils.throwableOfThrowable(withoutCause, ExceptionWithoutCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(nested, null, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(nested, ExceptionWithCause.class, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(nested, null, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(nested, ExceptionWithCause.class, 0)); assertEquals(nested, ExceptionUtils.throwableOfThrowable(nested, NestableException.class, 0)); assertEquals(nested.getCause(), ExceptionUtils.throwableOfThrowable(nested, ExceptionWithoutCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, null)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, null)); assertEquals(withCause, ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class, 0)); assertEquals(withCause.getCause(), ExceptionUtils.throwableOfThrowable(withCause, NestableException.class, 0)); assertEquals(withCause.getCause().getCause(), ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithoutCause.class, 0)); assertEquals(withCause, ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class, -1)); assertEquals(withCause, ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class, 1)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class, 9)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class, 1)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, ExceptionWithCause.class, 9)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, Exception.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfThrowable(withCause, Throwable.class, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, Exception.class, 0)); + assertNull(ExceptionUtils.throwableOfThrowable(withCause, Throwable.class, 0)); } @Test public void testThrowableOfType_ThrowableClass() { - assertEquals(null, ExceptionUtils.throwableOfType(null, null)); - assertEquals(null, ExceptionUtils.throwableOfType(null, NestableException.class)); + assertNull(ExceptionUtils.throwableOfType(null, null)); + assertNull(ExceptionUtils.throwableOfType(null, NestableException.class)); - assertEquals(null, ExceptionUtils.throwableOfType(withoutCause, null)); - assertEquals(null, ExceptionUtils.throwableOfType(withoutCause, ExceptionWithCause.class)); - assertEquals(null, ExceptionUtils.throwableOfType(withoutCause, NestableException.class)); + assertNull(ExceptionUtils.throwableOfType(withoutCause, null)); + assertNull(ExceptionUtils.throwableOfType(withoutCause, ExceptionWithCause.class)); + assertNull(ExceptionUtils.throwableOfType(withoutCause, NestableException.class)); assertEquals(withoutCause, ExceptionUtils.throwableOfType(withoutCause, ExceptionWithoutCause.class)); - assertEquals(null, ExceptionUtils.throwableOfType(nested, null)); - assertEquals(null, ExceptionUtils.throwableOfType(nested, ExceptionWithCause.class)); + assertNull(ExceptionUtils.throwableOfType(nested, null)); + assertNull(ExceptionUtils.throwableOfType(nested, ExceptionWithCause.class)); assertEquals(nested, ExceptionUtils.throwableOfType(nested, NestableException.class)); assertEquals(nested.getCause(), ExceptionUtils.throwableOfType(nested, ExceptionWithoutCause.class)); - assertEquals(null, ExceptionUtils.throwableOfType(withCause, null)); + assertNull(ExceptionUtils.throwableOfType(withCause, null)); assertEquals(withCause, ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class)); assertEquals(withCause.getCause(), ExceptionUtils.throwableOfType(withCause, NestableException.class)); assertEquals(withCause.getCause().getCause(), ExceptionUtils.throwableOfType(withCause, ExceptionWithoutCause.class)); @@ -639,28 +640,28 @@ public class ExceptionUtilsTest { @Test public void testThrowableOfType_ThrowableClassInt() { - assertEquals(null, ExceptionUtils.throwableOfType(null, null, 0)); - assertEquals(null, ExceptionUtils.throwableOfType(null, NestableException.class, 0)); + assertNull(ExceptionUtils.throwableOfType(null, null, 0)); + assertNull(ExceptionUtils.throwableOfType(null, NestableException.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfType(withoutCause, null)); - assertEquals(null, ExceptionUtils.throwableOfType(withoutCause, ExceptionWithCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfType(withoutCause, NestableException.class, 0)); + assertNull(ExceptionUtils.throwableOfType(withoutCause, null)); + assertNull(ExceptionUtils.throwableOfType(withoutCause, ExceptionWithCause.class, 0)); + assertNull(ExceptionUtils.throwableOfType(withoutCause, NestableException.class, 0)); assertEquals(withoutCause, ExceptionUtils.throwableOfType(withoutCause, ExceptionWithoutCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfType(nested, null, 0)); - assertEquals(null, ExceptionUtils.throwableOfType(nested, ExceptionWithCause.class, 0)); + assertNull(ExceptionUtils.throwableOfType(nested, null, 0)); + assertNull(ExceptionUtils.throwableOfType(nested, ExceptionWithCause.class, 0)); assertEquals(nested, ExceptionUtils.throwableOfType(nested, NestableException.class, 0)); assertEquals(nested.getCause(), ExceptionUtils.throwableOfType(nested, ExceptionWithoutCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfType(withCause, null)); + assertNull(ExceptionUtils.throwableOfType(withCause, null)); assertEquals(withCause, ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class, 0)); assertEquals(withCause.getCause(), ExceptionUtils.throwableOfType(withCause, NestableException.class, 0)); assertEquals(withCause.getCause().getCause(), ExceptionUtils.throwableOfType(withCause, ExceptionWithoutCause.class, 0)); assertEquals(withCause, ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class, -1)); assertEquals(withCause, ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class, 0)); - assertEquals(null, ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class, 1)); - assertEquals(null, ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class, 9)); + assertNull(ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class, 1)); + assertNull(ExceptionUtils.throwableOfType(withCause, ExceptionWithCause.class, 9)); assertEquals(withCause, ExceptionUtils.throwableOfType(withCause, Exception.class, 0)); assertEquals(withCause, ExceptionUtils.throwableOfType(withCause, Throwable.class, 0)); |