diff --git a/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/jqwik/JqwikJavaArbitraryResolver.java b/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/jqwik/JqwikJavaArbitraryResolver.java index fc251eb54..d808da8c8 100644 --- a/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/jqwik/JqwikJavaArbitraryResolver.java +++ b/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/jqwik/JqwikJavaArbitraryResolver.java @@ -116,16 +116,12 @@ public Arbitrary strings( return arbitrary .filter(it -> { if (!notBlank) { - if (it == null) { + if (it == null || it.isEmpty()) { return true; } } - if (it == null || it.trim().isEmpty()) { - return false; - } - - return true; + return it != null && !it.trim().isEmpty(); }); } diff --git a/fixture-monkey-tests/kotlin-tests/src/test/kotlin/com/navercorp/fixturemonkey/tests/kotlin/KotlinTest.kt b/fixture-monkey-tests/kotlin-tests/src/test/kotlin/com/navercorp/fixturemonkey/tests/kotlin/KotlinTest.kt index 4e806dc3f..fa2e9b13a 100644 --- a/fixture-monkey-tests/kotlin-tests/src/test/kotlin/com/navercorp/fixturemonkey/tests/kotlin/KotlinTest.kt +++ b/fixture-monkey-tests/kotlin-tests/src/test/kotlin/com/navercorp/fixturemonkey/tests/kotlin/KotlinTest.kt @@ -40,6 +40,7 @@ import com.navercorp.fixturemonkey.api.property.PropertyUtils import com.navercorp.fixturemonkey.api.type.Types import com.navercorp.fixturemonkey.api.type.Types.GeneratingWildcardType import com.navercorp.fixturemonkey.customizer.Values +import com.navercorp.fixturemonkey.javax.validation.plugin.JavaxValidationPlugin import com.navercorp.fixturemonkey.kotlin.KotlinPlugin import com.navercorp.fixturemonkey.kotlin.expression.root import com.navercorp.fixturemonkey.kotlin.get @@ -79,6 +80,7 @@ import java.time.temporal.ChronoUnit import java.util.LinkedList import java.util.TreeSet import java.util.UUID +import javax.validation.constraints.Size import kotlin.reflect.jvm.javaMethod class KotlinTest { @@ -971,6 +973,26 @@ class KotlinTest { then(actual).isInstanceOf(SecondConcreteClass::class.java) } + @Test + fun sizeZero(){ + // given + class StringWithSizeZero( + @field:Size(min = 0, max = 0) + val value: String, + ) + + val sut = FixtureMonkey.builder() + .plugin(KotlinPlugin()) + .plugin(JavaxValidationPlugin()) + .build() + + // when + val actual = sut.giveMeOne().value + + // then + then(actual).isEqualTo("") + } + companion object { private val SUT: FixtureMonkey = FixtureMonkey.builder() .plugin(KotlinPlugin())