Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency to mockito-all #1811

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion diktat-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies {
testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.platform.suite)
testImplementation(libs.assertj.core)
testImplementation(libs.mockito)
}

val addLicenseTask: TaskProvider<Task> = tasks.register("addLicense") {
Expand Down
1 change: 0 additions & 1 deletion diktat-ktlint-engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies {
testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.platform.suite)
testImplementation(libs.assertj.core)
testImplementation(libs.mockito)
}

val ktlintVersion: String = the<LibrariesForLibs>()
Expand Down
2 changes: 1 addition & 1 deletion diktat-rules/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.platform.suite)
testImplementation(libs.assertj.core)
testImplementation(libs.mockito)
testImplementation(libs.mockito.core)
// is used for simplifying boolean expressions
implementation(libs.jbool.expressions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.saveourtool.diktat.ruleset.utils.search.default
import com.saveourtool.diktat.util.applyToCode

import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.psi.stubs.elements.KtFileElementType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertTrue
Expand All @@ -27,7 +26,7 @@
}
""".trimIndent(), 0) { node, _ ->
if (node.elementType != KtFileElementType.INSTANCE) {
val thrown = Assertions.assertThrows(IllegalArgumentException::class.java) {

Check failure on line 29 in diktat-rules/src/test/kotlin/com/saveourtool/diktat/ruleset/utils/VariablesSearchTest.kt

View workflow job for this annotation

GitHub Actions / JUnit Tests (Linux, dorny/test-reporter@v1)

com.saveourtool.diktat.ruleset.utils.VariablesSearchTest ► testing requirement for collecting variables()

Failed test found in: diktat-rules/build/test-results/test/TEST-com.saveourtool.diktat.ruleset.utils.VariablesSearchTest.xml Error: org.opentest4j.AssertionFailedError: Unexpected exception type thrown, expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedClassVersionError>
Raw output
org.opentest4j.AssertionFailedError: Unexpected exception type thrown, expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedClassVersionError>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:67)
	at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35)
	at org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3115)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest$testing requirement for collecting variables$1.invoke(VariablesSearchTest.kt:29)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest$testing requirement for collecting variables$1.invoke(VariablesSearchTest.kt:17)
	at com.saveourtool.diktat.util.TestUtilsKt$applyToCode$1$1.invoke(TestUtils.kt:120)
	at com.saveourtool.diktat.ktlint.KtLintRuleWrapper.beforeVisitChildNodes(KtLintRuleWrapper.kt:30)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$1.invoke(RuleExecutionContext.kt:125)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$1.invoke(RuleExecutionContext.kt:124)
	at com.pinterest.ktlint.rule.engine.internal.SuppressHandler.handle(SuppressHandler.kt:28)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:124)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:93)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.access$executeRuleOnNodeRecursively(RuleExecutionContext.kt:30)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$2$1.invoke(RuleExecutionContext.kt:132)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$2$1.invoke(RuleExecutionContext.kt:131)
	at com.pinterest.ktlint.rule.engine.internal.SuppressHandler.handle(SuppressHandler.kt:28)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:131)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:93)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRule(RuleExecutionContext.kt:62)
	at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine$lint$3.invoke(KtLintRuleEngine.kt:100)
	at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine$lint$3.invoke(KtLintRuleEngine.kt:99)
	at com.pinterest.ktlint.rule.engine.internal.VisitorProvider$visitor$3.invoke(VisitorProvider.kt:46)
	at com.pinterest.ktlint.rule.engine.internal.VisitorProvider$visitor$3.invoke(VisitorProvider.kt:44)
	at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine.lint(KtLintRuleEngine.kt:99)
	at com.saveourtool.diktat.ktlint.DiktatProcessorFactoryImpl$invoke$1.check(DiktatProcessorFactoryImpl.kt:39)
	at com.saveourtool.diktat.ktlint.KtLintUtilsKt.lint(KtLintUtils.kt:186)
	at com.saveourtool.diktat.ktlint.KtLintUtilsKt.lint$default(KtLintUtils.kt:181)
	at com.saveourtool.diktat.util.TestUtilsKt.applyToCode(TestUtils.kt:114)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest.testing requirement for collecting variables(VariablesSearchTest.kt:17)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
Caused by: java.lang.UnsupportedClassVersionError: org/mockito/Mockito has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest$testing requirement for collecting variables$1.invoke$lambda$0(VariablesSearchTest.kt:30)
	at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:53)
	... 31 more

Check failure on line 29 in diktat-rules/src/test/kotlin/com/saveourtool/diktat/ruleset/utils/VariablesSearchTest.kt

View workflow job for this annotation

GitHub Actions / JUnit Tests (macOS, dorny/test-reporter@v1)

com.saveourtool.diktat.ruleset.utils.VariablesSearchTest ► testing requirement for collecting variables()

Failed test found in: diktat-rules/build/test-results/test/TEST-com.saveourtool.diktat.ruleset.utils.VariablesSearchTest.xml Error: org.opentest4j.AssertionFailedError: Unexpected exception type thrown, expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedClassVersionError>
Raw output
org.opentest4j.AssertionFailedError: Unexpected exception type thrown, expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedClassVersionError>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:67)
	at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35)
	at org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3115)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest$testing requirement for collecting variables$1.invoke(VariablesSearchTest.kt:29)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest$testing requirement for collecting variables$1.invoke(VariablesSearchTest.kt:17)
	at com.saveourtool.diktat.util.TestUtilsKt$applyToCode$1$1.invoke(TestUtils.kt:120)
	at com.saveourtool.diktat.ktlint.KtLintRuleWrapper.beforeVisitChildNodes(KtLintRuleWrapper.kt:30)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$1.invoke(RuleExecutionContext.kt:125)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$1.invoke(RuleExecutionContext.kt:124)
	at com.pinterest.ktlint.rule.engine.internal.SuppressHandler.handle(SuppressHandler.kt:28)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:124)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:93)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.access$executeRuleOnNodeRecursively(RuleExecutionContext.kt:30)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$2$1.invoke(RuleExecutionContext.kt:132)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$executeRuleOnNodeRecursively$2$1.invoke(RuleExecutionContext.kt:131)
	at com.pinterest.ktlint.rule.engine.internal.SuppressHandler.handle(SuppressHandler.kt:28)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:131)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:93)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext.executeRule(RuleExecutionContext.kt:62)
	at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine$lint$3.invoke(KtLintRuleEngine.kt:100)
	at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine$lint$3.invoke(KtLintRuleEngine.kt:99)
	at com.pinterest.ktlint.rule.engine.internal.VisitorProvider$visitor$3.invoke(VisitorProvider.kt:46)
	at com.pinterest.ktlint.rule.engine.internal.VisitorProvider$visitor$3.invoke(VisitorProvider.kt:44)
	at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine.lint(KtLintRuleEngine.kt:99)
	at com.saveourtool.diktat.ktlint.DiktatProcessorFactoryImpl$invoke$1.check(DiktatProcessorFactoryImpl.kt:39)
	at com.saveourtool.diktat.ktlint.KtLintUtilsKt.lint(KtLintUtils.kt:186)
	at com.saveourtool.diktat.ktlint.KtLintUtilsKt.lint$default(KtLintUtils.kt:181)
	at com.saveourtool.diktat.util.TestUtilsKt.applyToCode(TestUtils.kt:114)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest.testing requirement for collecting variables(VariablesSearchTest.kt:17)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
Caused by: java.lang.UnsupportedClassVersionError: org/mockito/Mockito has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at com.saveourtool.diktat.ruleset.utils.VariablesSearchTest$testing requirement for collecting variables$1.invoke$lambda$0(VariablesSearchTest.kt:30)
	at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:53)
	... 31 more
val variablesSearchAbstract: VariablesSearch = Mockito.mock(VariablesSearch::class.java, Mockito.CALLS_REAL_METHODS)
val nodeField = VariablesSearch::class.java.getDeclaredField("node")
val filter = VariablesSearch::class.java.getDeclaredField("filterForVariables")
Expand Down
5 changes: 2 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ log4j2 = "2.21.1"
kaml = "0.55.0"
sarif4k = "0.5.0"
jupiter-itf-extension = "0.12.0"
# FIXME: need to migrate to mockito
mockito-all = "1.10.19"
mockito = "5.7.0"

# executable jar
kotlinx-cli = "0.3.6"
Expand Down Expand Up @@ -123,7 +122,7 @@ junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", vers
junit-jupiter-extension-itf = { module = "com.soebes.itf.jupiter.extension:itf-jupiter-extension", version.ref = "jupiter-itf-extension" }
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }
junit-platform-suite = { module = "org.junit.platform:junit-platform-suite-engine", version.ref = "junit-platfrom" }
mockito = { module = "org.mockito:mockito-all", version.ref = "mockito-all" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }

# maven
maven-core = { module = "org.apache.maven:maven-core", version.ref = "maven-api" }
Expand Down
Loading