From 2ff0f0086070d5dd80b2428cb7123e01a53cc73c Mon Sep 17 00:00:00 2001 From: akefirad Date: Sat, 25 Jan 2025 15:23:16 +0100 Subject: [PATCH] GH-56 remove easymock and use mickito --- build.gradle.kts | 8 +------- gradle/libs.versions.toml | 7 +------ .../com/akefirad/groom/spock/SpockSpecUtils.kt | 1 - .../groovy/GroovyFoldingBuilderTest.groovy | 17 +++++++---------- .../com/akefirad/oss/easymock/EasyMock.groovy | 7 ------- 5 files changed, 9 insertions(+), 31 deletions(-) delete mode 100644 src/test/groovy/com/akefirad/oss/easymock/EasyMock.groovy diff --git a/build.gradle.kts b/build.gradle.kts index 29a1743..be4c900 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,12 +17,10 @@ plugins { group = providers.gradleProperty("pluginGroup").get() version = providers.gradleProperty("pluginVersion").get() -// Set the JVM language level used to build the project. kotlin { jvmToolchain(17) } -// Configure project's dependencies repositories { mavenCentral() @@ -32,14 +30,10 @@ repositories { } } -// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { testImplementation(libs.junit) - testImplementation(libs.mockk) testImplementation(libs.groovy) - - // TODO: use Mockito! - testImplementation("org.easymock:easymock:5.5.0") + testImplementation(libs.mockito) // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html intellijPlatform { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b5532ef..d65fd2f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,14 +11,9 @@ qodana = "2024.3.4" [libraries] junit = { group = "junit", name = "junit", version.ref = "junit" } -mockk = { group = "io.mockk", name = "mockk", version = "1.13.16" } -mockito-core = { group = "org.mockito", name = "mockito-core", version = "5.15.2" } -mockito-inline = { group = "org.mockito", name = "mockito-inline", version = "5.2.0" } +mockito = { group = "org.mockito", name = "mockito-core", version = "4.11.0" } groovy = { group = "org.codehaus.groovy", name = "groovy-test", version = "3.0.23" } # update if you can! -[bundles] -mockito = ["mockito-core", "mockito-inline"] - [plugins] changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" } diff --git a/src/main/kotlin/com/akefirad/groom/spock/SpockSpecUtils.kt b/src/main/kotlin/com/akefirad/groom/spock/SpockSpecUtils.kt index eb46e2e..02c4ff2 100644 --- a/src/main/kotlin/com/akefirad/groom/spock/SpockSpecUtils.kt +++ b/src/main/kotlin/com/akefirad/groom/spock/SpockSpecUtils.kt @@ -11,7 +11,6 @@ import kotlin.contracts.contract object SpockSpecUtils { private const val SPOCK_SPEC_CLASS: String = "spock.lang.Specification" - @JvmStatic fun PsiFile.hasAnySpecification(): Boolean { return this is GroovyFile && children .filterIsInstance() diff --git a/src/test/groovy/com/akefirad/groom/groovy/GroovyFoldingBuilderTest.groovy b/src/test/groovy/com/akefirad/groom/groovy/GroovyFoldingBuilderTest.groovy index da75bf1..845e6d4 100644 --- a/src/test/groovy/com/akefirad/groom/groovy/GroovyFoldingBuilderTest.groovy +++ b/src/test/groovy/com/akefirad/groom/groovy/GroovyFoldingBuilderTest.groovy @@ -8,10 +8,9 @@ import com.intellij.psi.PsiJavaFile import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixture4TestCase import org.junit.Test -import static com.akefirad.oss.easymock.EasyMock.mock -import static org.easymock.EasyMock.expect -import static org.easymock.EasyMock.replay -import static org.easymock.EasyMock.verify +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when class GroovyFoldingBuilderTest extends LightPlatformCodeInsightFixture4TestCase { @@ -30,8 +29,7 @@ class GroovyFoldingBuilderTest extends LightPlatformCodeInsightFixture4TestCase // given: def subject = new GroovyFoldingBuilder() def root = mock(PsiJavaFile) - expect(root.node).andReturn(null) - replay(root) + when(root.node).thenReturn(null) // when: def result = subject.buildFoldRegions(root, mock(Document), false) @@ -40,7 +38,7 @@ class GroovyFoldingBuilderTest extends LightPlatformCodeInsightFixture4TestCase assert result.length == 0 // and: - verify(root) + verify(root).node } @Test @@ -48,13 +46,12 @@ class GroovyFoldingBuilderTest extends LightPlatformCodeInsightFixture4TestCase // given: def subject = new GroovyFoldingBuilder() def node = mock(ASTNode) - expect(node.getPsi()).andReturn(mock(PsiElement)) - replay(node) + when(node.psi).thenReturn(mock(PsiElement)) // expect: assertThrows(IllegalStateException) { subject.getLanguagePlaceholderText(node, TextRange.EMPTY_RANGE) } // and: - verify(node) + verify(node).psi } } diff --git a/src/test/groovy/com/akefirad/oss/easymock/EasyMock.groovy b/src/test/groovy/com/akefirad/oss/easymock/EasyMock.groovy deleted file mode 100644 index e8669c2..0000000 --- a/src/test/groovy/com/akefirad/oss/easymock/EasyMock.groovy +++ /dev/null @@ -1,7 +0,0 @@ -package com.akefirad.oss.easymock - -class EasyMock { - public static T mock(Class classToMock) { - return org.easymock.EasyMock.mock(classToMock) - } -}