11package org.utbot.framework.plugin.api.utils
22
3+ import org.utbot.framework.codegen.domain.DependencyInjectionFramework
34import org.utbot.framework.codegen.domain.Junit4
45import org.utbot.framework.codegen.domain.Junit5
6+ import org.utbot.framework.codegen.domain.SpringBeans
7+ import org.utbot.framework.codegen.domain.SpringBoot
58import org.utbot.framework.codegen.domain.TestFramework
69import org.utbot.framework.codegen.domain.TestNg
710import org.utbot.framework.plugin.api.MockFramework
@@ -16,13 +19,13 @@ fun TestFramework.patterns(): Patterns {
1619 Junit4 -> junit4ModulePatterns
1720 Junit5 -> junit5ModulePatterns
1821 TestNg -> testNgModulePatterns
19- else -> throw UnsupportedOperationException ()
22+ else -> throw UnsupportedOperationException (" Unknown test framework $this " )
2023 }
2124 val libraryPatterns = when (this ) {
2225 Junit4 -> junit4Patterns
2326 Junit5 -> junit5Patterns
2427 TestNg -> testNgPatterns
25- else -> throw UnsupportedOperationException ()
28+ else -> throw UnsupportedOperationException (" Unknown test framework $this " )
2629 }
2730
2831 return Patterns (moduleLibraryPatterns, libraryPatterns)
@@ -34,13 +37,13 @@ fun TestFramework.parametrizedTestsPatterns(): Patterns {
3437 Junit4 -> emptyList()
3538 Junit5 -> emptyList() // emptyList here because JUnit5 module may not be enough for parametrized tests if :junit-jupiter-params: is not installed
3639 TestNg -> testNgModulePatterns
37- else -> throw UnsupportedOperationException ()
40+ else -> throw UnsupportedOperationException (" Unknown test framework $this " )
3841 }
3942 val libraryPatterns = when (this ) {
4043 Junit4 -> emptyList()
4144 Junit5 -> junit5ParametrizedTestsPatterns
4245 TestNg -> testNgPatterns
43- else -> throw UnsupportedOperationException ()
46+ else -> throw UnsupportedOperationException (" Unknown test framework $this " )
4447 }
4548
4649 return Patterns (moduleLibraryPatterns, libraryPatterns)
@@ -58,6 +61,21 @@ fun MockFramework.patterns(): Patterns {
5861 return Patterns (moduleLibraryPatterns, libraryPatterns)
5962}
6063
64+ fun DependencyInjectionFramework.patterns (): Patterns {
65+ val moduleLibraryPatterns = when (this ) {
66+ SpringBoot -> springBootModulePatterns
67+ SpringBeans -> springBeansModulePatterns
68+ else -> throw UnsupportedOperationException (" Unknown dependency injection framework $this " )
69+ }
70+ val libraryPatterns = when (this ) {
71+ SpringBoot -> springBootPatterns
72+ SpringBeans -> springBeansPatterns
73+ else -> throw UnsupportedOperationException (" Unknown dependency injection framework $this " )
74+ }
75+
76+ return Patterns (moduleLibraryPatterns, libraryPatterns)
77+ }
78+
6179val JUNIT_4_JAR_PATTERN = Regex (" junit-4(\\ .1[2-9])(\\ .[0-9]+)?" )
6280val JUNIT_4_MVN_PATTERN = Regex (" junit:junit:4(\\ .1[2-9])(\\ .[0-9]+)?" )
6381val junit4Patterns = listOf (JUNIT_4_JAR_PATTERN , JUNIT_4_MVN_PATTERN )
@@ -93,4 +111,18 @@ val mockitoModulePatterns = listOf(MOCKITO_BASIC_MODULE_PATTERN)
93111
94112const val MOCKITO_EXTENSIONS_FOLDER = " mockito-extensions"
95113const val MOCKITO_MOCKMAKER_FILE_NAME = " org.mockito.plugins.MockMaker"
96- val MOCKITO_EXTENSIONS_FILE_CONTENT = " mock-maker-inline"
114+ val MOCKITO_EXTENSIONS_FILE_CONTENT = " mock-maker-inline"
115+
116+ val SPRING_BEANS_JAR_PATTERN = Regex (" spring-beans-([0-9]+)(\\ .[0-9]+){1,2}" )
117+ val SPRING_BEANS_MVN_PATTERN = Regex (" org\\ .springframework:spring-beans:([0-9]+)(\\ .[0-9]+){1,2}" )
118+ val springBeansPatterns = listOf (SPRING_BEANS_JAR_PATTERN , SPRING_BEANS_MVN_PATTERN )
119+
120+ val SPRING_BEANS_BASIC_MODULE_PATTERN = Regex (" spring-beans" )
121+ val springBeansModulePatterns = listOf (SPRING_BEANS_BASIC_MODULE_PATTERN )
122+
123+ val SPRING_BOOT_JAR_PATTERN = Regex (" spring-boot-([0-9]+)(\\ .[0-9]+){1,2}" )
124+ val SPRING_BOOT_MVN_PATTERN = Regex (" org\\ .springframework\\ .boot:spring-boot:([0-9]+)(\\ .[0-9]+){1,2}" )
125+ val springBootPatterns = listOf (SPRING_BOOT_JAR_PATTERN , SPRING_BOOT_MVN_PATTERN )
126+
127+ val SPRING_BOOT_BASIC_MODULE_PATTERN = Regex (" spring-boot" )
128+ val springBootModulePatterns = listOf (SPRING_BOOT_BASIC_MODULE_PATTERN )
0 commit comments