@@ -9,6 +9,7 @@ import org.utbot.framework.plugin.api.UtAssembleModel
9
9
import org.utbot.framework.plugin.api.UtNullModel
10
10
import org.utbot.framework.plugin.api.UtPrimitiveModel
11
11
import org.utbot.framework.plugin.api.util.*
12
+ import org.utbot.framework.plugin.api.util.constructor.ValueConstructor
12
13
import org.utbot.fuzzer.FuzzedConcreteValue
13
14
import org.utbot.fuzzing.samples.DeepNested
14
15
import org.utbot.fuzzer.FuzzedType
@@ -17,13 +18,15 @@ import org.utbot.fuzzer.IdentityPreservingIdGenerator
17
18
import org.utbot.fuzzing.providers.NullValueProvider
18
19
import org.utbot.fuzzing.samples.AccessibleObjects
19
20
import org.utbot.fuzzing.samples.FailToGenerateListGeneric
21
+ import org.utbot.fuzzing.samples.StringListHolder
20
22
import org.utbot.fuzzing.samples.Stubs
21
23
import org.utbot.fuzzing.utils.Trie
22
24
import java.lang.reflect.GenericArrayType
23
25
import java.lang.reflect.ParameterizedType
24
26
import java.lang.reflect.Type
25
27
import java.util.IdentityHashMap
26
28
import java.util.concurrent.atomic.AtomicInteger
29
+ import kotlin.reflect.jvm.javaMethod
27
30
28
31
internal object TestIdentityPreservingIdGenerator : IdentityPreservingIdGenerator<Int> {
29
32
private val cache = mutableMapOf<Any , Int >()
@@ -273,6 +276,31 @@ class JavaFuzzingTest {
273
276
}
274
277
}
275
278
279
+ @Test
280
+ fun `fuzzer correctly works with settable field that has a parameterized type` () {
281
+ val seenStringListHolders = mutableListOf<StringListHolder >()
282
+ var remainingRuns = 100
283
+ runBlockingWithContext {
284
+ runJavaFuzzing(
285
+ TestIdentityPreservingIdGenerator ,
286
+ methodUnderTest = StringListHolder ::methodUnderTest.javaMethod!! .executableId,
287
+ constants = emptyList(),
288
+ names = emptyList(),
289
+ ) { thisInstance, _, _ ->
290
+ thisInstance?.let {
291
+ seenStringListHolders.add(
292
+ ValueConstructor ().construct(listOf (it.model)).single().value as StringListHolder
293
+ )
294
+ }
295
+ remainingRuns--
296
+ BaseFeedback (Trie .emptyNode(), if (remainingRuns > 0 ) Control .CONTINUE else Control .STOP )
297
+ }
298
+ }
299
+ val seenStrings = seenStringListHolders.flatMap { it.strings.orEmpty().filterNotNull() }
300
+ assertNotEquals(emptyList<String >(), seenStrings)
301
+ seenStrings.forEach { assertInstanceOf(String ::class .java, it) }
302
+ }
303
+
276
304
@Test
277
305
fun `value providers override every function of fuzzing in simple case` () {
278
306
val provided = MarkerValueProvider <FuzzedType , FuzzedValue , FuzzedDescription >(" p" )
0 commit comments