Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited7d870

Browse files
authored
Extractutbot-spring-framework module fromutbot-framework (#2570)
* Make `relevantFieldManagers` a dynamic property, since it's Spring-specificRemove `CgContext.relevantFieldManagers` field* Move `springNoConfigApplicationContext` constant from `utbot-testing` to `utbot-spring-test`* Extract `utbot-spring-framework` module from `utbot-framework-module`Remove duplicated `include("utbot-spring-framework")` in `settings.gradle.kts`* Rename `DependencyInjectionFramework` to `SpringModule` and stop implementing `CodeGenerationSettingItem` as it's not a setting* Move `SpringModule` from `utbot-framework` to `utbot-spring-framework`* Remove unused imports, update comments* Introduce `EngineProcessTask`* Use `EngineProcessTask` to call spring analyzer* Make `SpringModule` a `enum`
1 parent9c122a9 commited7d870

File tree

54 files changed

+371
-541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+371
-541
lines changed

‎settings.gradle.kts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ if (includeRiderInBuild.toBoolean()) {
5656

5757
include("utbot-ui-commons")
5858

59+
include("utbot-spring-framework")
5960
include("utbot-spring-commons-api")
6061
include("utbot-spring-commons")
6162
include("utbot-spring-analyzer")

‎utbot-core/src/main/kotlin/org/utbot/common/DynamicProperties.kt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ interface MutableDynamicProperties<TOwner> : DynamicProperties<TOwner> {
3636
operatorfun <T>set(property:DynamicProperty<TOwner,T>,value:T)
3737
}
3838

39+
fun <TOwner,T> MutableDynamicProperties<TOwner>.getOrPut(property:DynamicProperty<TOwner,T>,default: ()->T):T {
40+
if (property!inthis) set(property, default())
41+
return getValue(property)
42+
}
43+
3944
fun <TOwner>Iterable<InitialisedDynamicProperty<TOwner,*>>.toMutableDynamicProperties():MutableDynamicProperties<TOwner>=
4045
DynamicPropertiesImpl<TOwner>().also { properties->
4146
forEach { properties.add(it) }

‎utbot-framework/build.gradle‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ plugins {
33
}
44

55
configurations {
6-
fetchSpringAnalyzerJar
7-
fetchSpringCommonsJar
86
fetchInstrumentationJar
97
}
108

@@ -48,23 +46,10 @@ dependencies {
4846
implementationgroup:'com.github.UnitTestBot.ksmt',name:'ksmt-z3',version: ksmtVersion
4947

5048
fetchInstrumentationJar project(path:':utbot-instrumentation',configuration:'instrumentationArchive')
51-
52-
implementation project(':utbot-spring-commons-api')
53-
implementation project(':utbot-spring-analyzer')
54-
fetchSpringAnalyzerJar project(path:':utbot-spring-analyzer',configuration:'springAnalyzerJar')
55-
fetchSpringCommonsJar project(path:':utbot-spring-commons',configuration:'springCommonsJar')
5649
}
5750

5851
processResources {
5952
from(configurations.fetchInstrumentationJar) {
6053
into"lib"
6154
}
62-
63-
from(configurations.fetchSpringAnalyzerJar) {
64-
into"lib"
65-
}
66-
67-
from(configurations.fetchSpringCommonsJar) {
68-
into"lib"
69-
}
7055
}

‎utbot-framework/src/main/kotlin/org/utbot/framework/assemble/AssembleModelGenerator.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ class AssembleModelGenerator(private val basePackageName: String) {
205205
isUtClassRefModel,
206206
isUtVoidModel,
207207
isUtEnumConstantModel,
208-
isUtCustomModel-> utModel
208+
isUtCustomModel-> utModel// for example, UtSpringContextModel
209209
isUtLambdaModel-> assembleLambdaModel(utModel)
210210
isUtArrayModel-> assembleArrayModel(utModel)
211211
isUtCompositeModel-> assembleCompositeModel(utModel)
212212
isUtAssembleModel-> assembleAssembleModel(utModel)
213-
// Python, JavaScript, UtSpringContextModel are supposed to be here as well
213+
// Python, JavaScript are supposed to be here as well
214214
else-> utModel
215215
}
216216
}catch (e:AssembleException) {

‎utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/Domain.kt‎

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -711,47 +711,6 @@ enum class ProjectType {
711711
JavaScript,
712712
}
713713

714-
abstractclassDependencyInjectionFramework(
715-
overridevalid:String,
716-
overridevaldisplayName:String,
717-
overridevaldescription:String ="Use$displayName as dependency injection framework",
718-
valtestFrameworkDisplayName:String,
719-
/**
720-
* Generation Spring specific tests requires special spring test framework being installed,
721-
* so we can use `TestContextManager` from `spring-test` to configure test context in
722-
* spring-analyzer and to run integration tests.
723-
*/
724-
vartestFrameworkInstalled:Boolean =false
725-
) : CodeGenerationSettingItem {
726-
var isInstalled=false
727-
728-
companionobject:CodeGenerationSettingBox {
729-
overrideval defaultItem:DependencyInjectionFramework get()=SpringBoot
730-
overrideval allItems:List<DependencyInjectionFramework> get()=listOf(SpringBoot,SpringBeans)
731-
732-
val installedItems get()= allItems.filter { it.isInstalled }
733-
734-
/**
735-
* Generation Spring specific tests requires special spring test framework being installed,
736-
* so we can use `TestContextManager` from `spring-test` to configure test context in
737-
* spring-analyzer and to run integration tests.
738-
*/
739-
var testFrameworkInstalled:Boolean=false
740-
}
741-
}
742-
743-
object SpringBeans : DependencyInjectionFramework(
744-
id ="spring-beans",
745-
displayName ="Spring Beans",
746-
testFrameworkDisplayName ="spring-test",
747-
)
748-
749-
object SpringBoot : DependencyInjectionFramework(
750-
id ="spring-boot",
751-
displayName ="Spring Boot",
752-
testFrameworkDisplayName ="spring-boot-test",
753-
)
754-
755714
/**
756715
* Extended [UtModel] model with testSet id and execution id.
757716
*

‎utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/builtin/MockitoBuiltins.kt‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@ internal val mockitoClassId = BuiltinClassId(
2020
simpleName="Mockito",
2121
)
2222

23-
internalval mockClassId=BuiltinClassId(
24-
canonicalName="org.mockito.Mock",
25-
simpleName="Mock",
26-
)
27-
28-
internalval spyClassId=BuiltinClassId(
29-
canonicalName="org.mockito.Spy",
30-
simpleName="Spy"
31-
)
32-
33-
internalval injectMocksClassId=BuiltinClassId(
34-
canonicalName="org.mockito.InjectMocks",
35-
simpleName="InjectMocks",
36-
)
37-
3823
internalval ongoingStubbingClassId=BuiltinClassId(
3924
canonicalName="org.mockito.stubbing.OngoingStubbing",
4025
simpleName="OngoingStubbing",

‎utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/builtin/UtilMethodBuiltins.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ internal class UtilClassFileMethodProvider(language: CodegenLanguage)
278278
valUTIL_CLASS_VERSION="2.1"
279279
}
280280

281-
internalclassTestClassUtilMethodProvider(testClassId:ClassId) : UtilMethodProvider(testClassId)
281+
classTestClassUtilMethodProvider(testClassId:ClassId) : UtilMethodProvider(testClassId)
282282

283283
internalfunselectUtilClassId(codegenLanguage:CodegenLanguage):ClassId=
284284
when (codegenLanguage) {

‎utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/context/CgContext.kt‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import kotlinx.collections.immutable.PersistentSet
1313
importkotlinx.collections.immutable.persistentListOf
1414
importkotlinx.collections.immutable.persistentMapOf
1515
importkotlinx.collections.immutable.persistentSetOf
16+
importorg.utbot.common.DynamicProperty
17+
importorg.utbot.common.MutableDynamicProperties
18+
importorg.utbot.common.mutableDynamicPropertiesOf
1619
importorg.utbot.framework.codegen.domain.UtModelWrapper
1720
importorg.utbot.framework.codegen.domain.ProjectType
1821
importorg.utbot.framework.codegen.domain.builtin.TestClassUtilMethodProvider
@@ -25,7 +28,6 @@ import org.utbot.framework.codegen.tree.importIfNeeded
2528
importorg.utbot.framework.plugin.api.BuiltinClassId
2629
importorg.utbot.framework.plugin.api.ClassId
2730
importorg.utbot.framework.codegen.services.language.CgLanguageAssistant
28-
importorg.utbot.framework.codegen.tree.fieldmanager.CgAbstractClassFieldManager
2931
importorg.utbot.framework.plugin.api.CodegenLanguage
3032
importorg.utbot.framework.plugin.api.ExecutableId
3133
importorg.utbot.framework.plugin.api.FieldId
@@ -38,6 +40,9 @@ import org.utbot.framework.plugin.api.util.isCheckedException
3840
importorg.utbot.framework.plugin.api.util.isSubtypeOf
3941
importorg.utbot.framework.plugin.api.util.jClass
4042

43+
typealiasCgContextProperties=MutableDynamicProperties<CgContext>
44+
typealiasCgContextProperty<T>=DynamicProperty<CgContext,T>
45+
4146
/**
4247
* Interface for all code generation context aware entities
4348
*
@@ -243,10 +248,16 @@ interface CgContextOwner {
243248
var successfulExecutionsModels:List<UtModel>
244249

245250
/**
246-
* Managers to process annotated fields of the class under test
247-
* relevant for the current generation type.
251+
* Many of [CgContext] properties are only needed in some specific scenarios
252+
* (e.g. Spring-related properties and parametrized test specific properties).
253+
*
254+
* To avoid overly inflating [CgContext] interface such properties should
255+
* be added as dynamic properties.
256+
*
257+
* @see DynamicProperty
248258
*/
249-
val relevantFieldManagers:MutableList<CgAbstractClassFieldManager>
259+
// TODO make parameterized test specific properties dynamic
260+
val properties:CgContextProperties
250261

251262
funblock(init: ()->Unit):Block {
252263
val prevBlock= currentBlock
@@ -509,8 +520,8 @@ class CgContext(
509520
RuntimeExceptionTestsBehaviour.defaultItem,
510521
overridevalhangingTestsTimeout:HangingTestsTimeout =HangingTestsTimeout(),
511522
overridevalenableTestsTimeout:Boolean =true,
512-
overridevalrelevantFieldManagers:MutableList<CgAbstractClassFieldManager> = mutableListOf(),
513523
overridevarcontainsReflectiveCall:Boolean =false,
524+
overridevalproperties:CgContextProperties = mutableDynamicPropertiesOf(),
514525
) : CgContextOwner {
515526
overridelateinitvar statesCache:EnvironmentFieldStateCache
516527
overridelateinitvar actual:CgVariable
@@ -667,5 +678,6 @@ class CgContext(
667678
hangingTestsTimeout=this.hangingTestsTimeout,
668679
enableTestsTimeout=this.enableTestsTimeout,
669680
containsReflectiveCall=this.containsReflectiveCall,
681+
properties=this.properties,
670682
)
671683
}

‎utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/access/CgCallableAccessManager.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ interface CgCallableAccessManager {
8787
operatorfun ClassId.get(fieldId:FieldId):CgStaticFieldAccess
8888
}
8989

90-
internalclassCgCallableAccessManagerImpl(valcontext:CgContext) : CgCallableAccessManager,
90+
classCgCallableAccessManagerImpl(valcontext:CgContext) : CgCallableAccessManager,
9191
CgContextOwner by context {
9292

9393
privateval statementConstructor by lazy { getStatementConstructorBy(context) }

‎utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/TestFrameworkManager.kt‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ import org.utbot.framework.plugin.api.BuiltinMethodId
2525
importorg.utbot.framework.plugin.api.ClassId
2626
importorg.utbot.framework.plugin.api.CodegenLanguage
2727
importorg.utbot.framework.plugin.api.ConstructorId
28-
importorg.utbot.framework.plugin.api.util.SpringModelUtils.extendWithClassId
29-
importorg.utbot.framework.plugin.api.util.SpringModelUtils.runWithClassId
30-
importorg.utbot.framework.plugin.api.util.SpringModelUtils.springExtensionClassId
3128
importorg.utbot.framework.plugin.api.util.booleanArrayClassId
3229
importorg.utbot.framework.plugin.api.util.byteArrayClassId
3330
importorg.utbot.framework.plugin.api.util.charArrayClassId

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp