Changed client / server to consumer / producer

This commit is contained in:
Marcin Grzejszczak
2016-07-21 11:36:11 +02:00
parent 4f2f04a820
commit 5ef7a7fee2
35 changed files with 336 additions and 283 deletions

View File

@@ -118,18 +118,38 @@ class Common {
return new ClientDslProperty(clientValue)
}
/**
* Helper method to provide a better name for the consumer side
*/
ClientDslProperty stub(Object clientValue) {
return new ClientDslProperty(clientValue)
}
/**
* Helper method to provide a better name for the consumer side
*/
ClientDslProperty consumer(Object clientValue) {
return new ClientDslProperty(clientValue)
}
ServerDslProperty server(Object serverValue) {
return new ServerDslProperty(serverValue)
}
/**
* Helper method to provide a better name for the producer side
*/
ServerDslProperty test(Object serverValue) {
return new ServerDslProperty(serverValue)
}
/**
* Helper method to provide a better name for the producer side
*/
ServerDslProperty producer(Object clientValue) {
return new ServerDslProperty(clientValue)
}
void assertThatSidesMatch(OptionalProperty stubSide, Object testSide) {
assert testSide ==~ Pattern.compile(stubSide.optionalPattern())
}

View File

@@ -46,20 +46,6 @@ class Input extends Common {
this.messageBody = input.messageBody
}
/**
* Helper method to provide a better name for the producer side
*/
ServerDslProperty producer(Object clientValue) {
return new ServerDslProperty(clientValue)
}
/**
* Helper method to provide a better name for the consumer side
*/
ClientDslProperty consumer(Object clientValue) {
return new ClientDslProperty(clientValue)
}
/**
* Name of a destination from which message would come to trigger action in the system
*/

View File

@@ -28,6 +28,7 @@ import java.util.regex.Pattern
@CompileStatic
class RegexPatterns {
// tag::regexps[]
private static final Pattern TRUE_OR_FALSE = Pattern.compile(/(true|false)/)
private static final Pattern ONLY_ALPHA_UNICODE = Pattern.compile(/[\p{L}]*/)
private static final Pattern NUMBER = Pattern.compile('-?\\d*(\\.\\d+)?')
@@ -63,6 +64,7 @@ class RegexPatterns {
String url() {
return URL.pattern()
}
// end::regexps[]
static String multipartParam(Object name, Object value) {
return ".*--(.*)\r\nContent-Disposition: form-data; name=\"$name\"\r\n(Content-Type: .*\r\n)?(Content-Length: \\d+\r\n)?\r\n$value\r\n--\\1.*"

View File

@@ -11,13 +11,13 @@ class RequestSpec extends Specification {
Request request = new Request()
when:
request.with {
value(client("foo"), server(regex("foo")))
value(consumer("foo"), producer(regex("foo")))
}
then:
thrown(IllegalStateException)
when:
request.with {
value(server(regex("foo")), client("foo"))
value(producer(regex("foo")), consumer("foo"))
}
then:
thrown(IllegalStateException)
@@ -29,7 +29,7 @@ class RequestSpec extends Specification {
DslProperty property
when:
request.with {
property = value(client(regex("[0-9]{5}")))
property = value(consumer(regex("[0-9]{5}")))
}
then:
(property.serverValue as String).matches(/[0-9]{5}/)

View File

@@ -11,13 +11,13 @@ class ResponseSpec extends Specification {
Response response = new Response()
when:
response.with {
value(server("foo"), client(regex("foo")))
value(producer("foo"), consumer(regex("foo")))
}
then:
thrown(IllegalStateException)
when:
response.with {
value(client(regex("foo")), server("foo"))
value(consumer(regex("foo")), producer("foo"))
}
then:
thrown(IllegalStateException)
@@ -29,7 +29,7 @@ class ResponseSpec extends Specification {
DslProperty property
when:
request.with {
property = value(server(regex("[0-9]{5}")))
property = value(producer(regex("[0-9]{5}")))
}
then:
(property.serverValue as String).matches(/[0-9]{5}/)