Merge branch '2.1.x'

This commit is contained in:
Marcin Grzejszczak
2019-11-08 15:05:01 +01:00
2 changed files with 30 additions and 4 deletions

View File

@@ -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();
}
}

View File

@@ -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()
}
}