@@ -116,14 +116,7 @@ import org.utbot.framework.plugin.api.MockFramework.MOCKITO
116116import org.utbot.framework.plugin.api.MockStrategyApi
117117import org.utbot.framework.plugin.api.TreatOverflowAsError
118118import org.utbot.framework.util.Conflict
119- import org.utbot.intellij.plugin.models.GenerateTestsModel
120- import org.utbot.intellij.plugin.models.id
121- import org.utbot.intellij.plugin.models.jUnit4LibraryDescriptor
122- import org.utbot.intellij.plugin.models.jUnit5LibraryDescriptor
123- import org.utbot.intellij.plugin.models.jUnit5ParametrizedTestsLibraryDescriptor
124- import org.utbot.intellij.plugin.models.mockitoCoreLibraryDescriptor
125- import org.utbot.intellij.plugin.models.packageName
126- import org.utbot.intellij.plugin.models.testNgLibraryDescriptor
119+ import org.utbot.intellij.plugin.models.*
127120import org.utbot.intellij.plugin.settings.Settings
128121import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer
129122import org.utbot.intellij.plugin.ui.components.TestFolderComboWithBrowseButton
@@ -314,15 +307,16 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
314307 label?.let { add(it, BorderLayout .LINE_END ) }
315308 })
316309
317- private fun findSdkVersion (): JavaVersion ? {
318- val projectSdk = ModuleRootManager .getInstance(model.srcModule).sdk
319- return JavaVersion .tryParse(projectSdk?.versionString)
310+ private fun findSdkVersion (): JavaVersion {
311+ val moduleSdk = ModuleRootManager .getInstance(model.srcModule).sdk
312+ return JavaVersion .tryParse(moduleSdk?.versionString)
313+ ? : error(" Cannot define sdk version in module ${model.srcModule} " )
320314 }
321315
322316 override fun createTitlePane (): JComponent ? {
323317 val sdkVersion = findSdkVersion()
324318 // TODO:SAT-1571 investigate Android Studio specific sdk issues
325- if (sdkVersion? .feature in minSupportedSdkVersion.. maxSupportedSdkVersion || IntelliJApiHelper .isAndroidStudio()) return null
319+ if (sdkVersion.feature in minSupportedSdkVersion.. maxSupportedSdkVersion || IntelliJApiHelper .isAndroidStudio()) return null
326320 isOKActionEnabled = false
327321 return SdkNotificationPanel (model, sdkVersion)
328322 }
@@ -373,7 +367,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
373367 { projectStructure.select(model.srcModule.name, ClasspathEditor .getName(), true ) }
374368
375369 val sdkVersion = findSdkVersion()
376- val sdkFixed = isEdited && sdkVersion? .feature in minSupportedSdkVersion.. maxSupportedSdkVersion
370+ val sdkFixed = isEdited && sdkVersion.feature in minSupportedSdkVersion.. maxSupportedSdkVersion
377371 if (sdkFixed) {
378372 this @SdkNotificationPanel.isVisible = false
379373 isOKActionEnabled = true
@@ -721,11 +715,15 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
721715 val libraryInProject =
722716 findFrameworkLibrary(model.project, model.testModule, selectedTestFramework, LibrarySearchScope .Project )
723717 val versionInProject = libraryInProject?.libraryName?.parseVersion()
718+ val sdkVersion: Int? = findSdkVersion().feature
724719
725720 val libraryDescriptor = when (selectedTestFramework) {
726721 Junit4 -> jUnit4LibraryDescriptor(versionInProject)
727722 Junit5 -> jUnit5LibraryDescriptor(versionInProject)
728- TestNg -> testNgLibraryDescriptor(versionInProject)
723+ TestNg -> when (sdkVersion) {
724+ minSupportedSdkVersion -> testNgOldLibraryDescriptor()
725+ else -> testNgNewLibraryDescriptor(versionInProject)
726+ }
729727 }
730728
731729 selectedTestFramework.isInstalled = true
0 commit comments