Added the missing $() convenience method for messaging contracts (#623)
Fixes gh-619
This commit is contained in:
committed by
Marcin Grzejszczak
parent
f64feaf84d
commit
4cf6e199b9
@@ -95,6 +95,10 @@ class Input extends Common {
|
|||||||
return new DslProperty(client.clientValue, clientValue)
|
return new DslProperty(client.clientValue, clientValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DslProperty $(ClientDslProperty client) {
|
||||||
|
return value(client)
|
||||||
|
}
|
||||||
|
|
||||||
@EqualsAndHashCode(includeFields = true, callSuper = true)
|
@EqualsAndHashCode(includeFields = true, callSuper = true)
|
||||||
@ToString(includeSuper = true)
|
@ToString(includeSuper = true)
|
||||||
static class BodyType extends DslProperty {
|
static class BodyType extends DslProperty {
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ class OutputMessage extends Common {
|
|||||||
return new DslProperty(value, server.serverValue)
|
return new DslProperty(value, server.serverValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DslProperty $(ServerDslProperty server) {
|
||||||
|
return value(server)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Deprecated in favor of bodyMatchers to support other future bodyMatchers too
|
* @deprecated Deprecated in favor of bodyMatchers to support other future bodyMatchers too
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.springframework.cloud.contract.spec.internal
|
||||||
|
|
||||||
|
import spock.lang.Specification
|
||||||
|
/**
|
||||||
|
* @author Tim Ysewyn
|
||||||
|
*/
|
||||||
|
class InputSpec extends Specification {
|
||||||
|
|
||||||
|
def 'should set property when using the $() convenience method'() {
|
||||||
|
given:
|
||||||
|
Input input = new Input()
|
||||||
|
DslProperty property
|
||||||
|
when:
|
||||||
|
input.with {
|
||||||
|
property = $(consumer(regex("[0-9]{5}")))
|
||||||
|
}
|
||||||
|
then:
|
||||||
|
(property.serverValue as String).matches(/[0-9]{5}/)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.springframework.cloud.contract.spec.internal
|
||||||
|
|
||||||
|
import spock.lang.Specification
|
||||||
|
/**
|
||||||
|
* @author Tim Ysewyn
|
||||||
|
*/
|
||||||
|
class OutputMessageSpec extends Specification {
|
||||||
|
|
||||||
|
def 'should set property when using the $() convenience method'() {
|
||||||
|
given:
|
||||||
|
Input input = new Input()
|
||||||
|
DslProperty property
|
||||||
|
when:
|
||||||
|
input.with {
|
||||||
|
property = $(consumer(regex("[0-9]{5}")))
|
||||||
|
}
|
||||||
|
then:
|
||||||
|
(property.serverValue as String).matches(/[0-9]{5}/)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user