@@ -2,6 +2,7 @@ package org.utbot.intellij.plugin.models
22
33import com.intellij.openapi.roots.ExternalLibraryDescriptor
44import org.jetbrains.idea.maven.utils.library.RepositoryLibraryDescription
5+ import org.utbot.intellij.plugin.ui.utils.Version
56
67val ExternalLibraryDescriptor .mavenCoordinates: String
78 get() = " $libraryGroupId :$libraryArtifactId :${preferredVersion ? : RepositoryLibraryDescription .ReleaseVersionId } "
@@ -10,33 +11,70 @@ val ExternalLibraryDescriptor.id: String
1011 get() = " $libraryGroupId :$libraryArtifactId "
1112
1213// TODO: think about using JUnitExternalLibraryDescriptor from intellij-community sources (difficult to install)
13- fun jUnit4LibraryDescriptor (versionInProject : String? ) =
14- ExternalLibraryDescriptor (" junit" , " junit" , " 4.12" , null , versionInProject ? : " 4.13.2" )
14+ fun jUnit4LibraryDescriptor (versionInProject : Version ? ): ExternalLibraryDescriptor {
15+ val preferredVersion = if (versionInProject?.hasNumericOrEmptyPatch() == true ) versionInProject?.plainText else " 4.13.2"
16+ return ExternalLibraryDescriptor (
17+ " junit" , " junit" ,
18+ " 4.12" , null , preferredVersion
19+ )
20+ }
1521
16- fun jUnit5LibraryDescriptor (versionInProject : String? ) =
17- ExternalLibraryDescriptor (" org.junit.jupiter" , " junit-jupiter" , " 5.8.1" , null , versionInProject ? : " 5.8.1" )
22+ fun jUnit5LibraryDescriptor (versionInProject : Version ? ): ExternalLibraryDescriptor {
23+ val preferredVersion = if (versionInProject?.hasNumericOrEmptyPatch() == true ) versionInProject?.plainText else " 5.8.1"
24+ return ExternalLibraryDescriptor (
25+ " org.junit.jupiter" , " junit-jupiter" ,
26+ " 5.8.1" , null , preferredVersion
27+ )
28+ }
1829
19- fun jUnit5ParametrizedTestsLibraryDescriptor (versionInProject : String? ) =
20- ExternalLibraryDescriptor (" org.junit.jupiter" , " junit-jupiter-params" , " 5.8.1" , null , versionInProject ? : " 5.8.1" )
30+ fun jUnit5ParametrizedTestsLibraryDescriptor (versionInProject : Version ? ): ExternalLibraryDescriptor {
31+ val preferredVersion = if (versionInProject?.hasNumericOrEmptyPatch() == true ) versionInProject?.plainText else " 5.8.1"
32+ return ExternalLibraryDescriptor (
33+ " org.junit.jupiter" , " junit-jupiter-params" ,
34+ " 5.8.1" , null , preferredVersion
35+ )
36+ }
2137
22- fun mockitoCoreLibraryDescriptor (versionInProject : String? ) =
23- ExternalLibraryDescriptor (" org.mockito" , " mockito-core" , " 3.5.0" , null , versionInProject ? : " 4.2.0" )
38+ fun mockitoCoreLibraryDescriptor (versionInProject : Version ? ): ExternalLibraryDescriptor {
39+ val preferredVersion = if (versionInProject?.hasNumericOrEmptyPatch() == true ) versionInProject?.plainText else " 4.2.0"
40+ return ExternalLibraryDescriptor (
41+ " org.mockito" , " mockito-core" ,
42+ " 3.5.0" , null , preferredVersion
43+ )
44+ }
2445
25- fun springBootTestLibraryDescriptor (versionInProject : String? ) =
26- ExternalLibraryDescriptor (" org.springframework.boot" , " spring-boot-test" , " 2.4.0" , null , versionInProject ? : " 3.0.6" )
46+ fun springBootTestLibraryDescriptor (versionInProject : Version ? ): ExternalLibraryDescriptor {
47+ val preferredVersion = if (versionInProject?.hasNumericOrEmptyPatch() == true ) versionInProject?.plainText else " 3.0.6"
48+ return ExternalLibraryDescriptor (
49+ " org.springframework.boot" , " spring-boot-test" ,
50+ " 2.4.0" , null , preferredVersion
51+ )
52+ }
2753
28- fun springTestLibraryDescriptor (versionInProject : String? ) =
29- ExternalLibraryDescriptor (" org.springframework" , " spring-test" , " 2.5" , null , versionInProject ? : " 6.0.8" )
54+ fun springTestLibraryDescriptor (versionInProject : Version ? ): ExternalLibraryDescriptor {
55+ val preferredVersion = if (versionInProject?.hasNumericOrEmptyPatch() == true ) versionInProject?.plainText else " 6.0.8"
56+ return ExternalLibraryDescriptor (
57+ " org.springframework" , " spring-test" ,
58+ " 2.5" , null , preferredVersion
59+ )
60+ }
3061
3162
3263/* *
3364 * TestNg requires JDK 11 since version 7.6.0
3465 * For projects with JDK 8 version 7.5 should be installed.
3566 * See https://groups.google.com/g/testng-users/c/BAFB1vk-kok?pli=1 for more details.
3667 */
37-
38- fun testNgNewLibraryDescriptor (versionInProject : String? ) =
39- ExternalLibraryDescriptor (" org.testng" , " testng" , " 7.6.0" , null , versionInProject ? : " 7.6.0" )
68+ fun testNgNewLibraryDescriptor (versionInProject : Version ? ): ExternalLibraryDescriptor {
69+ val preferredVersion = if (versionInProject?.hasNumericOrEmptyPatch() == true ) versionInProject?.plainText else " 7.6.0"
70+ return ExternalLibraryDescriptor (
71+ " org.testng" , " testng" ,
72+ " 7.6.0" , null , preferredVersion
73+ )
74+ }
4075
4176fun testNgOldLibraryDescriptor () =
42- ExternalLibraryDescriptor (" org.testng" , " testng" , " 7.5" , " 7.5" , " 7.5" )
77+ ExternalLibraryDescriptor (
78+ " org.testng" , " testng" ,
79+ " 7.5" , " 7.5" , " 7.5"
80+ )
0 commit comments