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