Convert util class convention tests to @Nested test
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/89f3d989 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/89f3d989 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/89f3d989 Branch: refs/heads/master Commit: 89f3d989e0bd78f4db8db1d3fc39a50ae5c66c37 Parents: 0b14928 Author: Benedikt Ritter <brit...@apache.org> Authored: Thu Sep 6 20:21:18 2018 +0200 Committer: Benedikt Ritter <brit...@apache.org> Committed: Thu Sep 6 20:21:18 2018 +0200 ---------------------------------------------------------------------- .../org/apache/commons/lang3/ValidateTest.java | 38 +++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/89f3d989/src/test/java/org/apache/commons/lang3/ValidateTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/ValidateTest.java b/src/test/java/org/apache/commons/lang3/ValidateTest.java index 4103386..cf1a907 100644 --- a/src/test/java/org/apache/commons/lang3/ValidateTest.java +++ b/src/test/java/org/apache/commons/lang3/ValidateTest.java @@ -23,8 +23,6 @@ import org.junit.jupiter.api.Test; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; -import java.util.AbstractList; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -37,23 +35,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; /** * Unit tests {@link org.apache.commons.lang3.Validate}. */ class ValidateTest { - @Test - void testConstructor() { - assertNotNull(new Validate()); - final Constructor<?>[] cons = Validate.class.getDeclaredConstructors(); - assertEquals(1, cons.length); - assertTrue(Modifier.isPublic(cons[0].getModifiers())); - assertTrue(Modifier.isPublic(Validate.class.getModifiers())); - assertFalse(Modifier.isFinal(Validate.class.getModifiers())); - } - @Nested class IsTrue { @@ -1882,4 +1869,29 @@ class ValidateTest { } } } + + @Nested + class UtilClassConventions { + + @Test + void instancesCanBeConstrcuted() { + assertNotNull(new Validate()); + } + + @Test + void hasOnlyOnePublicConstructor() { + final Constructor<?>[] cons = Validate.class.getDeclaredConstructors(); + assertEquals(1, cons.length); + } + + @Test + void isPublicClass() { + assertTrue(Modifier.isPublic(Validate.class.getModifiers())); + } + + @Test + void isNonFinalClass() { + assertFalse(Modifier.isFinal(Validate.class.getModifiers())); + } + } }