@@ -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,
@@ -1369,19 +1445,49 @@ class BuiltinMethodId(
13691445 name : String ,
13701446 returnType : ClassId ,
13711447 parameters : List <ClassId >,
1372- bypassesSandbox : Boolean = false ,
1373- // by default we assume that the builtin method is non-static and public
1374- isStatic : Boolean = false ,
1375- isPublic : Boolean = true ,
1376- isProtected : Boolean = false ,
1377- isPrivate : Boolean = false
1448+ bypassesSandbox : Boolean ,
1449+ override val modifiers : Int ,
13781450) : MethodId(classId, name, returnType, parameters, bypassesSandbox) {
1379- override val modifiers: Int = ModifierFactory {
1380- static = isStatic
1381- public = isPublic
1382- private = isPrivate
1383- protected = isProtected
1384- }
1451+ constructor (
1452+ classId: ClassId ,
1453+ name: String ,
1454+ returnType: ClassId ,
1455+ parameters: List <ClassId >,
1456+ bypassesSandbox: Boolean = false ,
1457+ // by default, we assume that the builtin method is non-static and public
1458+ isStatic: Boolean = false ,
1459+ isPublic: Boolean = true ,
1460+ isProtected: Boolean = false ,
1461+ isPrivate: Boolean = false
1462+ ) : this (
1463+ classId = classId,
1464+ name = name,
1465+ returnType = returnType,
1466+ parameters = parameters,
1467+ bypassesSandbox = bypassesSandbox,
1468+ modifiers = ModifierFactory {
1469+ static = isStatic
1470+ public = isPublic
1471+ private = isPrivate
1472+ protected = isProtected
1473+ }
1474+ )
1475+
1476+ fun copy (
1477+ classId : ClassId = this.classId,
1478+ name : String = this.name,
1479+ returnType : ClassId = this.returnType,
1480+ parameters : List <ClassId > = this.parameters,
1481+ bypassesSandbox : Boolean = this.bypassesSandbox,
1482+ modifiers : Int = this.modifiers,
1483+ ) = BuiltinMethodId (
1484+ classId = classId,
1485+ name = name,
1486+ returnType = returnType,
1487+ parameters = parameters,
1488+ bypassesSandbox = bypassesSandbox,
1489+ modifiers = modifiers,
1490+ )
13851491}
13861492
13871493class BuiltinConstructorId (
0 commit comments