11package org.utbot.framework.context.spring
22
33import mu.KotlinLogging
4+ import org.utbot.common.dynamicPropertiesOf
45import org.utbot.common.isAbstract
56import org.utbot.common.isStatic
7+ import org.utbot.common.withValue
68import org.utbot.framework.codegen.generator.AbstractCodeGenerator
79import org.utbot.framework.codegen.generator.CodeGeneratorParams
810import org.utbot.framework.codegen.generator.SpringCodeGenerator
@@ -25,8 +27,10 @@ import org.utbot.framework.plugin.api.util.allSuperTypes
2527import org.utbot.framework.plugin.api.util.id
2628import org.utbot.framework.plugin.api.util.jClass
2729import org.utbot.framework.plugin.api.util.utContext
30+ import org.utbot.fuzzing.spring.addProperties
2831import org.utbot.fuzzing.spring.decorators.replaceTypes
2932import org.utbot.fuzzing.spring.unit.InjectMockValueProvider
33+ import org.utbot.fuzzing.spring.unit.NeverMockFlag
3034import org.utbot.fuzzing.toFuzzerType
3135
3236class SpringApplicationContextImpl (
@@ -75,10 +79,14 @@ class SpringApplicationContextImpl(
7579 )
7680 .withFallback(origValueProvider)
7781 .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
8290 }
8391 }
8492 }
0 commit comments