File tree Expand file tree Collapse file tree 4 files changed +11
-17
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework/codegen Expand file tree Collapse file tree 4 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -788,5 +788,5 @@ data class ModelId(
788
788
private val executionId : Int ,
789
789
)
790
790
791
- fun UtModel.modelId (executionId : Int = -1): ModelId = ModelId (this .idOrNull(), executionId)
791
+ fun UtModel.withId (executionId : Int = -1) = this to ModelId (this .idOrNull(), executionId)
792
792
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ import org.utbot.framework.codegen.domain.builtin.UtilClassFileMethodProvider
30
30
import org.utbot.framework.codegen.domain.builtin.UtilMethodProvider
31
31
import org.utbot.framework.codegen.domain.models.SimpleTestClassModel
32
32
import org.utbot.framework.codegen.domain.models.CgParameterKind
33
- import org.utbot.framework.codegen.domain.modelId
33
+ import org.utbot.framework.codegen.domain.withId
34
34
import org.utbot.framework.codegen.services.access.Block
35
35
import org.utbot.framework.codegen.tree.EnvironmentFieldStateCache
36
36
import org.utbot.framework.codegen.tree.importIfNeeded
@@ -573,7 +573,7 @@ data class CgContext(
573
573
574
574
override fun getIdByModel (model : UtModel ): ModelId {
575
575
if (model !in this .modelIds) {
576
- this .modelIds + = model to model.modelId ()
576
+ this .modelIds + = model.withId ()
577
577
}
578
578
579
579
return modelIds[model]
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package org.utbot.framework.codegen.domain.models.builders
3
3
import org.utbot.framework.codegen.domain.context.CgContext
4
4
import org.utbot.framework.codegen.domain.models.CgMethodTestSet
5
5
import org.utbot.framework.codegen.domain.models.SpringTestClassModel
6
- import org.utbot.framework.codegen.domain.modelId
6
+ import org.utbot.framework.codegen.domain.withId
7
7
import org.utbot.framework.plugin.api.ClassId
8
8
import org.utbot.framework.plugin.api.UtArrayModel
9
9
import org.utbot.framework.plugin.api.UtAssembleModel
@@ -61,13 +61,13 @@ class SpringTestClassModelBuilder(val context: CgContext): TestClassModelBuilder
61
61
}
62
62
63
63
private fun collectByThisInstanceModel (model : UtModel , executionIndex : Int ): Set <UtModel > {
64
- context.modelIds + = model to model.modelId (executionIndex)
64
+ context.modelIds + = model.withId (executionIndex)
65
65
66
66
val dependentModels = mutableSetOf<UtModel >()
67
67
collectRecursively(model, dependentModels)
68
68
69
69
dependentModels.forEach { model ->
70
- context.modelIds + = model to model.modelId (executionIndex)
70
+ context.modelIds + = model.withId (executionIndex)
71
71
}
72
72
73
73
return dependentModels
Original file line number Diff line number Diff line change @@ -18,19 +18,13 @@ class CgSpringVariableConstructor(context: CgContext) : CgVariableConstructor(co
18
18
override fun getOrCreateVariable (model : UtModel , name : String? ): CgValue {
19
19
val alreadyCreatedInjectMocks = findCgValueByModel(model, injectedMocksModelsVariables)
20
20
if (alreadyCreatedInjectMocks != null ) {
21
- if (model is UtCompositeModel ) {
22
- for (mock in model.fields.values) {
23
- getOrCreateVariable(mock )
24
- }
21
+ val fields : Collection < UtModel > = when (model ) {
22
+ is UtCompositeModel -> model.fields.values
23
+ is UtAssembleModel -> model.origin?.fields?.values ? : emptyList( )
24
+ else -> emptyList()
25
25
}
26
26
27
- if (model is UtAssembleModel ) {
28
- model.origin?.let { compositeModel ->
29
- for (mock in compositeModel.fields.values) {
30
- getOrCreateVariable(mock)
31
- }
32
- }
33
- }
27
+ fields.forEach { getOrCreateVariable(it) }
34
28
35
29
return alreadyCreatedInjectMocks
36
30
}
You can’t perform that action at this time.
0 commit comments