@@ -9,6 +9,7 @@ import org.utbot.framework.plugin.api.UtAssembleModel
99import org.utbot.framework.plugin.api.UtNullModel
1010import org.utbot.framework.plugin.api.UtPrimitiveModel
1111import org.utbot.framework.plugin.api.util.*
12+ import org.utbot.framework.plugin.api.util.constructor.ValueConstructor
1213import org.utbot.fuzzer.FuzzedConcreteValue
1314import org.utbot.fuzzing.samples.DeepNested
1415import org.utbot.fuzzer.FuzzedType
@@ -17,13 +18,15 @@ import org.utbot.fuzzer.IdentityPreservingIdGenerator
1718import org.utbot.fuzzing.providers.NullValueProvider
1819import org.utbot.fuzzing.samples.AccessibleObjects
1920import org.utbot.fuzzing.samples.FailToGenerateListGeneric
21+ import org.utbot.fuzzing.samples.StringListHolder
2022import org.utbot.fuzzing.samples.Stubs
2123import org.utbot.fuzzing.utils.Trie
2224import java.lang.reflect.GenericArrayType
2325import java.lang.reflect.ParameterizedType
2426import java.lang.reflect.Type
2527import java.util.IdentityHashMap
2628import java.util.concurrent.atomic.AtomicInteger
29+ import kotlin.reflect.jvm.javaMethod
2730
2831internal object TestIdentityPreservingIdGenerator : IdentityPreservingIdGenerator<Int> {
2932 private val cache = mutableMapOf<Any , Int >()
@@ -273,6 +276,31 @@ class JavaFuzzingTest {
273276 }
274277 }
275278
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+
276304 @Test
277305 fun `value providers override every function of fuzzing in simple case` () {
278306 val provided = MarkerValueProvider <FuzzedType , FuzzedValue , FuzzedDescription >(" p" )
0 commit comments