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
@@ -24,8 +26,10 @@ import org.utbot.framework.plugin.api.util.allSuperTypes
24
26
import org.utbot.framework.plugin.api.util.id
25
27
import org.utbot.framework.plugin.api.util.jClass
26
28
import org.utbot.framework.plugin.api.util.utContext
29
+ import org.utbot.fuzzing.spring.addProperties
27
30
import org.utbot.fuzzing.spring.decorators.replaceTypes
28
31
import org.utbot.fuzzing.spring.unit.InjectMockValueProvider
32
+ import org.utbot.fuzzing.spring.unit.NeverMockFlag
29
33
import org.utbot.fuzzing.toFuzzerType
30
34
31
35
class SpringApplicationContextImpl (
@@ -74,10 +78,14 @@ class SpringApplicationContextImpl(
74
78
)
75
79
.withFallback(origValueProvider)
76
80
.replaceTypes { description, type ->
77
- typeReplacer.replaceTypeIfNeeded(type.classId)?.let { replacement ->
78
- // TODO infer generic type
79
- toFuzzerType(replacement.jClass, description.typeCache)
80
- } ? : type
81
+ typeReplacer.replaceTypeIfNeeded(type.classId)
82
+ ?.takeIf { it != type.classId }
83
+ ?.let { replacement ->
84
+ // TODO infer generic type of replacement
85
+ toFuzzerType(replacement.jClass, description.typeCache).addProperties(
86
+ dynamicPropertiesOf(NeverMockFlag .withValue(Unit ))
87
+ )
88
+ } ? : type
81
89
}
82
90
}
83
91
}
0 commit comments