Added the missing $() convenience method for messaging contracts (#623)

Fixes gh-619
This commit is contained in:
Tim Ysewyn
2018-04-18 23:19:00 +02:00
committed by Marcin Grzejszczak
parent f64feaf84d
commit 4cf6e199b9
4 changed files with 48 additions and 0 deletions

View File

@@ -95,6 +95,10 @@ class Input extends Common {
return new DslProperty(client.clientValue, clientValue)
}
DslProperty $(ClientDslProperty client) {
return value(client)
}
@EqualsAndHashCode(includeFields = true, callSuper = true)
@ToString(includeSuper = true)
static class BodyType extends DslProperty {

View File

@@ -97,6 +97,10 @@ class OutputMessage extends Common {
return new DslProperty(value, server.serverValue)
}
DslProperty $(ServerDslProperty server) {
return value(server)
}
/**
* @deprecated Deprecated in favor of bodyMatchers to support other future bodyMatchers too
*/

View File

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

View File

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