@@ -13,7 +13,7 @@ import org.utbot.framework.context.ConcreteExecutionContext
13
13
import org.utbot.framework.context.NonNullSpeculator
14
14
import org.utbot.framework.context.TypeReplacer
15
15
import org.utbot.framework.context.custom.CoverageFilteringConcreteExecutionContext
16
- import org.utbot.framework.context.custom.allowMocks
16
+ import org.utbot.framework.context.custom.useMocks
17
17
import org.utbot.framework.context.utils.transformJavaFuzzingContext
18
18
import org.utbot.framework.context.utils.transformValueProvider
19
19
import org.utbot.framework.plugin.api.BeanDefinitionData
@@ -26,10 +26,11 @@ import org.utbot.framework.plugin.api.util.allSuperTypes
26
26
import org.utbot.framework.plugin.api.util.id
27
27
import org.utbot.framework.plugin.api.util.jClass
28
28
import org.utbot.framework.plugin.api.util.utContext
29
+ import org.utbot.fuzzing.spring.FuzzedTypeFlag
29
30
import org.utbot.fuzzing.spring.addProperties
30
31
import org.utbot.fuzzing.spring.decorators.replaceTypes
32
+ import org.utbot.fuzzing.spring.properties
31
33
import org.utbot.fuzzing.spring.unit.InjectMockValueProvider
32
- import org.utbot.fuzzing.spring.unit.NeverMockFlag
33
34
import org.utbot.fuzzing.toFuzzerType
34
35
35
36
class SpringApplicationContextImpl (
@@ -42,6 +43,8 @@ class SpringApplicationContextImpl(
42
43
private val logger = KotlinLogging .logger {}
43
44
}
44
45
46
+ private object ReplacedFuzzedTypeFlag : FuzzedTypeFlag
47
+
45
48
override val typeReplacer: TypeReplacer = SpringTypeReplacer (delegateContext.typeReplacer, this )
46
49
override val nonNullSpeculator: NonNullSpeculator = SpringNonNullSpeculator (delegateContext.nonNullSpeculator, this )
47
50
@@ -70,7 +73,13 @@ class SpringApplicationContextImpl(
70
73
return when (springTestType) {
71
74
SpringTestType .UNIT_TEST -> delegateConcreteExecutionContext.transformJavaFuzzingContext { fuzzingContext ->
72
75
fuzzingContext
73
- .allowMocks()
76
+ .useMocks { type ->
77
+ ReplacedFuzzedTypeFlag !in type.properties &&
78
+ fuzzingContext.mockStrategy.eligibleToMock(
79
+ classToMock = type.classId,
80
+ classUnderTest = fuzzingContext.classUnderTest
81
+ )
82
+ }
74
83
.transformValueProvider { origValueProvider ->
75
84
InjectMockValueProvider (
76
85
idGenerator = fuzzingContext.idGenerator,
@@ -83,7 +92,7 @@ class SpringApplicationContextImpl(
83
92
?.let { replacement ->
84
93
// TODO infer generic type of replacement
85
94
toFuzzerType(replacement.jClass, description.typeCache).addProperties(
86
- dynamicPropertiesOf(NeverMockFlag .withValue(Unit ))
95
+ dynamicPropertiesOf(ReplacedFuzzedTypeFlag .withValue(Unit ))
87
96
)
88
97
} ? : type
89
98
}
0 commit comments