From ebe06b4888f2e2560cc64e204fd1ba3b7f10b775 Mon Sep 17 00:00:00 2001 From: IlyaMuravjov Date: Tue, 25 Jul 2023 18:19:05 +0300 Subject: [PATCH] Replace `nullFuzzedValue` with primitive-aware `defaultFuzzedValue` --- .../kotlin/org/utbot/fuzzing/providers/Collections.kt | 2 +- .../main/kotlin/org/utbot/fuzzing/providers/Field.kt | 6 +++--- .../main/kotlin/org/utbot/fuzzing/providers/Objects.kt | 6 +++--- .../main/kotlin/org/utbot/fuzzing/providers/Utils.kt | 10 +++++----- .../kotlin/org/utbot/fuzzing/spring/SavedEntity.kt | 4 ++-- .../utbot/fuzzing/spring/SpringBeanValueProvider.kt | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Collections.kt b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Collections.kt index 51bda79661..7dad70c11c 100644 --- a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Collections.kt +++ b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Collections.kt @@ -70,7 +70,7 @@ class EmptyCollectionValueProvider( summary = "%var% = ${executableId.classId.simpleName}#${executableId.name}" } } else { - nullFuzzedValue(classId) + defaultFuzzedValue(classId) } }, )) diff --git a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Field.kt b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Field.kt index a97bd240d9..b211d3c6c7 100644 --- a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Field.kt +++ b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Field.kt @@ -39,10 +39,10 @@ class FieldValueProvider( val thisInstanceValue = values.single() val thisInstanceModel = when (val model = thisInstanceValue.model) { is UtReferenceModel -> model - is UtNullModel -> return@Create nullFuzzedValue(type.classId) + is UtNullModel -> return@Create defaultFuzzedValue(type.classId) else -> { logger.warn { "This instance model can be only UtReferenceModel or UtNullModel, but $model is met" } - return@Create nullFuzzedValue(type.classId) + return@Create defaultFuzzedValue(type.classId) } } UtAssembleModel( @@ -62,7 +62,7 @@ class FieldValueProvider( } }, modify = emptySequence(), - empty = nullRoutine(type.classId) + empty = defaultValueRoutine(type.classId) ) ) } \ No newline at end of file diff --git a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt index 77612897c9..5afa0ba6ad 100644 --- a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt +++ b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt @@ -101,7 +101,7 @@ class ObjectValueProvider( } } }, - empty = nullRoutine(classId) + empty = defaultValueRoutine(classId) ) } } @@ -127,7 +127,7 @@ object NullValueProvider : ValueProvider> { if (description.scope?.getProperty(NULLABLE_PROP) == true) { - yield(Seed.Simple(nullFuzzedValue(classClassId))) + yield(Seed.Simple(defaultFuzzedValue(classClassId))) } } } @@ -180,7 +180,7 @@ class AbstractsObjectValueProvider( construct = Routine.Create(listOf(toFuzzerType(concrete.id.jClass, description.typeCache))) { it.first() }, - empty = nullRoutine(type.classId) + empty = defaultValueRoutine(type.classId) )) } } diff --git a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Utils.kt b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Utils.kt index a6317ce518..01b6ae41e2 100644 --- a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Utils.kt +++ b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Utils.kt @@ -1,14 +1,14 @@ package org.utbot.fuzzing.providers import org.utbot.framework.plugin.api.ClassId -import org.utbot.framework.plugin.api.UtNullModel +import org.utbot.framework.plugin.api.util.defaultValueModel import org.utbot.fuzzer.FuzzedType import org.utbot.fuzzer.FuzzedValue import org.utbot.fuzzer.fuzzed import org.utbot.fuzzing.Routine -fun nullRoutine(classId: ClassId): Routine.Empty = - Routine.Empty { nullFuzzedValue(classId) } +fun defaultValueRoutine(classId: ClassId): Routine.Empty = + Routine.Empty { defaultFuzzedValue(classId) } -fun nullFuzzedValue(classId: ClassId): FuzzedValue = - UtNullModel(classId).fuzzed { summary = "%var% = null" } \ No newline at end of file +fun defaultFuzzedValue(classId: ClassId): FuzzedValue = + classId.defaultValueModel().fuzzed { summary = "%var% = $model" } \ No newline at end of file diff --git a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SavedEntity.kt b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SavedEntity.kt index 6032173afa..e10024099a 100644 --- a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SavedEntity.kt +++ b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SavedEntity.kt @@ -13,7 +13,7 @@ import org.utbot.fuzzing.FuzzedDescription import org.utbot.fuzzing.JavaValueProvider import org.utbot.fuzzing.Routine import org.utbot.fuzzing.Seed -import org.utbot.fuzzing.providers.nullRoutine +import org.utbot.fuzzing.providers.defaultValueRoutine import org.utbot.fuzzing.toFuzzerType class SavedEntityValueProvider( @@ -42,7 +42,7 @@ class SavedEntityValueProvider( } }, modify = emptySequence(), - empty = nullRoutine(type.classId) + empty = defaultValueRoutine(type.classId) ) ) } \ No newline at end of file diff --git a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SpringBeanValueProvider.kt b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SpringBeanValueProvider.kt index 7d659a8edd..d36642a901 100644 --- a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SpringBeanValueProvider.kt +++ b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/spring/SpringBeanValueProvider.kt @@ -9,7 +9,7 @@ import org.utbot.fuzzer.IdGenerator import org.utbot.fuzzer.fuzzed import org.utbot.fuzzing.* import org.utbot.fuzzing.providers.SPRING_BEAN_PROP -import org.utbot.fuzzing.providers.nullRoutine +import org.utbot.fuzzing.providers.defaultValueRoutine class SpringBeanValueProvider( private val idGenerator: IdGenerator, @@ -60,7 +60,7 @@ class SpringBeanValueProvider( }) } }, - empty = nullRoutine(type.classId) + empty = defaultValueRoutine(type.classId) ) ) }