Skip to content

Commit 30d5534

Browse files
Test generation should be forbidden for JDK 17+ #2210 (#2299)
1 parent c2813b6 commit 30d5534

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
548548
val sdkFixed = isEdited && sdkVersion.feature in minSupportedSdkVersion..maxSupportedSdkVersion
549549
if (sdkFixed) {
550550
this@SdkNotificationPanel.isVisible = false
551-
isOKActionEnabled = true
552551
initValidation()
553552
}
554553
}
@@ -613,32 +612,35 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
613612
"Tick any methods to generate tests for", membersTable
614613
)
615614
}
615+
if (!isSdkSupported()) {
616+
return ValidationInfo("")
617+
}
616618
return null
617619
}
618620

619-
class OKOptionAction(val testsModel: GenerateTestsModel, val okAction : Action) : AbstractAction(testsModel.getActionText()), OptionAction {
621+
inner class OKOptionAction(val okAction : Action) : AbstractAction(model.getActionText()), OptionAction {
620622
init {
621623
putValue(DEFAULT_ACTION, java.lang.Boolean.TRUE)
622624
putValue(FOCUSED_ACTION, java.lang.Boolean.TRUE)
623625
}
624626
private val generateAction = object : AbstractAction(ACTION_GENERATE) {
625627
override fun actionPerformed(e: ActionEvent?) {
626-
testsModel.runGeneratedTestsWithCoverage = false
628+
model.runGeneratedTestsWithCoverage = false
627629
updateButtonText(e)
628630
}
629631
}
630632
private val generateAndRunAction = object : AbstractAction(ACTION_GENERATE_AND_RUN) {
631633
override fun actionPerformed(e: ActionEvent?) {
632-
testsModel.runGeneratedTestsWithCoverage = true
634+
model.runGeneratedTestsWithCoverage = true
633635
updateButtonText(e)
634636
}
635637
}
636638

637639
private fun updateButtonText(e: ActionEvent?) {
638640
with(e?.source as JButton) {
639-
text = testsModel.getActionText()
640-
testsModel.project.service<Settings>().runGeneratedTestsWithCoverage =
641-
testsModel.runGeneratedTestsWithCoverage
641+
text = this@GenerateTestsDialogWindow.model.getActionText()
642+
this@GenerateTestsDialogWindow.model.project.service<Settings>().runGeneratedTestsWithCoverage =
643+
this@GenerateTestsDialogWindow.model.runGeneratedTestsWithCoverage
642644
repaint()
643645
}
644646
}
@@ -648,15 +650,19 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
648650
}
649651

650652
override fun getOptions(): Array<Action> {
651-
if (testsModel.runGeneratedTestsWithCoverage) return arrayOf(generateAndRunAction, generateAction)
653+
if (model.runGeneratedTestsWithCoverage) return arrayOf(generateAndRunAction, generateAction)
652654
return arrayOf(generateAction, generateAndRunAction)
653655
}
656+
657+
override fun setEnabled(enabled: Boolean) {
658+
super.setEnabled(enabled && isSdkSupported())
659+
}
654660
}
655661

656662
private var okOptionAction: OKOptionAction? = null
657663
override fun getOKAction(): Action {
658664
if (okOptionAction == null) {
659-
okOptionAction = OKOptionAction(model, super.getOKAction())
665+
okOptionAction = OKOptionAction(super.getOKAction())
660666
}
661667
return okOptionAction!!
662668
}

0 commit comments

Comments
 (0)