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 3890b2a81..484815bdf 100644 --- a/src/test/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialogTestSpec.kt +++ b/src/test/kotlin/eu/ibagroup/formainframe/utils/ui/WindowsLikeMessageDialogTestSpec.kt @@ -8,12 +8,12 @@ * Copyright IBA Group 2020 */ -package eu.ibagroup.formainframe.utils.ui +package org.zowe.explorer.utils.ui import com.intellij.openapi.application.ApplicationManager 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.* @@ -23,11 +23,11 @@ import javax.swing.JButton import javax.swing.JPanel class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ - + afterSpec { clearAllMocks() } - + context("Windows dialog common spec") { val application = ApplicationManager.getApplication() val project = ProjectManager.getInstance().defaultProject @@ -35,13 +35,13 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ mockkObject(application) every { EventQueue.isDispatchThread() } returns true every { application.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, @@ -56,38 +56,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" @@ -96,18 +96,18 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ } unmockkAll() } - + 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 @@ -131,4 +131,4 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({ } unmockkAll() } -}) \ No newline at end of file +})