Fixed the way regex entries are generated for message bodies; fixes gh-858

This commit is contained in:
Marcin Grzejszczak
2019-01-22 09:14:08 +01:00
parent a2d6137340
commit 8ebc749d2f
5 changed files with 29 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ import java.util.regex.Pattern
import groovy.transform.CompileStatic
import groovy.transform.ToString
import repackaged.nl.flotsam.xeger.Xeger
/**
* Represents a property that may or may not be there
@@ -28,7 +29,7 @@ import groovy.transform.ToString
*/
@CompileStatic
@ToString(includePackage = false, includeNames = true)
class OptionalProperty implements Serializable {
class OptionalProperty implements Serializable, CanBeDynamic {
final Object value
OptionalProperty(Object value) {
@@ -56,4 +57,9 @@ class OptionalProperty implements Serializable {
String toString() {
return optionalPattern()
}
@Override
Object generateConcreteValue() {
return new Xeger(optionalPattern()).generate()
}
}

View File

@@ -33,7 +33,7 @@ import repackaged.nl.flotsam.xeger.Xeger
@TypeChecked
@EqualsAndHashCode
@ToString(includePackage = false, includeNames = true)
class RegexProperty extends DslProperty {
class RegexProperty extends DslProperty implements CanBeDynamic {
final Pattern pattern
private final Class clazz
@@ -169,4 +169,9 @@ class RegexProperty extends DslProperty {
String toString() {
return this.pattern()
}
@Override
Object generateConcreteValue() {
return generate()
}
}