From 84cde572a3e325cddfb3e3f42a4d0a82f1193130 Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Thu, 21 Sep 2023 15:36:12 +0200 Subject: [PATCH] Adds Mockito dependency --- equalsverifier-core/pom.xml | 10 ++++++++++ .../internal/reflection/Instantiator.java | 5 +++++ equalsverifier-release-main/pom.xml | 5 +++++ .../verify_release/jar/helper/JarAsserter.java | 6 ++++++ .../equalsverifier/verify_release/pom/MainPomTest.java | 7 ++++--- pom.xml | 6 ++++++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/equalsverifier-core/pom.xml b/equalsverifier-core/pom.xml index f99a59091..3a5404694 100644 --- a/equalsverifier-core/pom.xml +++ b/equalsverifier-core/pom.xml @@ -35,11 +35,16 @@ true + org.mockito:mockito-core net.bytebuddy:byte-buddy org.objenesis:objenesis + + org.mockito + nl.jqno.equalsverifier.internal.lib.mockito + net.bytebuddy nl.jqno.equalsverifier.internal.lib.bytebuddy @@ -76,6 +81,11 @@ + + org.mockito + mockito-core + ${version.mockito} + org.objenesis objenesis diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/Instantiator.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/Instantiator.java index f9d2472ee..31c0458ea 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/Instantiator.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/Instantiator.java @@ -3,6 +3,7 @@ import static nl.jqno.equalsverifier.internal.reflection.Util.classForName; import static nl.jqno.equalsverifier.internal.reflection.Util.classes; import static nl.jqno.equalsverifier.internal.reflection.Util.objects; +import static org.mockito.Mockito.mock; import java.lang.invoke.MethodHandles; import java.lang.reflect.Modifier; @@ -69,6 +70,10 @@ public T instantiate() { return ObjenesisWrapper.getObjenesis().newInstance(type); } + public T instantiateMock() { + return mock(type); + } + /** * Instantiates an anonymous subclass of T. The subclass is generated dynamically. * diff --git a/equalsverifier-release-main/pom.xml b/equalsverifier-release-main/pom.xml index 7f9813047..4bc97b414 100644 --- a/equalsverifier-release-main/pom.xml +++ b/equalsverifier-release-main/pom.xml @@ -181,6 +181,11 @@ provided true + + org.mockito + mockito-core + ${version.mockito} + org.objenesis objenesis diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java index aef3830e7..0b6f30597 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java @@ -43,6 +43,7 @@ public void assertPresenceOfMultiReleaseClasses() { public void assertPresenceOfEmbeddedDepedencies() { assertPresenceOf( + EV + "/internal/lib/mockito/Mockito.class", EV + "/internal/lib/bytebuddy/ByteBuddy.class", EV + "/internal/lib/objenesis/Objenesis.class" ); @@ -132,6 +133,11 @@ public void assertVersionsOfClassFiles() { public void assertVersionsOfEmbeddedClassFiles() { assertAll( + () -> + assertVersionOfClassFile( + JAVA_11_CLASS_FILE_VERSION, + EV + "/internal/lib/mockito/Mockito.class" + ), () -> assertVersionOfClassFile( JAVA_5_CLASS_FILE_VERSION, diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java index 99c8e8570..8bddba6e5 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java @@ -31,12 +31,13 @@ public void artifactId() { @Test public void dependencies() { assertAll( - () -> pom.assertNumberOfDependencies(5), + () -> pom.assertNumberOfDependencies(6), () -> pom.assertDependencyIsOptional(1), () -> pom.assertDependencyIsOptional(2), () -> pom.assertDependencyIsOptional(3), - () -> pom.assertDependency(4, "org.objenesis", "objenesis"), - () -> pom.assertDependency(5, "net.bytebuddy", "byte-buddy") + () -> pom.assertDependency(4, "org.mockito", "mockito-core"), + () -> pom.assertDependency(5, "org.objenesis", "objenesis"), + () -> pom.assertDependency(6, "net.bytebuddy", "byte-buddy") ); } } diff --git a/pom.xml b/pom.xml index c15328a43..6910bcb9d 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,7 @@ Max Low + 5.5.0 1.14.7 3.3 @@ -204,6 +205,11 @@ + + org.mockito + mockito-core + ${version.mockito} + org.objenesis objenesis