From f34b691e07fdc6f9743e107a7f2d2c15d21a8793 Mon Sep 17 00:00:00 2001 From: Arseni Tsikhamirau Date: Wed, 17 Apr 2024 13:13:52 +0200 Subject: [PATCH] IJMP-1661-Fix-tests-after-switch-to-gradle-8-7 --- .../dataops/JobFetchProviderTestSpec.kt | 2 ++ .../explorer/ui/FileFetchNodeTestSpec.kt | 7 +------ .../explorer/ui/UssDirNodeTestSpec.kt | 21 +++++++++++++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/test/kotlin/eu/ibagroup/formainframe/dataops/JobFetchProviderTestSpec.kt b/src/test/kotlin/eu/ibagroup/formainframe/dataops/JobFetchProviderTestSpec.kt index 6d83e413d..768b32277 100644 --- a/src/test/kotlin/eu/ibagroup/formainframe/dataops/JobFetchProviderTestSpec.kt +++ b/src/test/kotlin/eu/ibagroup/formainframe/dataops/JobFetchProviderTestSpec.kt @@ -236,6 +236,7 @@ class JobFetchProviderTestSpec : ShouldSpec({ every { mockedResponse.isSuccessful } returns false every { mockedResponse.code() } returns 404 every { mockedResponse.body() } returns emptyList() + every { mockedResponse.message() } returns "Unknown error" val exception = shouldThrow { fetchResponseMethodRef.invoke(jobFetchProviderForTest, mockedQuery, progressMockk) @@ -252,6 +253,7 @@ class JobFetchProviderTestSpec : ShouldSpec({ jobFetchProviderForTest::class.java.declaredMethods.first { it.name == "cleanupUnusedFile" } cleanupUnusedFileMethodRef.trySetAccessible() dataOpsManagerService.testInstance = object : TestDataOpsManagerImpl(componentManager) { + @Suppress("UNCHECKED_CAST") override fun getAttributesService( attributesClass: Class, vFileClass: Class diff --git a/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/FileFetchNodeTestSpec.kt b/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/FileFetchNodeTestSpec.kt index 04933c0d6..02d15e360 100644 --- a/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/FileFetchNodeTestSpec.kt +++ b/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/FileFetchNodeTestSpec.kt @@ -14,9 +14,6 @@ import com.intellij.ide.projectView.PresentationData import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import com.intellij.testFramework.LightProjectDescriptor -import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl import com.intellij.ui.SimpleTextAttributes import eu.ibagroup.formainframe.config.connect.ConnectionConfig import eu.ibagroup.formainframe.config.ws.DSMask @@ -30,7 +27,6 @@ import eu.ibagroup.formainframe.explorer.FilesWorkingSetImpl import eu.ibagroup.formainframe.testutils.WithApplicationShouldSpec import eu.ibagroup.formainframe.testutils.testServiceImpl.TestDataOpsManagerImpl import eu.ibagroup.formainframe.utils.service -import io.kotest.core.spec.style.ShouldSpec import io.mockk.* import java.time.LocalDateTime @@ -59,12 +55,11 @@ class FileFetchNodeTestSpec: WithApplicationShouldSpec({ val mockedExplorerTreeStructure = mockk() every { mockedWorkingSet.explorer } returns mockedExplorer - every { mockedExplorer.componentManager } returns mockk() - every { mockedExplorer.componentManager.service() } returns dataOpsManagerService every { mockedExplorerTreeStructure.registerNode(any()) } just Runs every { mockedWorkingSet.connectionConfig } returns mockk() dataOpsManagerService.testInstance = object: TestDataOpsManagerImpl(componentManager) { + @Suppress("UNCHECKED_CAST") override fun , File : VirtualFile> getFileFetchProvider( requestClass: Class, queryClass: Class>, diff --git a/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/UssDirNodeTestSpec.kt b/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/UssDirNodeTestSpec.kt index 2c0b7c802..02e402582 100644 --- a/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/UssDirNodeTestSpec.kt +++ b/src/test/kotlin/eu/ibagroup/formainframe/explorer/ui/UssDirNodeTestSpec.kt @@ -11,16 +11,20 @@ package eu.ibagroup.formainframe.explorer.ui import com.intellij.ide.util.treeView.AbstractTreeNode +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile import eu.ibagroup.formainframe.config.ws.UssPath import eu.ibagroup.formainframe.dataops.DataOpsManager +import eu.ibagroup.formainframe.dataops.attributes.AttributesService +import eu.ibagroup.formainframe.dataops.attributes.FileAttributes import eu.ibagroup.formainframe.dataops.attributes.RemoteUssAttributes import eu.ibagroup.formainframe.dataops.attributes.RemoteUssAttributesService -import eu.ibagroup.formainframe.dataops.getAttributesService import eu.ibagroup.formainframe.dataops.sort.SortQueryKeys import eu.ibagroup.formainframe.explorer.FileExplorer import eu.ibagroup.formainframe.explorer.FilesWorkingSetImpl import eu.ibagroup.formainframe.testutils.WithApplicationShouldSpec +import eu.ibagroup.formainframe.testutils.testServiceImpl.TestDataOpsManagerImpl import eu.ibagroup.formainframe.utils.service import eu.ibagroup.formainframe.vfs.MFVirtualFile import io.kotest.assertions.assertSoftly @@ -45,10 +49,19 @@ class UssDirNodeTestSpec : WithApplicationShouldSpec({ val mockedUssAttributesService = mockk() + val dataOpsManagerService = ApplicationManager.getApplication().service() as TestDataOpsManagerImpl + val componentManager = dataOpsManagerService.componentManager + dataOpsManagerService.testInstance = object : TestDataOpsManagerImpl(componentManager) { + @Suppress("UNCHECKED_CAST") + override fun getAttributesService( + attributesClass: Class, + vFileClass: Class + ): AttributesService { + return mockedUssAttributesService as AttributesService + } + } + every { mockedWorkingSet.explorer } returns mockedExplorer - every { mockedExplorer.componentManager } returns mockk() - every { mockedExplorer.componentManager.service() } returns mockk() - every { mockedExplorer.componentManager.service().getAttributesService() } returns mockedUssAttributesService every { mockedExplorerTreeStructure.registerNode(any()) } just Runs context("sort children nodes") {