Skip to content

Commit

Permalink
Adds Mockito dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Sep 21, 2023
1 parent 2652b2b commit 84cde57
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
10 changes: 10 additions & 0 deletions equalsverifier-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>org.mockito:mockito-core</include>
<include>net.bytebuddy:byte-buddy</include>
<include>org.objenesis:objenesis</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.mockito</pattern>
<shadedPattern>nl.jqno.equalsverifier.internal.lib.mockito</shadedPattern>
</relocation>
<relocation>
<pattern>net.bytebuddy</pattern>
<shadedPattern>nl.jqno.equalsverifier.internal.lib.bytebuddy</shadedPattern>
Expand Down Expand Up @@ -76,6 +81,11 @@

<dependencies>
<!-- Main dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${version.mockito}</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
5 changes: 5 additions & 0 deletions equalsverifier-release-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${version.mockito}</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
}
}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<analysis.spotbugs.effort>Max</analysis.spotbugs.effort>
<analysis.spotbugs.threshold>Low</analysis.spotbugs.threshold>

<version.mockito>5.5.0</version.mockito>
<version.bytebuddy>1.14.7</version.bytebuddy>
<version.objenesis>3.3</version.objenesis>

Expand Down Expand Up @@ -204,6 +205,11 @@

<dependencies>
<!-- Main dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${version.mockito}</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
Expand Down

0 comments on commit 84cde57

Please sign in to comment.