From 5f7904870823e3678718eaa43305c81a49d0a5ee Mon Sep 17 00:00:00 2001 From: Arseni Tsikhamirau Date: Tue, 24 Sep 2024 16:07:19 +0200 Subject: [PATCH] IJMP-1832-Do-not-reconnect-on-CredentialsNotFound --- .../explorer/actions/PurgeJobAction.kt | 2 +- .../explorer/ui/ExplorerTreeView.kt | 8 +-- .../formainframe/tso/TSOWindowFactory.kt | 30 +++++++---- .../explorer/ui/ExplorerTreeViewTestSpec.kt | 8 +-- .../tso/TSOWindowFactoryTestSpec.kt | 50 +++++++++++++++++++ 5 files changed, 74 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/eu/ibagroup/formainframe/explorer/actions/PurgeJobAction.kt b/src/main/kotlin/eu/ibagroup/formainframe/explorer/actions/PurgeJobAction.kt index cfb3f4f5..e7ab138c 100644 --- a/src/main/kotlin/eu/ibagroup/formainframe/explorer/actions/PurgeJobAction.kt +++ b/src/main/kotlin/eu/ibagroup/formainframe/explorer/actions/PurgeJobAction.kt @@ -270,7 +270,7 @@ class PurgeJobAction : AnAction() { cancellable = true ) { runCatching { - service().performOperation( + DataOpsManager.getService().performOperation( operation = PurgeJobOperation( request = BasicPurgeJobParams(jobStatus.jobName, jobStatus.jobId), connectionConfig = connectionConfig diff --git a/src/main/kotlin/eu/ibagroup/formainframe/explorer/ui/ExplorerTreeView.kt b/src/main/kotlin/eu/ibagroup/formainframe/explorer/ui/ExplorerTreeView.kt index 0b791061..a4b5f64e 100644 --- a/src/main/kotlin/eu/ibagroup/formainframe/explorer/ui/ExplorerTreeView.kt +++ b/src/main/kotlin/eu/ibagroup/formainframe/explorer/ui/ExplorerTreeView.kt @@ -64,12 +64,8 @@ import eu.ibagroup.formainframe.explorer.ExplorerUnit import eu.ibagroup.formainframe.explorer.UNITS_CHANGED import eu.ibagroup.formainframe.explorer.WorkingSet import eu.ibagroup.formainframe.telemetry.NotificationsService -import eu.ibagroup.formainframe.utils.castOrNull +import eu.ibagroup.formainframe.utils.* import eu.ibagroup.formainframe.utils.crudable.EntityWithUuid -import eu.ibagroup.formainframe.utils.getAncestorNodes -import eu.ibagroup.formainframe.utils.runInEdtAndWait -import eu.ibagroup.formainframe.utils.rwLocked -import eu.ibagroup.formainframe.utils.subscribe import eu.ibagroup.formainframe.vfs.MFBulkFileListener import eu.ibagroup.formainframe.vfs.MFVFilePropertyChangeEvent import eu.ibagroup.formainframe.vfs.MFVirtualFile @@ -475,7 +471,7 @@ abstract class ExplorerTreeView() as TestDataOpsManagerImpl + dataOpsManager.testInstance = object : TestDataOpsManagerImpl() { + override fun performOperation(operation: Operation, progressIndicator: ProgressIndicator): R { + throw CredentialsNotFoundForConnection(ConnectionConfig()) + } + + } + + val oldSessionResponse = TsoResponse(servletKey = "test-servletKey-1") + val session = TSOConfigWrapper(tsoSessionConfig, connectionConfig, oldSessionResponse) + val command = "TIME" + val messageType = mockk() + val messageData = mockk() + + every { console.getProcessHandler() } returns processHandler + every { console.getTsoSession() } returns session + every { processHandler.notifyTextAvailable(any(), any()) } just Runs + + // when + sendTopic(SESSION_COMMAND_ENTERED).processCommand( + project, + console, + session, + command, + messageType, + messageData, + processHandler + ) + + // then + verify(exactly = 1) { + processHandler.notifyTextAvailable( + "Unable to obtain the connection information for connection=${session.getConnectionConfig()}.\n Session will be closed.", + ProcessOutputType.STDOUT + ) + } + verify(exactly = 1) { + processHandler.destroyProcess() + } + assertSoftly { + session.unresponsive shouldBe true + } + } + should("should reconnect to the tso session after unsuccessful execution of the command") { // given clearMocks(processHandler, verificationMarks = true, recordedCalls = true)