1
1
package org.utbot.framework.codegen.domain.models.builders
2
2
3
+ import org.utbot.framework.codegen.domain.ModelId
3
4
import org.utbot.framework.codegen.domain.context.CgContext
4
5
import org.utbot.framework.codegen.domain.models.CgMethodTestSet
5
6
import org.utbot.framework.codegen.domain.models.ClassModels
6
7
import org.utbot.framework.codegen.domain.models.SpringTestClassModel
7
- import org.utbot.framework.codegen.domain.withExecutionId
8
8
import org.utbot.framework.plugin.api.ClassId
9
9
import org.utbot.framework.plugin.api.UtArrayModel
10
10
import org.utbot.framework.plugin.api.UtAssembleModel
@@ -39,17 +39,15 @@ class SpringTestClassModelBuilder(val context: CgContext): TestClassModelBuilder
39
39
val thisInstances = mutableSetOf<UtModel >()
40
40
val thisInstancesDependentModels = mutableSetOf<UtModel >()
41
41
42
- for (testSet in testSets) {
43
- for ((index, execution) in testSet.executions.withIndex()) {
44
- execution.stateBefore.thisInstance?.let { model ->
45
- thisInstances + = model
46
- thisInstancesDependentModels + = collectByThisInstanceModel(model, index)
47
- }
42
+ for ((testSetIndex, testSet) in testSets.withIndex()) {
43
+ for ((executionIndex, execution) in testSet.executions.withIndex()) {
48
44
49
- execution.stateAfter.thisInstance?.let { model ->
50
- thisInstances + = model
51
- thisInstancesDependentModels + = collectByThisInstanceModel(model, index)
52
- }
45
+ setOf (execution.stateBefore.thisInstance, execution.stateAfter.thisInstance)
46
+ .filterNotNull()
47
+ .forEach { model ->
48
+ thisInstances + = model
49
+ thisInstancesDependentModels + = collectByThisInstanceModel(model, executionIndex, testSetIndex)
50
+ }
53
51
}
54
52
}
55
53
@@ -59,14 +57,14 @@ class SpringTestClassModelBuilder(val context: CgContext): TestClassModelBuilder
59
57
return thisInstances.groupByClassId() to dependentMockModels.groupByClassId()
60
58
}
61
59
62
- private fun collectByThisInstanceModel (model : UtModel , executionIndex : Int ): Set <UtModel > {
63
- context.modelIds[model] = model.withExecutionId( executionIndex)
60
+ private fun collectByThisInstanceModel (model : UtModel , executionIndex : Int , testSetIndex : Int ): Set <UtModel > {
61
+ context.modelIds[model] = ModelId .create(model, executionIndex, testSetIndex )
64
62
65
63
val dependentModels = mutableSetOf<UtModel >()
66
64
collectRecursively(model, dependentModels)
67
65
68
66
dependentModels.forEach { model ->
69
- context.modelIds[model] = model.withExecutionId( executionIndex)
67
+ context.modelIds[model] = ModelId .create(model, executionIndex, testSetIndex )
70
68
}
71
69
72
70
return dependentModels
0 commit comments