@@ -57,6 +57,8 @@ import kotlin.contracts.contract
5757import org.utbot.common.isAbstract
5858import org.utbot.framework.plugin.api.mapper.UtModelMapper
5959import org.utbot.framework.plugin.api.mapper.map
60+ import org.utbot.framework.plugin.api.mapper.mapModelIfExists
61+ import org.utbot.framework.plugin.api.mapper.mapModels
6062import org.utbot.framework.plugin.api.mapper.mapPreservingType
6163import org.utbot.framework.plugin.api.util.SpringModelUtils
6264import org.utbot.framework.process.OpenModulesContainer
@@ -73,6 +75,11 @@ data class UtMethodTestSet(
7375 val clustersInfo : List <Pair <UtClusterInfo ?, IntRange >> = listOf(null to executions.indices)
7476)
7577
78+ fun UtMethodTestSet.mapModels (mapper : UtModelMapper ): UtMethodTestSet =
79+ copy(executions = executions.map { it.mapModels(mapper) })
80+
81+ fun Collection<UtMethodTestSet>.mapModels (mapper : UtModelMapper ) = map { it.mapModels(mapper) }
82+
7683data class Step (
7784 val stmt : Stmt ,
7885 val depth : Int ,
@@ -145,11 +152,70 @@ abstract class UtExecution(
145152 displayName : String? = this.displayName,
146153 ): UtExecution
147154
155+ open fun mapModels (mapper : UtModelMapper ) = copy(
156+ stateBefore = stateBefore.mapModels(mapper),
157+ stateAfter = stateAfter.mapModels(mapper),
158+ result = result.mapModelIfExists(mapper)
159+ )
160+
148161 val executableToCall get() = stateBefore.executableToCall
149162}
150163
151- interface UtExecutionWithInstrumentation {
152- val instrumentation: List <UtInstrumentation >
164+ abstract class UtExecutionWithInstrumentation (
165+ stateBefore : EnvironmentModels ,
166+ stateAfter : EnvironmentModels ,
167+ result : UtExecutionResult ,
168+ coverage : Coverage ? = null ,
169+ summary : List <DocStatement >? = null ,
170+ testMethodName : String? = null ,
171+ displayName : String? = null ,
172+ val instrumentation : List <UtInstrumentation >,
173+ ) : UtExecution(
174+ stateBefore = stateBefore,
175+ stateAfter = stateAfter,
176+ result = result,
177+ coverage = coverage,
178+ summary = summary,
179+ testMethodName = testMethodName,
180+ displayName = displayName,
181+ ) {
182+ abstract fun copy (
183+ stateBefore : EnvironmentModels = this.stateBefore,
184+ stateAfter : EnvironmentModels = this.stateAfter,
185+ result : UtExecutionResult = this.result,
186+ coverage : Coverage ? = this.coverage,
187+ summary : List <DocStatement >? = this.summary,
188+ testMethodName : String? = this.testMethodName,
189+ displayName : String? = this.displayName,
190+ instrumentation : List <UtInstrumentation > = this.instrumentation,
191+ ): UtExecution
192+
193+ override fun copy (
194+ stateBefore : EnvironmentModels ,
195+ stateAfter : EnvironmentModels ,
196+ result : UtExecutionResult ,
197+ coverage : Coverage ? ,
198+ summary : List <DocStatement >? ,
199+ testMethodName : String? ,
200+ displayName : String? ,
201+ ): UtExecution = copy(
202+ stateBefore = stateBefore,
203+ stateAfter = stateAfter,
204+ result = result,
205+ instrumentation = instrumentation,
206+ coverage = coverage,
207+ summary = summary,
208+ testMethodName = testMethodName,
209+ displayName = displayName,
210+ )
211+
212+ override fun mapModels (mapper : UtModelMapper ): UtExecution =
213+ copy(
214+ stateBefore = stateBefore.mapModels(mapper),
215+ stateAfter = stateAfter.mapModels(mapper),
216+ result = result.mapModelIfExists(mapper),
217+ instrumentation = instrumentation.map { it.mapModels(mapper) },
218+ )
153219}
154220
155221/* *
@@ -167,15 +233,24 @@ class UtSymbolicExecution(
167233 stateBefore : EnvironmentModels ,
168234 stateAfter : EnvironmentModels ,
169235 result : UtExecutionResult ,
170- override val instrumentation : List <UtInstrumentation >,
236+ instrumentation : List <UtInstrumentation >,
171237 val path : MutableList <Step >,
172238 val fullPath : List <Step >,
173239 coverage : Coverage ? = null ,
174240 summary : List <DocStatement >? = null ,
175241 testMethodName : String? = null ,
176242 displayName : String? = null ,
177243 /* * Convenient view of the full symbolic path */ val symbolicSteps : List <SymbolicStep > = listOf(),
178- ) : UtExecution(stateBefore, stateAfter, result, coverage, summary, testMethodName, displayName), UtExecutionWithInstrumentation {
244+ ) : UtExecutionWithInstrumentation(
245+ stateBefore,
246+ stateAfter,
247+ result,
248+ coverage,
249+ summary,
250+ testMethodName,
251+ displayName,
252+ instrumentation
253+ ) {
179254 /* *
180255 * By design the 'before' and 'after' states contain info about the same fields.
181256 * It means that it is not possible for a field to be present at 'before' and to be absent at 'after'.
@@ -193,7 +268,8 @@ class UtSymbolicExecution(
193268 coverage : Coverage ? ,
194269 summary : List <DocStatement >? ,
195270 testMethodName : String? ,
196- displayName : String?
271+ displayName : String? ,
272+ instrumentation : List <UtInstrumentation >,
197273 ): UtExecution = UtSymbolicExecution (
198274 stateBefore = stateBefore,
199275 stateAfter = stateAfter,
@@ -1356,19 +1432,49 @@ class BuiltinMethodId(
13561432 name : String ,
13571433 returnType : ClassId ,
13581434 parameters : List <ClassId >,
1359- bypassesSandbox : Boolean = false ,
1360- // by default we assume that the builtin method is non-static and public
1361- isStatic : Boolean = false ,
1362- isPublic : Boolean = true ,
1363- isProtected : Boolean = false ,
1364- isPrivate : Boolean = false
1435+ bypassesSandbox : Boolean ,
1436+ override val modifiers : Int ,
13651437) : MethodId(classId, name, returnType, parameters, bypassesSandbox) {
1366- override val modifiers: Int = ModifierFactory {
1367- static = isStatic
1368- public = isPublic
1369- private = isPrivate
1370- protected = isProtected
1371- }
1438+ constructor (
1439+ classId: ClassId ,
1440+ name: String ,
1441+ returnType: ClassId ,
1442+ parameters: List <ClassId >,
1443+ bypassesSandbox: Boolean = false ,
1444+ // by default, we assume that the builtin method is non-static and public
1445+ isStatic: Boolean = false ,
1446+ isPublic: Boolean = true ,
1447+ isProtected: Boolean = false ,
1448+ isPrivate: Boolean = false
1449+ ) : this (
1450+ classId = classId,
1451+ name = name,
1452+ returnType = returnType,
1453+ parameters = parameters,
1454+ bypassesSandbox = bypassesSandbox,
1455+ modifiers = ModifierFactory {
1456+ static = isStatic
1457+ public = isPublic
1458+ private = isPrivate
1459+ protected = isProtected
1460+ }
1461+ )
1462+
1463+ fun copy (
1464+ classId : ClassId = this.classId,
1465+ name : String = this.name,
1466+ returnType : ClassId = this.returnType,
1467+ parameters : List <ClassId > = this.parameters,
1468+ bypassesSandbox : Boolean = this.bypassesSandbox,
1469+ modifiers : Int = this.modifiers,
1470+ ) = BuiltinMethodId (
1471+ classId = classId,
1472+ name = name,
1473+ returnType = returnType,
1474+ parameters = parameters,
1475+ bypassesSandbox = bypassesSandbox,
1476+ modifiers = modifiers,
1477+ )
13721478}
13731479
13741480class BuiltinConstructorId (
0 commit comments