@@ -2,6 +2,7 @@ package org.utbot.intellij.plugin.models
2
2
3
3
import com.intellij.openapi.roots.ExternalLibraryDescriptor
4
4
import org.jetbrains.idea.maven.utils.library.RepositoryLibraryDescription
5
+ import org.utbot.intellij.plugin.ui.utils.Version
5
6
6
7
val ExternalLibraryDescriptor .mavenCoordinates: String
7
8
get() = " $libraryGroupId :$libraryArtifactId :${preferredVersion ? : RepositoryLibraryDescription .ReleaseVersionId } "
@@ -10,33 +11,70 @@ val ExternalLibraryDescriptor.id: String
10
11
get() = " $libraryGroupId :$libraryArtifactId "
11
12
12
13
// 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
+ }
15
21
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
+ }
18
29
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
+ }
21
37
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
+ }
24
45
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
+ }
27
53
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
+ }
30
61
31
62
32
63
/* *
33
64
* TestNg requires JDK 11 since version 7.6.0
34
65
* For projects with JDK 8 version 7.5 should be installed.
35
66
* See https://groups.google.com/g/testng-users/c/BAFB1vk-kok?pli=1 for more details.
36
67
*/
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
+ }
40
75
41
76
fun 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