Skip to content

Commit

Permalink
Fix generating empty String with @SiZe annotation (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongahjo authored Nov 15, 2024
1 parent 738893d commit ba84097
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/content/v1.0.x-kor/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ menu:
docs:
weight: 100
---
sectionStart
## v.1.0.29
Fix generating empty String with @Size annotation.

sectionEnd

sectionStart
## v.1.0.28
Add support for `hashCode`, `equals`, `toString` in anonymous object
Expand Down
6 changes: 6 additions & 0 deletions docs/content/v1.0.x/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ menu:
docs:
weight: 100
---
sectionStart
## v.1.0.29
Fix generating empty String with @Size annotation.

sectionEnd

sectionStart
## v.1.0.28
Add support for `hashCode`, `equals`, `toString` in anonymous object
Expand Down
12 changes: 12 additions & 0 deletions docs/content/v1.1.x-kor/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ menu:
docs:
weight: 100
---
sectionStart
## v.1.1.3
Fix generating empty String with @Size annotation.

sectionEnd

sectionStart
## v.1.1.2
Fix setting recursive implementations of self reference object.
Expand All @@ -21,6 +27,12 @@ Add a missing `giveMeJavaBuilder` with an object parameter.

sectionEnd

sectionStart
## v.1.0.29
Fix generating empty String with @Size annotation.

sectionEnd

sectionStart
## v.1.0.28
Add support for `hashCode`, `equals`, `toString` in anonymous object
Expand Down
12 changes: 12 additions & 0 deletions docs/content/v1.1.x/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ menu:
docs:
weight: 100
---
sectionStart
## v.1.1.3
Fix generating empty String with @Size annotation.

sectionEnd

sectionStart
## v.1.1.2
Fix setting recursive implementations of self reference object.
Expand All @@ -21,6 +27,12 @@ Add a missing `giveMeJavaBuilder` with an object parameter.

sectionEnd

sectionStart
## v.1.0.29
Fix generating empty String with @Size annotation.

sectionEnd

sectionStart
## v.1.0.28
Add support for `hashCode`, `equals`, `toString` in anonymous object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,12 @@ public Arbitrary<String> 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();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.navercorp.fixturemonkey.api.property.ConcreteTypeCandidateConcretePro
import com.navercorp.fixturemonkey.api.property.PropertyUtils
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
Expand Down Expand Up @@ -78,6 +79,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 {
Expand Down Expand Up @@ -1047,6 +1049,26 @@ class KotlinTest {
then(actual).isEqualTo(expected)
}

@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<StringWithSizeZero>().value

// then
then(actual).isEqualTo("")
}

companion object {
private val SUT: FixtureMonkey = FixtureMonkey.builder()
.plugin(KotlinPlugin())
Expand Down

0 comments on commit ba84097

Please sign in to comment.