diff --git a/src/main/kotlin/org/zowe/explorer/explorer/actions/AddMemberAction.kt b/src/main/kotlin/org/zowe/explorer/explorer/actions/AddMemberAction.kt index fcfb035cc..7bbcda246 100644 --- a/src/main/kotlin/org/zowe/explorer/explorer/actions/AddMemberAction.kt +++ b/src/main/kotlin/org/zowe/explorer/explorer/actions/AddMemberAction.kt @@ -12,6 +12,7 @@ package org.zowe.explorer.explorer.actions import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.components.service import com.intellij.openapi.progress.runBackgroundableTask import org.zowe.explorer.config.connect.ConnectionConfig import org.zowe.explorer.dataops.DataOpsManager @@ -32,7 +33,6 @@ import org.zowe.explorer.explorer.ui.FileExplorerView import org.zowe.explorer.explorer.ui.FileLikeDatasetNode import org.zowe.explorer.explorer.ui.LibraryNode import org.zowe.explorer.explorer.ui.getExplorerView -import org.zowe.explorer.utils.service import org.zowe.explorer.vfs.MFVirtualFile /** Class that represents "Add member" action */ @@ -76,9 +76,9 @@ class AddMemberAction : AnAction() { ) }.onSuccess { currentNode.cleanCache(cleanBatchedQuery = true) - }.onFailure { - var throwable = it - if (it is CallException && it.code == 500 && it.message?.contains("Directory full") == true) { + }.onFailure { failObj: Throwable -> + var throwable = failObj + if (failObj is CallException && failObj.code == 500 && failObj.message?.contains("Directory full") == true) { runCatching { dataOpsManager.performOperation( operation = DeleteMemberOperation( @@ -89,8 +89,8 @@ class AddMemberAction : AnAction() { connectionConfig = connectionConfig ) ) - }.onFailure { th -> - throwable = Throwable("Directory is FULL. Invalid member created.\n" + th.message) + }.onFailure { innerFailObj: Throwable -> + throwable = Throwable("Directory is FULL. Invalid member created.\n" + innerFailObj.message) currentNode.cleanCache(cleanBatchedQuery = true) } } diff --git a/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateDatasetActionTestSpec.kt b/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateDatasetActionTestSpec.kt index 52f82e68a..4068040e7 100644 --- a/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateDatasetActionTestSpec.kt +++ b/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateDatasetActionTestSpec.kt @@ -18,7 +18,16 @@ import com.intellij.openapi.actionSystem.Presentation import com.intellij.openapi.components.ComponentManager import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.showOkNoDialog +import io.kotest.assertions.assertSoftly +import io.kotest.matchers.shouldBe +import io.mockk.Runs +import io.mockk.clearAllMocks +import io.mockk.every +import io.mockk.just +import io.mockk.mockk +import io.mockk.mockkObject +import io.mockk.mockkStatic +import io.mockk.unmockkAll import org.zowe.explorer.common.ui.StatefulDialog import org.zowe.explorer.common.ui.cleanInvalidateOnExpand import org.zowe.explorer.common.ui.showUntilDone @@ -30,18 +39,17 @@ import org.zowe.explorer.dataops.Operation import org.zowe.explorer.dataops.operations.DatasetAllocationParams import org.zowe.explorer.explorer.Explorer import org.zowe.explorer.explorer.FilesWorkingSet -import org.zowe.explorer.explorer.ui.* +import org.zowe.explorer.explorer.ui.DSMaskNode +import org.zowe.explorer.explorer.ui.ExplorerTreeNode +import org.zowe.explorer.explorer.ui.ExplorerTreeView +import org.zowe.explorer.explorer.ui.FileExplorerView +import org.zowe.explorer.explorer.ui.FileLikeDatasetNode +import org.zowe.explorer.explorer.ui.FilesWorkingSetNode +import org.zowe.explorer.explorer.ui.JobNode +import org.zowe.explorer.explorer.ui.LibraryNode +import org.zowe.explorer.explorer.ui.NodeData +import org.zowe.explorer.explorer.ui.getExplorerView import org.zowe.explorer.testutils.WithApplicationShouldSpec -import io.kotest.assertions.assertSoftly -import io.kotest.matchers.shouldBe -import io.mockk.Runs -import io.mockk.clearAllMocks -import io.mockk.every -import io.mockk.just -import io.mockk.mockk -import io.mockk.mockkObject -import io.mockk.mockkStatic -import io.mockk.unmockkAll import org.zowe.kotlinsdk.DatasetOrganization import org.zowe.kotlinsdk.DsnameType import java.util.* @@ -387,93 +395,12 @@ class AllocateDatasetActionTestSpec : WithApplicationShouldSpec({ isCleanInvalidateOnExpandTriggered shouldBe true isShowUntilDoneSucceeded shouldBe true isOperationPerformed shouldBe true - isCleanCacheTriggered shouldBe true isUpdateOnConfigCrudableCalled shouldBe false isThrowableReported shouldBe false initState.errorMessage shouldBe "" } } - should("perform allocate dataset action without refreshing dataset mask as the selected node is a working set") { - val workingSetMock = mockk() - val nodeMock = mockk() - val nodeDataMock = NodeData(nodeMock, null, null) - val selectedNodesData = listOf(nodeDataMock) - lateinit var initState: DatasetAllocationParams - var isOperationPerformed = false - var isUpdateOnConfigCrudableCalled = false - var isShowUntilDoneSucceeded = false - - val showUntilDoneMockk: ( - DatasetAllocationParams, - (DatasetAllocationParams) -> StatefulDialog, - (DatasetAllocationParams) -> Boolean - ) -> DatasetAllocationParams? = ::showUntilDone - mockkStatic(showUntilDoneMockk as KFunction<*>) - every { - hint(DatasetAllocationParams::class) - showUntilDoneMockk( - any(), - any<(DatasetAllocationParams) -> StatefulDialog>(), - any<(DatasetAllocationParams) -> Boolean>() - ) - } answers { - initState = firstArg() - val thirdBlockResult = thirdArg<(DatasetAllocationParams) -> Boolean>() - isShowUntilDoneSucceeded = thirdBlockResult(initState) - initState - } - - mockkObject(configCrudable) - every { - configCrudable.getByUniqueKey(any(), any()) - } returns Optional.of(filesWorkingSetConfigMock) - - every { nodeMock.parent } returns null - every { nodeMock.hint(FilesWorkingSet::class).unit } returns workingSetMock - every { viewMock.mySelectedNodesData } returns selectedNodesData - every { workingSetMock.name } returns "test" - every { workingSetMock.uuid } returns "test" - every { workingSetMock.hint(ConnectionConfig::class).connectionConfig } returns mockk() - every { - dataOpsManagerMock.hint(Boolean::class).performOperation(any>(), any()) - } answers { - isOperationPerformed = true - true - } - every { workingSetMock.explorer } returns explorerMock - every { configCrudable.update(any(), any()) } answers { - isUpdateOnConfigCrudableCalled = true - Optional.of(mockk()) - } - - val showOkNoDialogMock: ( - String, - String, - Project?, - String, - String, - Icon? - ) -> Boolean = ::showOkNoDialog - mockkStatic(showOkNoDialogMock as KFunction<*>) - every { - hint(Boolean::class) - showOkNoDialogMock(any(), any(), any(), any(), any(), any()) - } answers { - true - } - - allocateDsActionInst.actionPerformed(anActionEventMock) - - assertSoftly { - isCleanInvalidateOnExpandTriggered shouldBe false - isShowUntilDoneSucceeded shouldBe true - isOperationPerformed shouldBe true - isUpdateOnConfigCrudableCalled shouldBe true - isThrowableReported shouldBe false - initState.errorMessage shouldBe "" - } - } - should("perform allocate dataset action creating new dataset mask without refreshing the existing on as the connection config is not found") { + should("perform allocate dataset action creating new dataset mask without adding as the connection config is not found") { val workingSetMock = mockk() val nodeMock = mockk() val nodeDataMock = NodeData(nodeMock, null, null) diff --git a/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateLikeActionTestSpec.kt b/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateLikeActionTestSpec.kt index a1b624164..21b9d5531 100644 --- a/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateLikeActionTestSpec.kt +++ b/src/test/kotlin/org/zowe/explorer/explorer/actions/AllocateLikeActionTestSpec.kt @@ -19,6 +19,16 @@ import com.intellij.openapi.components.ComponentManager import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.project.Project import com.intellij.openapi.ui.Messages.showWarningDialog +import io.kotest.assertions.assertSoftly +import io.kotest.matchers.shouldBe +import io.mockk.Runs +import io.mockk.clearAllMocks +import io.mockk.every +import io.mockk.just +import io.mockk.mockk +import io.mockk.mockkObject +import io.mockk.mockkStatic +import io.mockk.unmockkAll import org.zowe.explorer.common.ui.StatefulDialog import org.zowe.explorer.common.ui.cleanInvalidateOnExpand import org.zowe.explorer.common.ui.showUntilDone @@ -41,18 +51,6 @@ import org.zowe.explorer.explorer.ui.LibraryNode import org.zowe.explorer.explorer.ui.NodeData import org.zowe.explorer.explorer.ui.getExplorerView import org.zowe.explorer.testutils.WithApplicationShouldSpec -import org.zowe.explorer.testutils.testServiceImpl.TestAnalyticsServiceImpl -import org.zowe.explorer.utils.service -import io.kotest.assertions.assertSoftly -import io.kotest.matchers.shouldBe -import io.mockk.Runs -import io.mockk.clearAllMocks -import io.mockk.every -import io.mockk.just -import io.mockk.mockk -import io.mockk.mockkObject -import io.mockk.mockkStatic -import io.mockk.unmockkAll import org.zowe.kotlinsdk.Dataset import org.zowe.kotlinsdk.DatasetOrganization import org.zowe.kotlinsdk.RecordFormat @@ -184,7 +182,6 @@ class AllocateLikeActionTestSpec : WithApplicationShouldSpec({ assertSoftly { isCleanInvalidateOnExpandTriggered shouldBe true isShowUntilDoneSucceeded shouldBe true - isAnalitycsTracked shouldBe true isOperationPerformed shouldBe true isThrowableReported shouldBe false initState.errorMessage shouldBe "" @@ -256,7 +253,6 @@ class AllocateLikeActionTestSpec : WithApplicationShouldSpec({ assertSoftly { isCleanInvalidateOnExpandTriggered shouldBe true isShowUntilDoneSucceeded shouldBe true - isAnalitycsTracked shouldBe true isOperationPerformed shouldBe true isThrowableReported shouldBe false initState.errorMessage shouldBe "" @@ -328,7 +324,6 @@ class AllocateLikeActionTestSpec : WithApplicationShouldSpec({ assertSoftly { isCleanInvalidateOnExpandTriggered shouldBe true isShowUntilDoneSucceeded shouldBe true - isAnalitycsTracked shouldBe true isOperationPerformed shouldBe true isThrowableReported shouldBe false initState.errorMessage shouldBe "" @@ -405,7 +400,6 @@ class AllocateLikeActionTestSpec : WithApplicationShouldSpec({ assertSoftly { isCleanInvalidateOnExpandTriggered shouldBe true isShowUntilDoneSucceeded shouldBe true - isAnalitycsTracked shouldBe true isOperationPerformed shouldBe true isBlocksChangedToTracks shouldBe true isThrowableReported shouldBe false @@ -428,7 +422,6 @@ class AllocateLikeActionTestSpec : WithApplicationShouldSpec({ assertSoftly { isCleanInvalidateOnExpandTriggered shouldBe false - isAnalitycsTracked shouldBe false isOperationPerformed shouldBe false isThrowableReported shouldBe false }