From 25b6ab4a573b92a064e76a7d3f23221ff0d986b4 Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Thu, 5 Oct 2023 10:12:23 +0300 Subject: [PATCH] Make JDK names more readable (in unsupported version warning) (#2646) Use better JDK names in unsupported version warning #2635 (cherry picked from commit 4bb432959f640b1e3e62a0b8b721536e2cce219e) --- .../org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt | 4 +++- .../src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt index 8076c2208a..e0cc22c797 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt @@ -520,7 +520,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m text = run { val sdkVersion = findSdkVersionOrNull(this@GenerateTestsDialogWindow.model.srcModule)?.feature if (sdkVersion != null) { - "SDK version $sdkVersion is not supported, use ${JavaSdkVersion.JDK_1_8}, ${JavaSdkVersion.JDK_11} or ${JavaSdkVersion.JDK_17}" + "SDK version $sdkVersion is not supported, use ${JavaSdkVersion.JDK_1_8.toReadableString()}, ${JavaSdkVersion.JDK_11.toReadableString()} or ${JavaSdkVersion.JDK_17.toReadableString()} instead." } else { "SDK is not defined" } @@ -533,6 +533,8 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m }) } + fun JavaSdkVersion.toReadableString() : String = toString().replace("JDK_", "").replace('_', '.') + override fun getBackground(): Color? = EditorColorsManager.getInstance().globalScheme.getColor(HintUtil.ERROR_COLOR_KEY) ?: super.getBackground() diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt b/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt index 3d5f7acb87..e06b403bc8 100644 --- a/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt @@ -68,7 +68,7 @@ class UnitTestBotActionTest : BaseTest() { textEditor().typeAdditionFunction(newClassName) openUTBotDialogFromProjectViewForClass(newClassName) assertThat(unitTestBotDialog.generateTestsButton.isEnabled().not()) - assertThat(unitTestBotDialog.sdkNotificationLabel.hasText("SDK version 19 is not supported, use JDK_1_8, JDK_11 or JDK_17")) + assertThat(unitTestBotDialog.sdkNotificationLabel.hasText("SDK version 19 is not supported, use 1.8, 11 or 17 instead.")) assertThat(unitTestBotDialog.setupSdkLink.isShowing) unitTestBotDialog.closeButton.click() }