Skip to content

Commit

Permalink
Small trailling change
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Jun 12, 2024
1 parent b9b67c4 commit 43b4342
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +46,7 @@ class WindowsLikeMessageDialog(
doNotAskOption,
canBeParent,
helpId) {

companion object {
/**
* Static function is used to show Windows based message dialog
Expand All @@ -67,11 +67,11 @@ class WindowsLikeMessageDialog(
return windowsLikeMessageDialog.exitCode
}
}

override fun createActions(): Array<Action> {
return mutableListOf<Action>().toTypedArray()
}

override fun createLeftSideActions(): Array<Action> {
val actions = mutableListOf<Action>()
for (i in myOptions.indices) {
Expand Down Expand Up @@ -99,11 +99,11 @@ class WindowsLikeMessageDialog(
}
return actions.toTypedArray();
}

override fun createButtonsPanel(buttons: MutableList<out JButton>): 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
Expand All @@ -112,16 +112,16 @@ class WindowsLikeMessageDialog(
val buttonsPanel: JPanel = NonOpaquePanel()
val jPanels = mutableListOf<JPanel>()
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
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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,
Expand All @@ -53,57 +53,57 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({
false,
"helpId"
)

val classUnderTest = spyk(customDialog, "testDialog")

should("create right side empty actions of the dialog") {
val expected = mutableListOf<Action>().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"
((result.getComponent(2) as JPanel).getComponent(0) as JButton).text shouldBe "Decide for each file"
}
}
}

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
Expand All @@ -126,4 +126,4 @@ class WindowsLikeMessageDialogTestSpec : WithApplicationShouldSpec({
}
}
}
})
})

0 comments on commit 43b4342

Please sign in to comment.