Merge branch '2.1.x'
This commit is contained in:
@@ -44,14 +44,21 @@ public class OptionalProperty implements Serializable, CanBeDynamic {
|
||||
}
|
||||
|
||||
public String value() {
|
||||
if (this.value == null) {
|
||||
return valueToCheck(this.value).toString();
|
||||
}
|
||||
|
||||
private Object valueToCheck(Object value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
else if (this.value instanceof RegexProperty) {
|
||||
return ((RegexProperty) this.value).pattern();
|
||||
else if (value instanceof ClientDslProperty) {
|
||||
return valueToCheck(((ClientDslProperty) value).getClientValue());
|
||||
}
|
||||
else if (value instanceof RegexProperty || value instanceof Pattern) {
|
||||
return new RegexProperty(value).pattern();
|
||||
}
|
||||
else {
|
||||
return this.value.toString();
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -464,4 +464,23 @@ then:
|
||||
then:
|
||||
thrown(IllegalStateException)
|
||||
}
|
||||
|
||||
@Issue("1215")
|
||||
def 'should work fine when dealing with anyOf'() {
|
||||
when:
|
||||
Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url '/any'
|
||||
body (
|
||||
foo: $(consumer(optional(anyOf('WORKS','MIGHTY', 'DESPAIR'))), producer('DESPAIR'))
|
||||
)
|
||||
}
|
||||
response {
|
||||
status OK()
|
||||
}
|
||||
}
|
||||
then:
|
||||
noExceptionThrown()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user