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

@@ -59,8 +59,8 @@ class WireMockToDslConverter {
request {
${request.method ? "method \"\"\"$request.method\"\"\"" : ""}
${request.url ? "url \"\"\"$request.url\"\"\"" : ""}
${urlPattern ? "url \$(client(regex('${escapeJava(urlPattern)}')), server('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""}
${urlPathPattern ? "urlPath \$(client(regex('${escapeJava(urlPattern)}')), server('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""}
${urlPattern ? "url \$(consumer(regex('${escapeJava(urlPattern)}')), producer('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""}
${urlPathPattern ? "urlPath \$(consumer(regex('${escapeJava(urlPattern)}')), producer('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""}
${request.urlPath ? "url \"\"\"$request.urlPath\"\"\"" : ""}
${
request.headers ? """headers {
@@ -77,7 +77,7 @@ class WireMockToDslConverter {
}
${bodyPatterns?.equalTo?.every { it } ? "body('''${bodyPatterns.equalTo[0]}''')" : ''}
${bodyPatterns?.equalToJson?.every { it } ? "body('''${bodyPatterns.equalToJson[0]}''')" : ''}
${bodyPatterns?.matches?.every { it } ? "body \$(client(regex('${escapeJava(bodyPatterns.matches[0])}')), server('${new Xeger(escapeJava(bodyPatterns.matches[0])).generate()}'))" : ""}
${bodyPatterns?.matches?.every { it } ? "body \$(consumer(regex('${escapeJava(bodyPatterns.matches[0])}')), producer('${new Xeger(escapeJava(bodyPatterns.matches[0])).generate()}'))" : ""}
}
response {
${response.status ? "status $response.status" : ""}

View File

@@ -37,7 +37,7 @@ class DslToWireMockClientConverterSpec extends Specification {
org.springframework.cloud.contract.spec.Contract.make {
request {
method('PUT')
url \$(client(~/\\/[0-9]{2}/), server('/12'))
url \$(consumer(~/\\/[0-9]{2}/), producer('/12'))
}
response {
status 200
@@ -203,11 +203,11 @@ class DslToWireMockClientConverterSpec extends Specification {
response {
status 200
body([[id: value(
client('123'),
server(regex('[0-9]+'))
consumer('123'),
producer(regex('[0-9]+'))
)], [id: value(
client('567'),
server(regex('[0-9]+'))
consumer('567'),
producer(regex('[0-9]+'))
)]])
headers {
header 'Content-Type': 'application/json'
@@ -238,8 +238,8 @@ class DslToWireMockClientConverterSpec extends Specification {
header 'Content-Type': 'application/json'
}
body(
email: $(stub(optional(regex(email()))), test('abc@abc.com')),
callback_url: $(stub(regex(hostname())), test('http://partners.com'))
email: $(consumer(optional(regex(email()))), producer('abc@abc.com')),
callback_url: $(consumer(regex(hostname())), producer('http://partners.com'))
)
}
response {
@@ -248,8 +248,8 @@ class DslToWireMockClientConverterSpec extends Specification {
header 'Content-Type': 'application/json'
}
body(
code: value(stub("123123"), test(optional("123123"))),
message: "User not found by email == [${value(test(regex(email())), stub('not.existing@user.com'))}]"
code: value(consumer("123123"), producer(optional("123123"))),
message: "User not found by email == [${value(producer(regex(email())), consumer('not.existing@user.com'))}]"
)
}
}

View File

@@ -57,12 +57,12 @@ class WireMockToDslConverterSpec extends Specification {
url '/path'
headers {
header('Accept': $(
client(regex('text/.*')),
server('text/plain')
consumer(regex('text/.*')),
producer('text/plain')
))
header('X-Custom-Header': $(
client(regex('^.*2134.*$')),
server('121345')
consumer(regex('^.*2134.*$')),
producer('121345')
))
}
@@ -119,7 +119,7 @@ class WireMockToDslConverterSpec extends Specification {
Contract expectedGroovyDsl = Contract.make {
request {
method 'DELETE'
url $(client(~/\/credit-card-verification-data\/[0-9]+/), server('/credit-card-verification-data/1'))
url $(consumer(~/\/credit-card-verification-data\/[0-9]+/), producer('/credit-card-verification-data/1'))
headers {
header('Content-Type': 'application/vnd.mymoid-adapter.v2+json; charset=UTF-8')
}
@@ -377,7 +377,7 @@ class WireMockToDslConverterSpec extends Specification {
request {
method 'POST'
url '/test'
body $(client(~/[0-9]{5}/), server('12345'))
body $(consumer(~/[0-9]{5}/), producer('12345'))
}
response {
status 200
@@ -498,7 +498,7 @@ class WireMockToDslConverterSpec extends Specification {
request {
method 'POST'
url '/test'
body $(client(~/[0-9]{2}/), server('12'))
body $(consumer(~/[0-9]{2}/), producer('12'))
}
response {
status 200

View File

@@ -22,7 +22,7 @@ Contract.make {
headers {
header 'Content-Type': 'application/json'
}
url $(client('/[0-9]{2}'), server('/12'))
url $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status 200

View File

@@ -22,7 +22,7 @@ Contract.make {
headers {
header 'Content-Type': 'application/json'
}
urlPattern $(client('/[0-9]{2}'), server('/12'))
urlPattern $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status 200

View File

@@ -22,7 +22,7 @@ Contract.make {
headers {
header 'Content-Type': 'application/json'
}
url $(client('/[0-9]{2}'), server('/12'))
url $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status 200

View File

@@ -22,7 +22,7 @@ Contract.make {
headers {
header 'Content-Type': 'application/json'
}
url $(client('/[0-9]{2}'), server('/12'))
url $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status 200

View File

@@ -19,7 +19,7 @@ import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method 'PUT'
url $(client(regex('^/api/[0-9]{2}$')), server('/api/12'))
url $(consumer(regex('^/api/[0-9]{2}$')), producer('/api/12'))
headers {
header 'Content-Type': 'application/json'
}
@@ -31,12 +31,12 @@ Contract.make {
}
response {
headers {
header 'Content-Type': $(client('application/json'), server(regex('application/json.*')))
header 'Location': $(client('https://localhost:8080'), server(execute('isEmpty($it)')))
header 'Content-Type': $(consumer('application/json'), producer(regex('application/json.*')))
header 'Location': $(consumer('https://localhost:8080'), producer(execute('isEmpty($it)')))
}
body (
path: $(client('/api/12'), server(regex('^/api/[0-9]{2}$'))),
correlationId: $(client('1223456'), server(execute('isProperCorrelationId($it)')))
path: $(consumer('/api/12'), producer(regex('^/api/[0-9]{2}$'))),
correlationId: $(consumer('1223456'), producer(execute('isProperCorrelationId($it)')))
)
status 200
}

View File

@@ -22,7 +22,7 @@ Contract.make {
url """/fraudcheck"""
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":99999}
"""
)
@@ -34,7 +34,7 @@ Contract.make {
response {
status 200
body( """{
"fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}",
"fraudCheckStatus": "${value(consumer('FRAUD'), producer(regex('[A-Z]{5}')))}",
"rejectionReason": "Amount too high"
}""")
headers {

View File

@@ -22,7 +22,7 @@ Contract.make {
url '/fraudcheck'
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":123.123
}
"""
@@ -36,7 +36,7 @@ Contract.make {
status 200
body(
fraudCheckStatus: "OK",
rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')

View File

@@ -21,7 +21,7 @@ Contract.make {
url """/fraudcheck"""
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":99999}
"""
)
@@ -33,7 +33,7 @@ Contract.make {
response {
status 200
body( """{
"fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}",
"fraudCheckStatus": "${value(consumer('FRAUD'), producer(regex('[A-Z]{5}')))}",
"rejectionReason": "Amount too high"
}""")
headers {

View File

@@ -21,7 +21,7 @@ Contract.make {
url '/fraudcheck'
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":123.123
}
"""
@@ -35,7 +35,7 @@ Contract.make {
status 200
body(
fraudCheckStatus: "OK",
rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')

View File

@@ -21,7 +21,7 @@ Contract.make {
url '/fraudcheck'
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":123.123
}
"""
@@ -35,7 +35,7 @@ Contract.make {
status 200
body(
fraudCheckStatus: "OK",
rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')

View File

@@ -22,7 +22,7 @@ Contract.make {
url """/fraudcheck"""
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":99999}
"""
)
@@ -34,7 +34,7 @@ Contract.make {
response {
status 200
body( """{
"fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}",
"fraudCheckStatus": "${value(consumer('FRAUD'), producer(regex('[A-Z]{5}')))}",
"rejectionReason": "Amount too high"
}""")
headers {

View File

@@ -20,7 +20,7 @@ org.springframework.cloud.contract.spec.Contract.make {
url '/fraudcheck'
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":123.123
}
"""
@@ -34,7 +34,7 @@ org.springframework.cloud.contract.spec.Contract.make {
status 999
body(
fraudCheckStatus: "OK",
rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')

View File

@@ -20,7 +20,7 @@ org.springframework.cloud.contract.spec.Contract.make {
url """/fraudcheck"""
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":99999}
"""
)
@@ -32,7 +32,7 @@ org.springframework.cloud.contract.spec.Contract.make {
response {
status 200
body( """{
"fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}",
"fraudCheckStatus": "${value(consumer('FRAUD'), producer(regex('[A-Z]{5}')))}",
"rejectionReason": "Amount too high"
}""")
headers {

View File

@@ -20,7 +20,7 @@ org.springframework.cloud.contract.spec.Contract.make {
url '/fraudcheck'
body("""
{
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":123.123
}
"""
@@ -34,7 +34,7 @@ org.springframework.cloud.contract.spec.Contract.make {
status 200
body(
fraudCheckStatus: "OK",
rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')