@@ -34,17 +34,21 @@ import org.usvm.instrumentation.testcase.api.UTestShortExpression
34
34
import org.usvm.instrumentation.testcase.api.UTestStaticMethodCall
35
35
import org.usvm.instrumentation.testcase.api.UTestStringExpression
36
36
import org.utbot.framework.codegen.domain.builtin.UtilMethodProvider
37
+ import org.utbot.framework.plugin.api.ConstructorId
37
38
import org.utbot.framework.plugin.api.ExecutableId
38
39
import org.utbot.framework.plugin.api.FieldId
40
+ import org.utbot.framework.plugin.api.MethodId
39
41
import org.utbot.framework.plugin.api.UtArrayModel
40
42
import org.utbot.framework.plugin.api.UtAssembleModel
41
43
import org.utbot.framework.plugin.api.UtClassRefModel
42
44
import org.utbot.framework.plugin.api.UtCompositeModel
43
45
import org.utbot.framework.plugin.api.UtExecutableCallModel
44
46
import org.utbot.framework.plugin.api.UtInstrumentation
45
47
import org.utbot.framework.plugin.api.UtModel
48
+ import org.utbot.framework.plugin.api.UtNewInstanceInstrumentation
46
49
import org.utbot.framework.plugin.api.UtNullModel
47
50
import org.utbot.framework.plugin.api.UtPrimitiveModel
51
+ import org.utbot.framework.plugin.api.UtStaticMethodInstrumentation
48
52
import org.utbot.framework.plugin.api.util.classClassId
49
53
import org.utbot.framework.plugin.api.util.objectClassId
50
54
import org.utbot.fuzzer.IdGenerator
@@ -71,6 +75,8 @@ class UTestInstToUtModelConverter(
71
75
return alreadyCreatedModel
72
76
}
73
77
78
+ fun findInstrumentations (): List <UtInstrumentation > = instrumentations
79
+
74
80
private fun removeInstantiationCallFromThisInstanceModificationChain (model : UtModel ) {
75
81
if (model is UtAssembleModel ) {
76
82
val instantiationCall = model.instantiationCall
@@ -301,7 +307,36 @@ class UTestInstToUtModelConverter(
301
307
}
302
308
303
309
is UTestGlobalMock -> {
304
- // TODO usvm-sbft: collect instrumentations here
310
+ // Daniil said that we can miss [type] and [fields] when converting to [UtInstrumentation]
311
+ val methodsToExprs = uTestExpr.methods.entries
312
+
313
+ methodsToExprs
314
+ .filter { it.key is MethodId }
315
+ .forEach { (jcMethod, uTestExprs) ->
316
+ val methodId = jcMethod.toExecutableId(jcClasspath) as MethodId
317
+ val valueModels = uTestExprs.map { expr -> processExpr(expr) }
318
+ val methodInstrumentation = UtStaticMethodInstrumentation (
319
+ methodId = methodId,
320
+ values = valueModels,
321
+ )
322
+
323
+ instrumentations + = methodInstrumentation
324
+ }
325
+
326
+ methodsToExprs
327
+ .filter { it.key is ConstructorId }
328
+ .forEach { (jcMethod, uTestExprs) ->
329
+ val valueModels = uTestExprs.map { expr -> processExpr(expr) }
330
+ val methodInstrumentation = UtNewInstanceInstrumentation (
331
+ // TODO usvm-sbft looking at [Traverser] ln 1682, this classId does not seem correct
332
+ classId = jcMethod.enclosingClass.classId,
333
+ instances = valueModels,
334
+ callSites = setOf (jcMethod.enclosingClass.classId),
335
+ )
336
+
337
+ instrumentations + = methodInstrumentation
338
+ }
339
+
305
340
// UtClassRefModel is returned here for consistency with [Descriptor2ValueConverter]
306
341
// which returns Class<*> instance for [UTestGlobalMock] descriptors.
307
342
UtClassRefModel (
0 commit comments