@@ -57,6 +57,8 @@ import kotlin.contracts.contract
57
57
import org.utbot.common.isAbstract
58
58
import org.utbot.framework.plugin.api.mapper.UtModelMapper
59
59
import 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
60
62
import org.utbot.framework.plugin.api.mapper.mapPreservingType
61
63
import org.utbot.framework.plugin.api.util.SpringModelUtils
62
64
import org.utbot.framework.process.OpenModulesContainer
@@ -73,6 +75,11 @@ data class UtMethodTestSet(
73
75
val clustersInfo : List <Pair <UtClusterInfo ?, IntRange >> = listOf(null to executions.indices)
74
76
)
75
77
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
+
76
83
data class Step (
77
84
val stmt : Stmt ,
78
85
val depth : Int ,
@@ -145,11 +152,70 @@ abstract class UtExecution(
145
152
displayName : String? = this.displayName,
146
153
): UtExecution
147
154
155
+ open fun mapModels (mapper : UtModelMapper ) = copy(
156
+ stateBefore = stateBefore.mapModels(mapper),
157
+ stateAfter = stateAfter.mapModels(mapper),
158
+ result = result.mapModelIfExists(mapper)
159
+ )
160
+
148
161
val executableToCall get() = stateBefore.executableToCall
149
162
}
150
163
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
+ )
153
219
}
154
220
155
221
/* *
@@ -167,15 +233,24 @@ class UtSymbolicExecution(
167
233
stateBefore : EnvironmentModels ,
168
234
stateAfter : EnvironmentModels ,
169
235
result : UtExecutionResult ,
170
- override val instrumentation : List <UtInstrumentation >,
236
+ instrumentation : List <UtInstrumentation >,
171
237
val path : MutableList <Step >,
172
238
val fullPath : List <Step >,
173
239
coverage : Coverage ? = null ,
174
240
summary : List <DocStatement >? = null ,
175
241
testMethodName : String? = null ,
176
242
displayName : String? = null ,
177
243
/* * 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
+ ) {
179
254
/* *
180
255
* By design the 'before' and 'after' states contain info about the same fields.
181
256
* 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(
193
268
coverage : Coverage ? ,
194
269
summary : List <DocStatement >? ,
195
270
testMethodName : String? ,
196
- displayName : String?
271
+ displayName : String? ,
272
+ instrumentation : List <UtInstrumentation >,
197
273
): UtExecution = UtSymbolicExecution (
198
274
stateBefore = stateBefore,
199
275
stateAfter = stateAfter,
@@ -1369,19 +1445,49 @@ class BuiltinMethodId(
1369
1445
name : String ,
1370
1446
returnType : ClassId ,
1371
1447
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 ,
1378
1450
) : 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
+ )
1385
1491
}
1386
1492
1387
1493
class BuiltinConstructorId (
0 commit comments