1
1
package org.utbot.framework.context.spring
2
2
3
3
import mu.KotlinLogging
4
+ import org.utbot.common.dynamicPropertiesOf
4
5
import org.utbot.common.isAbstract
5
6
import org.utbot.common.isStatic
7
+ import org.utbot.common.withValue
6
8
import org.utbot.framework.codegen.generator.AbstractCodeGenerator
7
9
import org.utbot.framework.codegen.generator.CodeGeneratorParams
8
10
import org.utbot.framework.codegen.generator.SpringCodeGenerator
@@ -25,8 +27,10 @@ import org.utbot.framework.plugin.api.util.allSuperTypes
25
27
import org.utbot.framework.plugin.api.util.id
26
28
import org.utbot.framework.plugin.api.util.jClass
27
29
import org.utbot.framework.plugin.api.util.utContext
30
+ import org.utbot.fuzzing.spring.addProperties
28
31
import org.utbot.fuzzing.spring.decorators.replaceTypes
29
32
import org.utbot.fuzzing.spring.unit.InjectMockValueProvider
33
+ import org.utbot.fuzzing.spring.unit.NeverMockFlag
30
34
import org.utbot.fuzzing.toFuzzerType
31
35
32
36
class SpringApplicationContextImpl (
@@ -75,10 +79,14 @@ class SpringApplicationContextImpl(
75
79
)
76
80
.withFallback(origValueProvider)
77
81
.replaceTypes { description, type ->
78
- typeReplacer.replaceTypeIfNeeded(type.classId)?.let { replacement ->
79
- // TODO infer generic type
80
- toFuzzerType(replacement.jClass, description.typeCache)
81
- } ? : type
82
+ typeReplacer.replaceTypeIfNeeded(type.classId)
83
+ ?.takeIf { it != type.classId }
84
+ ?.let { replacement ->
85
+ // TODO infer generic type of replacement
86
+ toFuzzerType(replacement.jClass, description.typeCache).addProperties(
87
+ dynamicPropertiesOf(NeverMockFlag .withValue(Unit ))
88
+ )
89
+ } ? : type
82
90
}
83
91
}
84
92
}
0 commit comments