Skip to content

Commit

Permalink
Fixes after merge with for mainframe
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Mar 19, 2024
1 parent 29c1166 commit 0aaabcf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down Expand Up @@ -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(
Expand All @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.*
Expand Down Expand Up @@ -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<FilesWorkingSet>()
val nodeMock = mockk<FilesWorkingSetNode>()
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>,
(DatasetAllocationParams) -> Boolean
) -> DatasetAllocationParams? = ::showUntilDone
mockkStatic(showUntilDoneMockk as KFunction<*>)
every {
hint(DatasetAllocationParams::class)
showUntilDoneMockk(
any<DatasetAllocationParams>(),
any<(DatasetAllocationParams) -> StatefulDialog<DatasetAllocationParams>>(),
any<(DatasetAllocationParams) -> Boolean>()
)
} answers {
initState = firstArg<DatasetAllocationParams>()
val thirdBlockResult = thirdArg<(DatasetAllocationParams) -> Boolean>()
isShowUntilDoneSucceeded = thirdBlockResult(initState)
initState
}

mockkObject(configCrudable)
every {
configCrudable.getByUniqueKey<FilesWorkingSetConfig, String>(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<ConnectionConfig>()
every {
dataOpsManagerMock.hint(Boolean::class).performOperation(any<Operation<Any>>(), any<ProgressIndicator>())
} 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<String>(), any<String>(), any<Project>(), any<String>(), any<String>(), 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<FilesWorkingSet>()
val nodeMock = mockk<FilesWorkingSetNode>()
val nodeDataMock = NodeData(nodeMock, null, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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
Expand All @@ -428,7 +422,6 @@ class AllocateLikeActionTestSpec : WithApplicationShouldSpec({

assertSoftly {
isCleanInvalidateOnExpandTriggered shouldBe false
isAnalitycsTracked shouldBe false
isOperationPerformed shouldBe false
isThrowableReported shouldBe false
}
Expand Down

0 comments on commit 0aaabcf

Please sign in to comment.