From 43b43422be40d8422117845f618d792a75bc6827 Mon Sep 17 00:00:00 2001 From: Uladzislau Date: Wed, 12 Jun 2024 15:32:41 +0200 Subject: [PATCH] Small trailling change Signed-off-by: Uladzislau --- .../utils/ui/WindowsLikeMessageDialog.kt | 20 +++++----- .../ui/WindowsLikeMessageDialogTestSpec.kt | 38 +++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialog.kt b/src/main/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialog.kt index d98904834..eb2efe46b 100644 --- a/src/main/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialog.kt +++ b/src/main/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialog.kt @@ -8,7 +8,7 @@ * Copyright IBA Group 2020 */ -package eu.ibagroup.formainframe.utils.ui +package org.zowe.explorer.utils.ui import com.intellij.openapi.project.Project import com.intellij.openapi.ui.messages.MessageDialog @@ -46,7 +46,7 @@ class WindowsLikeMessageDialog( doNotAskOption, canBeParent, helpId) { - + companion object { /** * Static function is used to show Windows based message dialog @@ -67,11 +67,11 @@ class WindowsLikeMessageDialog( return windowsLikeMessageDialog.exitCode } } - + override fun createActions(): Array { return mutableListOf().toTypedArray() } - + override fun createLeftSideActions(): Array { val actions = mutableListOf() for (i in myOptions.indices) { @@ -99,11 +99,11 @@ class WindowsLikeMessageDialog( } return actions.toTypedArray(); } - + override fun createButtonsPanel(buttons: MutableList): JPanel { return createLayoutButtonsPanel(buttons) } - + /** * Function is used to create the bottom JComponent of the message dialog containing N buttons followed one by one * using vertical direction @@ -112,16 +112,16 @@ class WindowsLikeMessageDialog( val buttonsPanel: JPanel = NonOpaquePanel() val jPanels = mutableListOf() buttonsPanel.layout = BoxLayout(buttonsPanel, BoxLayout.Y_AXIS) - + for (i in buttons.indices) { val button: JButton = buttons[i] val jPanel: JPanel = NonOpaquePanel() jPanel.add(button) jPanels.add(jPanel) } - + jPanels.forEach { buttonsPanel.add(it) } return buttonsPanel } - -} \ No newline at end of file + +} diff --git a/src/test/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialogTestSpec.kt b/src/test/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialogTestSpec.kt index 328251244..6d3e946a4 100644 --- a/src/test/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialogTestSpec.kt +++ b/src/test/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialogTestSpec.kt @@ -8,11 +8,11 @@ * Copyright IBA Group 2020 */ -package eu.ibagroup.formainframe.utils.ui +package org.zowe.explorer.utils.ui import com.intellij.openapi.project.ProjectManager import com.intellij.ui.UiInterceptors -import eu.ibagroup.formainframe.testutils.WithApplicationShouldSpec +import org.zowe.explorer.testutils.WithApplicationShouldSpec import io.kotest.assertions.assertSoftly import io.kotest.matchers.shouldBe import io.mockk.* @@ -22,23 +22,23 @@ import javax.swing.JButton import javax.swing.JPanel class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ - + afterSpec { clearAllMocks() } - + context("Windows dialog common spec") { - + val project = ProjectManager.getInstance().defaultProject mockkStatic(EventQueue::class) every { EventQueue.isDispatchThread() } returns true - + val actions = arrayOf( "Skip the conflicting file(s)", "Replace the file(s) in the destination", "Decide for each file" ) - + val customDialog = WindowsLikeMessageDialog( project, null, @@ -53,38 +53,38 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ false, "helpId" ) - + val classUnderTest = spyk(customDialog, "testDialog") - + should("create right side empty actions of the dialog") { val expected = mutableListOf().toTypedArray() val methodToTest = classUnderTest::class.java.declaredMethods.single { it.name == "createActions" } val result = methodToTest.invoke(classUnderTest) - + assertSoftly { result as Array<*> shouldBe expected } } - + should("create left side actions of the dialog") { val methodToTest = classUnderTest::class.java.declaredMethods.single { it.name == "createLeftSideActions" } val result = methodToTest.invoke(classUnderTest) as Array<*> val actionToPerform = (result[0] as Action) - + // Call default action to be able to cover lambda expression actionToPerform.actionPerformed(null) - + assertSoftly { // Plus help action, because helpId is not null result.size shouldBe 4 } } - + should("create buttons panel of the dialog with 3 buttons") { val methodToTest = classUnderTest::class.java.declaredMethods.single { it.name == "createButtonsPanel" } val arguments = mutableListOf(JButton(actions[0]), JButton(actions[1]), JButton(actions[2])) val result = methodToTest.invoke(classUnderTest, arguments) as JPanel - + assertSoftly { ((result.getComponent(0) as JPanel).getComponent(0) as JButton).text shouldBe "Skip the conflicting file(s)" ((result.getComponent(1) as JPanel).getComponent(0) as JButton).text shouldBe "Replace the file(s) in the destination" @@ -92,18 +92,18 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ } } } - + context("test showWindowsLikeMessageDialog static function") { val project = ProjectManager.getInstance().defaultProject mockkStatic(EventQueue::class) every { EventQueue.isDispatchThread() } returns true - + val actions = arrayOf( "Skip the conflicting file(s)", "Replace the file(s) in the destination", "Decide for each file" ) - + should("call showWindowsLikeMessageDialog") { mockkStatic(UiInterceptors::class) every { UiInterceptors.tryIntercept(any()) } returns true @@ -126,4 +126,4 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ } } } -}) \ No newline at end of file +})