Skip to content

Commit

Permalink
Remove dependency to mockito-all (#1811)
Browse files Browse the repository at this point in the history
- just remove dependency
- refactored a test to avoid using Mockito since it's required Java 11
  • Loading branch information
nulls authored Nov 21, 2023
1 parent ad37745 commit 15d2ad4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 17 deletions.
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
1 change: 0 additions & 1 deletion diktat-rules/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencies {
testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.platform.suite)
testImplementation(libs.assertj.core)
testImplementation(libs.mockito)
// is used for simplifying boolean expressions
implementation(libs.jbool.expressions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package com.saveourtool.diktat.ruleset.utils
import com.saveourtool.diktat.ruleset.utils.search.VariablesSearch
import com.saveourtool.diktat.ruleset.utils.search.default
import com.saveourtool.diktat.util.applyToCode
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
import org.jetbrains.kotlin.psi.KtProperty

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
import org.junit.jupiter.api.Test
import org.mockito.Mockito

@Suppress("UnsafeCallOnNullableType")
class VariablesSearchTest {
Expand All @@ -27,16 +28,11 @@ class VariablesSearchTest {
}
""".trimIndent(), 0) { node, _ ->
if (node.elementType != KtFileElementType.INSTANCE) {
val thrown = Assertions.assertThrows(IllegalArgumentException::class.java) {
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")
nodeField.isAccessible = true
filter.isAccessible = true

nodeField.set(variablesSearchAbstract, node)
filter.set(variablesSearchAbstract, ::default)
val variablesSearchAbstract: VariablesSearch = object : VariablesSearch(node, ::default) {
override fun KtElement.getAllSearchResults(property: KtProperty): List<KtNameReferenceExpression> = TODO("Not required for test")
}

val thrown = Assertions.assertThrows(IllegalArgumentException::class.java) {
variablesSearchAbstract.collectVariables()
}
assertTrue(thrown.message!!.contains("To collect all variables in a file you need to provide file root node"))
Expand Down
3 changes: 0 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ 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"

# executable jar
kotlinx-cli = "0.3.6"
Expand Down Expand Up @@ -123,7 +121,6 @@ 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" }

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

0 comments on commit 15d2ad4

Please sign in to comment.