Changed client / server to consumer / producer
This commit is contained in:
@@ -110,15 +110,15 @@ class ContractHttpDocsSpec extends Specification {
|
||||
|
||||
// `containing` function matches strings
|
||||
// that contains passed substring.
|
||||
parameter 'gender': value(stub(containing("[mf]")), server('mf'))
|
||||
parameter 'gender': value(consumer(containing("[mf]")), producer('mf'))
|
||||
|
||||
// `matching` function tests parameter
|
||||
// against passed regular expression.
|
||||
parameter 'offset': value(stub(matching("[0-9]+")), server(123))
|
||||
parameter 'offset': value(consumer(matching("[0-9]+")), producer(123))
|
||||
|
||||
// `notMatching` functions tests if parameter
|
||||
// does not match passed regular expression.
|
||||
parameter 'loginStartsWith': value(stub(notMatching(".{0,2}")), server(3))
|
||||
parameter 'loginStartsWith': value(consumer(notMatching(".{0,2}")), producer(3))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,23 +205,23 @@ class ContractHttpDocsSpec extends Specification {
|
||||
org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method('GET')
|
||||
url $(client(~/\/[0-9]{2}/), server('/12'))
|
||||
url $(consumer(~/\/[0-9]{2}/), producer('/12'))
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body(
|
||||
id: value(
|
||||
client('123'),
|
||||
server(regex('[0-9]+'))
|
||||
consumer('123'),
|
||||
producer(regex('[0-9]+'))
|
||||
),
|
||||
surname: $(
|
||||
client('Kowalsky'),
|
||||
server('Lewandowski')
|
||||
consumer('Kowalsky'),
|
||||
producer('Lewandowski')
|
||||
),
|
||||
name: 'Jan',
|
||||
created: $(client('2014-02-02 12:23:43'), server(execute('currentDate(it)'))),
|
||||
correlationId: value(client('5d1f9fef-e0dc-4f3d-a7e4-72d2220dd827'),
|
||||
server(regex('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'))
|
||||
created: $(consumer('2014-02-02 12:23:43'), producer(execute('currentDate(it)'))),
|
||||
correlationId: value(consumer('5d1f9fef-e0dc-4f3d-a7e4-72d2220dd827'),
|
||||
producer(regex('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'))
|
||||
)
|
||||
)
|
||||
headers {
|
||||
@@ -242,8 +242,8 @@ class ContractHttpDocsSpec 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 {
|
||||
@@ -252,7 +252,7 @@ class ContractHttpDocsSpec extends Specification {
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
body(
|
||||
code: value(stub("123123"), test(optional("123123")))
|
||||
code: value(consumer("123123"), producer(optional("123123")))
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ class ContractHttpDocsSpec extends Specification {
|
||||
org.springframework.cloud.contract.spec.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'
|
||||
}
|
||||
@@ -303,8 +303,8 @@ class ContractHttpDocsSpec extends Specification {
|
||||
}
|
||||
response {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -294,8 +294,8 @@ class JaxRsClientMethodBuilderSpec extends Specification implements WireMockStub
|
||||
body(
|
||||
property1: "a",
|
||||
property2: value(
|
||||
client('123'),
|
||||
server(regex('[0-9]{3}'))
|
||||
consumer('123'),
|
||||
producer(regex('[0-9]{3}'))
|
||||
)
|
||||
)
|
||||
headers {
|
||||
@@ -329,7 +329,7 @@ class JaxRsClientMethodBuilderSpec extends Specification implements WireMockStub
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body("""{"property1":"a","property2":"${value(client('123'), server(regex('[0-9]{3}')))}"}""")
|
||||
body("""{"property1":"a","property2":"${value(consumer('123'), producer(regex('[0-9]{3}')))}"}""")
|
||||
headers {
|
||||
header('Content-Type': 'application/json')
|
||||
|
||||
@@ -420,15 +420,15 @@ class JaxRsClientMethodBuilderSpec extends Specification implements WireMockStub
|
||||
method 'GET'
|
||||
urlPath('/users') {
|
||||
queryParameters {
|
||||
parameter 'limit': $(client(equalTo("20")), server(equalTo("10")))
|
||||
parameter 'offset': $(client(containing("20")), server(equalTo("20")))
|
||||
parameter 'limit': $(consumer(equalTo("20")), producer(equalTo("10")))
|
||||
parameter 'offset': $(consumer(containing("20")), producer(equalTo("20")))
|
||||
parameter 'filter': "email"
|
||||
parameter 'sort': equalTo("name")
|
||||
parameter 'search': $(client(notMatching(~/^\/[0-9]{2}$/)), server("55"))
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server("99"))
|
||||
parameter 'name': $(client(matching("Denis.*")), server("Denis.Stepanov"))
|
||||
parameter 'search': $(consumer(notMatching(~/^\/[0-9]{2}$/)), producer("55"))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer("99"))
|
||||
parameter 'name': $(consumer(matching("Denis.*")), producer("Denis.Stepanov"))
|
||||
parameter 'email': "bob@email.com"
|
||||
parameter 'hello': $(client(matching("Denis.*")), server(absent()))
|
||||
parameter 'hello': $(consumer(matching("Denis.*")), producer(absent()))
|
||||
parameter 'hello': absent()
|
||||
}
|
||||
}
|
||||
@@ -473,17 +473,17 @@ class JaxRsClientMethodBuilderSpec extends Specification implements WireMockStub
|
||||
org.springframework.cloud.contract.spec.Contract contractDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url($(stub(regex('/foo/[0-9]+')), test('/foo/123456'))) {
|
||||
url($(consumer(regex('/foo/[0-9]+')), producer('/foo/123456'))) {
|
||||
queryParameters {
|
||||
parameter 'limit': $(client(equalTo("20")), server(equalTo("10")))
|
||||
parameter 'offset': $(client(containing("20")), server(equalTo("20")))
|
||||
parameter 'limit': $(consumer(equalTo("20")), producer(equalTo("10")))
|
||||
parameter 'offset': $(consumer(containing("20")), producer(equalTo("20")))
|
||||
parameter 'filter': "email"
|
||||
parameter 'sort': equalTo("name")
|
||||
parameter 'search': $(client(notMatching(~/^\/[0-9]{2}$/)), server("55"))
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server("99"))
|
||||
parameter 'name': $(client(matching("Denis.*")), server("Denis.Stepanov"))
|
||||
parameter 'search': $(consumer(notMatching(~/^\/[0-9]{2}$/)), producer("55"))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer("99"))
|
||||
parameter 'name': $(consumer(matching("Denis.*")), producer("Denis.Stepanov"))
|
||||
parameter 'email': "bob@email.com"
|
||||
parameter 'hello': $(client(matching("Denis.*")), server(absent()))
|
||||
parameter 'hello': $(consumer(matching("Denis.*")), producer(absent()))
|
||||
parameter 'hello': absent()
|
||||
}
|
||||
}
|
||||
@@ -618,15 +618,15 @@ class JaxRsClientMethodBuilderSpec extends Specification implements WireMockStub
|
||||
method 'GET'
|
||||
urlPath('/users') {
|
||||
queryParameters {
|
||||
parameter 'limit': $(client(equalTo("20")), server(equalTo("10")))
|
||||
parameter 'offset': $(client(containing("20")), server(equalTo("20")))
|
||||
parameter 'limit': $(consumer(equalTo("20")), producer(equalTo("10")))
|
||||
parameter 'offset': $(consumer(containing("20")), producer(equalTo("20")))
|
||||
parameter 'filter': "email"
|
||||
parameter 'sort': equalTo("name")
|
||||
parameter 'search': $(client(notMatching(~/^\/[0-9]{2}$/)), server("55"))
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server("99"))
|
||||
parameter 'name': $(client(matching("Denis.*")), server("Denis.Stepanov"))
|
||||
parameter 'search': $(consumer(notMatching(~/^\/[0-9]{2}$/)), producer("55"))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer("99"))
|
||||
parameter 'name': $(consumer(matching("Denis.*")), producer("Denis.Stepanov"))
|
||||
parameter 'email': "bob@email.com"
|
||||
parameter 'hello': $(client(matching("Denis.*")), server(absent()))
|
||||
parameter 'hello': $(consumer(matching("Denis.*")), producer(absent()))
|
||||
parameter 'hello': absent()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,9 @@ import java.util.regex.Pattern
|
||||
class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStubVerifier {
|
||||
|
||||
@Shared ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties(assertJsonSize: true)
|
||||
|
||||
|
||||
@Shared
|
||||
// tag::contract_with_regex[]
|
||||
Contract dslWithOptionalsInString = Contract.make {
|
||||
priority 1
|
||||
request {
|
||||
@@ -41,8 +42,8 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
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 {
|
||||
@@ -51,11 +52,12 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
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'))}]"
|
||||
)
|
||||
}
|
||||
}
|
||||
// end::contract_with_regex[]
|
||||
|
||||
@Shared
|
||||
Contract dslWithOptionals = Contract.make {
|
||||
@@ -69,10 +71,10 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
body(
|
||||
""" {
|
||||
"email" : "${
|
||||
value(stub(optional(regex(email()))), test('abc@abc.com'))
|
||||
value(consumer(optional(regex(email()))), producer('abc@abc.com'))
|
||||
}",
|
||||
"callback_url" : "${
|
||||
value(client(regex(hostname())), server('http://partners.com'))
|
||||
value(consumer(regex(hostname())), producer('http://partners.com'))
|
||||
}"
|
||||
}
|
||||
"""
|
||||
@@ -85,9 +87,9 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
}
|
||||
body(
|
||||
""" {
|
||||
"code" : "${value(stub(123123), test(optional(123123)))}",
|
||||
"code" : "${value(consumer(123123), producer(optional(123123)))}",
|
||||
"message" : "User not found by email = [${
|
||||
value(server(regex(email())), client('not.existing@user.com'))
|
||||
value(producer(regex(email())), consumer('not.existing@user.com'))
|
||||
}]"
|
||||
}
|
||||
"""
|
||||
@@ -394,8 +396,8 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
body(
|
||||
property1: "a",
|
||||
property2: value(
|
||||
client('123'),
|
||||
server(regex('[0-9]{3}'))
|
||||
consumer('123'),
|
||||
producer(regex('[0-9]{3}'))
|
||||
)
|
||||
)
|
||||
headers {
|
||||
@@ -428,7 +430,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
response {
|
||||
status 200
|
||||
body("""{"property1":"a","property2":"${
|
||||
value(client('123'), server(regex('[0-9]{3}')))
|
||||
value(consumer('123'), producer(regex('[0-9]{3}')))
|
||||
}"}""")
|
||||
headers {
|
||||
header('Content-Type': 'application/json')
|
||||
@@ -461,7 +463,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
response {
|
||||
status 200
|
||||
body("""{"property":" ${
|
||||
value(client('123'), server(regex('\\d+')))
|
||||
value(consumer('123'), producer(regex('\\d+')))
|
||||
}"}""")
|
||||
headers {
|
||||
header('Content-Type': 'application/json')
|
||||
@@ -489,15 +491,15 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
method 'GET'
|
||||
urlPath('/users') {
|
||||
queryParameters {
|
||||
parameter 'limit': $(client(equalTo("20")), server(equalTo("10")))
|
||||
parameter 'offset': $(client(containing("20")), server(equalTo("20")))
|
||||
parameter 'limit': $(consumer(equalTo("20")), producer(equalTo("10")))
|
||||
parameter 'offset': $(consumer(containing("20")), producer(equalTo("20")))
|
||||
parameter 'filter': "email"
|
||||
parameter 'sort': equalTo("name")
|
||||
parameter 'search': $(client(notMatching(~/^\/[0-9]{2}$/)), server("55"))
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server("99"))
|
||||
parameter 'name': $(client(matching("Denis.*")), server("Denis.Stepanov"))
|
||||
parameter 'search': $(consumer(notMatching(~/^\/[0-9]{2}$/)), producer("55"))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer("99"))
|
||||
parameter 'name': $(consumer(matching("Denis.*")), producer("Denis.Stepanov"))
|
||||
parameter 'email': "bob@email.com"
|
||||
parameter 'hello': $(client(matching("Denis.*")), server(absent()))
|
||||
parameter 'hello': $(consumer(matching("Denis.*")), producer(absent()))
|
||||
parameter 'hello': absent()
|
||||
}
|
||||
}
|
||||
@@ -535,17 +537,17 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url($(stub(regex('/foo/[0-9]+')), test('/foo/123456'))) {
|
||||
url($(consumer(regex('/foo/[0-9]+')), producer('/foo/123456'))) {
|
||||
queryParameters {
|
||||
parameter 'limit': $(client(equalTo("20")), server(equalTo("10")))
|
||||
parameter 'offset': $(client(containing("20")), server(equalTo("20")))
|
||||
parameter 'limit': $(consumer(equalTo("20")), producer(equalTo("10")))
|
||||
parameter 'offset': $(consumer(containing("20")), producer(equalTo("20")))
|
||||
parameter 'filter': "email"
|
||||
parameter 'sort': equalTo("name")
|
||||
parameter 'search': $(client(notMatching(~/^\/[0-9]{2}$/)), server("55"))
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server("99"))
|
||||
parameter 'name': $(client(matching("Denis.*")), server("Denis.Stepanov"))
|
||||
parameter 'search': $(consumer(notMatching(~/^\/[0-9]{2}$/)), producer("55"))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer("99"))
|
||||
parameter 'name': $(consumer(matching("Denis.*")), producer("Denis.Stepanov"))
|
||||
parameter 'email': "bob@email.com"
|
||||
parameter 'hello': $(client(matching("Denis.*")), server(absent()))
|
||||
parameter 'hello': $(consumer(matching("Denis.*")), producer(absent()))
|
||||
parameter 'hello': absent()
|
||||
}
|
||||
}
|
||||
@@ -638,7 +640,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method 'POST'
|
||||
url $(client(regex('/partners/[0-9]+/users')), server('/partners/1000/users'))
|
||||
url $(consumer(regex('/partners/[0-9]+/users')), producer('/partners/1000/users'))
|
||||
headers { header 'Content-Type': 'application/json' }
|
||||
body(
|
||||
first_name: 'John',
|
||||
@@ -652,7 +654,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
response {
|
||||
status 201
|
||||
headers {
|
||||
header 'Location': $(client('http://localhost/partners/1000/users/1001'), server(regex('http://localhost/partners/[0-9]+/users/[0-9]+')))
|
||||
header 'Location': $(consumer('http://localhost/partners/1000/users/1001'), producer(regex('http://localhost/partners/[0-9]+/users/[0-9]+')))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -677,7 +679,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method 'POST'
|
||||
url $(client(regex('/partners/[0-9]+/users')), server('/partners/1000/users'))
|
||||
url $(consumer(regex('/partners/[0-9]+/users')), producer('/partners/1000/users'))
|
||||
headers { header 'Content-Type': 'application/json' }
|
||||
body(
|
||||
first_name: 'John',
|
||||
@@ -691,7 +693,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
response {
|
||||
status 201
|
||||
headers {
|
||||
header 'Location': $(client('http://localhost/partners/1000/users/1001'), server(regex("^${hostname()}/partners/[0-9]+/users/[0-9]+")))
|
||||
header 'Location': $(consumer('http://localhost/partners/1000/users/1001'), producer(regex("^${hostname()}/partners/[0-9]+/users/[0-9]+")))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -757,7 +759,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
|
||||
request {
|
||||
method 'PUT'
|
||||
url "/partners/${value(client(regex('^[0-9]*$')), server('11'))}/agents/11/customers/09665703Z"
|
||||
url "/partners/${value(consumer(regex('^[0-9]*$')), producer('11'))}/agents/11/customers/09665703Z"
|
||||
headers {
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
@@ -795,8 +797,8 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
body(
|
||||
email: $(client(regex(email())), server('not.existing@user.com')),
|
||||
callback_url: $(client(regex(hostname())), server('http://partners.com'))
|
||||
email: $(consumer(regex(email())), producer('not.existing@user.com')),
|
||||
callback_url: $(consumer(regex(hostname())), producer('http://partners.com'))
|
||||
)
|
||||
}
|
||||
response {
|
||||
@@ -806,7 +808,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
}
|
||||
body(
|
||||
code: 4,
|
||||
message: "User not found by email = [${value(server(regex(email())), client('not.existing@user.com'))}]"
|
||||
message: "User not found by email = [${value(producer(regex(email())), consumer('not.existing@user.com'))}]"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -869,7 +871,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
body("""
|
||||
{
|
||||
"clientPesel":"${
|
||||
value(client(regex('[0-9]{10}')), server('1234567890'))
|
||||
value(consumer(regex('[0-9]{10}')), producer('1234567890'))
|
||||
}",
|
||||
"loanAmount":123.123
|
||||
}
|
||||
@@ -885,14 +887,14 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
body("""{
|
||||
"fraudCheckStatus": "OK",
|
||||
"rejectionReason": ${
|
||||
value(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
|
||||
value(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
|
||||
}
|
||||
}""")
|
||||
headers {
|
||||
header('Content-Type': 'application/vnd.fraud.v1+json')
|
||||
header 'Location': value(
|
||||
stub(null),
|
||||
test(execute('assertThatLocationIsNull($it)'))
|
||||
consumer(null),
|
||||
producer(execute('assertThatLocationIsNull($it)'))
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -929,31 +931,31 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
}
|
||||
body(
|
||||
client: [
|
||||
first_name : $(stub(regex(onlyAlphaUnicode())), test('Denis')),
|
||||
last_name : $(stub(regex(onlyAlphaUnicode())), test('FakeName')),
|
||||
email : $(stub(regex(email())), test('fakemail@fakegmail.com')),
|
||||
fax : $(stub(PHONE_NUMBER), test('+xx001213214')),
|
||||
phone : $(stub(PHONE_NUMBER), test('2223311')),
|
||||
data_of_birth: $(stub(DATETIME), test('2002-10-22T00:00:00Z'))
|
||||
first_name : $(consumer(regex(onlyAlphaUnicode())), producer('Denis')),
|
||||
last_name : $(consumer(regex(onlyAlphaUnicode())), producer('FakeName')),
|
||||
email : $(consumer(regex(email())), producer('fakemail@fakegmail.com')),
|
||||
fax : $(consumer(PHONE_NUMBER), producer('+xx001213214')),
|
||||
phone : $(consumer(PHONE_NUMBER), producer('2223311')),
|
||||
data_of_birth: $(consumer(DATETIME), producer('2002-10-22T00:00:00Z'))
|
||||
],
|
||||
client_id_card: [
|
||||
id : $(stub(ANYSTRING), test('ABC12345')),
|
||||
date_of_issue: $(stub(ANYSTRING), test('2002-10-02T00:00:00Z')),
|
||||
id : $(consumer(ANYSTRING), producer('ABC12345')),
|
||||
date_of_issue: $(consumer(ANYSTRING), producer('2002-10-02T00:00:00Z')),
|
||||
address : [
|
||||
street : $(stub(ANYSTRING), test('Light Street')),
|
||||
city : $(stub(ANYSTRING), test('Fire')),
|
||||
region : $(stub(ANYSTRING), test('Skys')),
|
||||
country: $(stub(ANYSTRING), test('HG')),
|
||||
zip : $(stub(NUMBERS), test('658965'))
|
||||
street : $(consumer(ANYSTRING), producer('Light Street')),
|
||||
city : $(consumer(ANYSTRING), producer('Fire')),
|
||||
region : $(consumer(ANYSTRING), producer('Skys')),
|
||||
country: $(consumer(ANYSTRING), producer('HG')),
|
||||
zip : $(consumer(NUMBERS), producer('658965'))
|
||||
]
|
||||
],
|
||||
incomes_and_expenses: [
|
||||
monthly_income : $(stub(NUMBERS), test('0.0')),
|
||||
monthly_loan_repayments: $(stub(NUMBERS), test('100')),
|
||||
monthly_living_expenses: $(stub(NUMBERS), test('22'))
|
||||
monthly_income : $(consumer(NUMBERS), producer('0.0')),
|
||||
monthly_loan_repayments: $(consumer(NUMBERS), producer('100')),
|
||||
monthly_living_expenses: $(consumer(NUMBERS), producer('22'))
|
||||
],
|
||||
additional_info: [
|
||||
allow_to_contact: $(stub(optional(regex(anyBoolean()))), test('true'))
|
||||
allow_to_contact: $(consumer(optional(regex(anyBoolean()))), producer('true'))
|
||||
]
|
||||
)
|
||||
}
|
||||
@@ -993,8 +995,8 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
|
||||
}
|
||||
body(
|
||||
client: [
|
||||
first_name: $(stub(ONLY_ALPHA_UNICODE), test('Пенева')),
|
||||
last_name : $(stub(ONLY_ALPHA_UNICODE), test('Пенева'))
|
||||
first_name: $(consumer(ONLY_ALPHA_UNICODE), producer('Пенева')),
|
||||
last_name : $(consumer(ONLY_ALPHA_UNICODE), producer('Пенева'))
|
||||
]
|
||||
)
|
||||
}
|
||||
@@ -1057,9 +1059,9 @@ World.'''"""
|
||||
header('content-type', 'multipart/form-data;boundary=AaB03x')
|
||||
}
|
||||
multipart(
|
||||
formParameter: value(client(regex('.+')), server('"formParameterValue"')),
|
||||
someBooleanParameter: value(client(regex('(true|false)')), server('true')),
|
||||
file: named(value(client(regex('.+')), server('filename.csv')), value(client(regex('.+')), server('file content')))
|
||||
formParameter: value(consumer(regex('.+')), producer('"formParameterValue"')),
|
||||
someBooleanParameter: value(consumer(regex('(true|false)')), producer('true')),
|
||||
file: named(value(consumer(regex('.+')), producer('filename.csv')), value(consumer(regex('.+')), producer('file content')))
|
||||
)
|
||||
}
|
||||
response {
|
||||
@@ -1095,11 +1097,11 @@ World.'''"""
|
||||
method "PUT"
|
||||
url "/multipart"
|
||||
multipart(
|
||||
formParameter: value(client(regex('".+"')), server('"formParameterValue"')),
|
||||
someBooleanParameter: value(client(regex('(true|false)')), server('true')),
|
||||
formParameter: value(consumer(regex('".+"')), producer('"formParameterValue"')),
|
||||
someBooleanParameter: value(consumer(regex('(true|false)')), producer('true')),
|
||||
file: named(
|
||||
name: value(client(regex('.+')), server('filename.csv')),
|
||||
content: value(client(regex('.+')), server('file content')))
|
||||
name: value(consumer(regex('.+')), producer('filename.csv')),
|
||||
content: value(consumer(regex('.+')), producer('file content')))
|
||||
)
|
||||
}
|
||||
response {
|
||||
@@ -1129,8 +1131,8 @@ World.'''"""
|
||||
queryParameters {
|
||||
parameter 'token':
|
||||
value(
|
||||
client(regex('^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')),
|
||||
server('6973b31d-7140-402a-bca6-1cdb954e03a7')
|
||||
consumer(regex('^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')),
|
||||
producer('6973b31d-7140-402a-bca6-1cdb954e03a7')
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1139,7 +1141,7 @@ World.'''"""
|
||||
status 200
|
||||
body(
|
||||
authorities: [
|
||||
value(stub('ROLE_ADMIN'), test(regex('^[a-zA-Z0-9_\\- ]+$')))
|
||||
value(consumer('ROLE_ADMIN'), producer(regex('^[a-zA-Z0-9_\\- ]+$')))
|
||||
]
|
||||
)
|
||||
}
|
||||
@@ -1163,8 +1165,8 @@ World.'''"""
|
||||
queryParameters {
|
||||
parameter 'token':
|
||||
value(
|
||||
client(regex('^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')),
|
||||
server('6973b31d-7140-402a-bca6-1cdb954e03a7')
|
||||
consumer(regex('^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')),
|
||||
producer('6973b31d-7140-402a-bca6-1cdb954e03a7')
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1173,7 +1175,7 @@ World.'''"""
|
||||
status 200
|
||||
body(
|
||||
authorities: [
|
||||
value(stub('ROLE_ADMIN'), test(regex('^[a-zA-Z0-9_\\- ]+$')))
|
||||
value(consumer('ROLE_ADMIN'), producer(regex('^[a-zA-Z0-9_\\- ]+$')))
|
||||
]
|
||||
)
|
||||
}
|
||||
@@ -1198,7 +1200,7 @@ World.'''"""
|
||||
status 200
|
||||
body(
|
||||
fraudCheckStatus: "OK",
|
||||
rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
|
||||
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1228,11 +1230,11 @@ World.'''"""
|
||||
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;charset=UTF-8')
|
||||
@@ -1386,7 +1388,7 @@ World.'''"""
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body( code: 9, message: $(client('Wrong credentials'), server(regex('^(?!\\s*$).+'))) )
|
||||
body( code: 9, message: $(consumer('Wrong credentials'), producer(regex('^(?!\\s*$).+'))) )
|
||||
}
|
||||
}
|
||||
MethodBodyBuilder builder = new MockMvcSpockMethodRequestProcessingBodyBuilder(contractDsl, properties)
|
||||
@@ -1451,13 +1453,13 @@ World.'''"""
|
||||
method 'PUT'
|
||||
url '/foo'
|
||||
body([
|
||||
requestElement: value(client(regex('[0-9]{5}')))
|
||||
requestElement: value(consumer(regex('[0-9]{5}')))
|
||||
])
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body([
|
||||
responseElement: value(server(regex('[0-9]{7}')))
|
||||
responseElement: value(producer(regex('[0-9]{7}')))
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,21 +31,21 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method('GET')
|
||||
url $(client(~/\/[0-9]{2}/), server('/12'))
|
||||
url $(consumer(~/\/[0-9]{2}/), producer('/12'))
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body(
|
||||
id: value(
|
||||
client('123'),
|
||||
server(regex('[0-9]+'))
|
||||
consumer('123'),
|
||||
producer(regex('[0-9]+'))
|
||||
),
|
||||
surname: $(
|
||||
client('Kowalsky'),
|
||||
server('Lewandowski')
|
||||
consumer('Kowalsky'),
|
||||
producer('Lewandowski')
|
||||
),
|
||||
name: 'Jan',
|
||||
created: $(client('2014-02-02 12:23:43'), server({ currentDate(it) }))
|
||||
created: $(consumer('2014-02-02 12:23:43'), producer({ currentDate(it) }))
|
||||
)
|
||||
headers {
|
||||
header 'Content-Type': 'text/plain'
|
||||
@@ -132,15 +132,15 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
header("Content-Type": 'application/x-www-form-urlencoded')
|
||||
}
|
||||
body("""paymentType=INCOMING&transferType=BANK&amount=${
|
||||
value(client(regex('[0-9]{3}\\.[0-9]{2}')), server(500.00))
|
||||
value(consumer(regex('[0-9]{3}\\.[0-9]{2}')), producer(500.00))
|
||||
}&bookingDate=${
|
||||
value(client(regex('[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])')), server('2015-05-18'))
|
||||
value(consumer(regex('[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])')), producer('2015-05-18'))
|
||||
}""")
|
||||
}
|
||||
response {
|
||||
status 204
|
||||
body(
|
||||
paymentId: value(client('4'), server(regex('[1-9][0-9]*'))),
|
||||
paymentId: value(consumer('4'), producer(regex('[1-9][0-9]*'))),
|
||||
foundExistingPayment: false
|
||||
)
|
||||
}
|
||||
@@ -179,16 +179,16 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method('GET')
|
||||
url $(client(~/\/[0-9]{2}/), server('/12'))
|
||||
url $(consumer(~/\/[0-9]{2}/), producer('/12'))
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body("""\
|
||||
{
|
||||
"id": "${value(client('123'), server('321'))}",
|
||||
"surname": "${value(client('Kowalsky'), server('Lewandowski'))}",
|
||||
"id": "${value(consumer('123'), producer('321'))}",
|
||||
"surname": "${value(consumer('Kowalsky'), producer('Lewandowski'))}",
|
||||
"name": "Jan",
|
||||
"created" : "${$(client('2014-02-02 12:23:43'), server('2999-09-09 01:23:45'))}"
|
||||
"created" : "${$(consumer('2014-02-02 12:23:43'), producer('2999-09-09 01:23:45'))}"
|
||||
}
|
||||
"""
|
||||
)
|
||||
@@ -224,7 +224,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method('GET')
|
||||
url $(client(regex('/[0-9]{2}')), server('/12'))
|
||||
url $(consumer(regex('/[0-9]{2}')), producer('/12'))
|
||||
body """
|
||||
{
|
||||
"name": "Jan"
|
||||
@@ -274,18 +274,18 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method('GET')
|
||||
url $(client(~/\/[0-9]{2}/), server('/12'))
|
||||
url $(consumer(~/\/[0-9]{2}/), producer('/12'))
|
||||
body(
|
||||
id: value(
|
||||
client('123'),
|
||||
server({ regex('[0-9]+') })
|
||||
consumer('123'),
|
||||
producer({ regex('[0-9]+') })
|
||||
),
|
||||
surname: $(
|
||||
client('Kowalsky'),
|
||||
server('Lewandowski')
|
||||
consumer('Kowalsky'),
|
||||
producer('Lewandowski')
|
||||
),
|
||||
name: 'Jan',
|
||||
created: $(client('2014-02-02 12:23:43'), server({ currentDate(it) }))
|
||||
created: $(consumer('2014-02-02 12:23:43'), producer({ currentDate(it) }))
|
||||
)
|
||||
}
|
||||
response {
|
||||
@@ -373,8 +373,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
headers {
|
||||
header "Content-Type", "customtype/xml"
|
||||
}
|
||||
body """<name>${value(client('Jozo'), server('Denis'))}</name><jobId>${
|
||||
value(client("<test>"), server('1234567890'))
|
||||
body """<name>${value(consumer('Jozo'), producer('Denis'))}</name><jobId>${
|
||||
value(consumer("<test>"), producer('1234567890'))
|
||||
}</jobId>"""
|
||||
}
|
||||
response {
|
||||
@@ -415,8 +415,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
request {
|
||||
method 'GET'
|
||||
url "/users"
|
||||
body """<user><name>${value(client('Jozo'), server('Denis'))}</name><jobId>${
|
||||
value(client("<test>"), server('1234567890'))
|
||||
body """<user><name>${value(consumer('Jozo'), producer('Denis'))}</name><jobId>${
|
||||
value(consumer("<test>"), producer('1234567890'))
|
||||
}</jobId></user>"""
|
||||
}
|
||||
response {
|
||||
@@ -455,8 +455,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body """<user><name>${value(client('Jozo'), server('Denis'))}</name><jobId>${
|
||||
value(client("<test>"), server('1234567890'))
|
||||
body """<user><name>${value(consumer('Jozo'), producer('Denis'))}</name><jobId>${
|
||||
value(consumer("<test>"), producer('1234567890'))
|
||||
}</jobId></user>"""
|
||||
}
|
||||
}
|
||||
@@ -520,8 +520,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
request {
|
||||
method 'GET'
|
||||
url "/users"
|
||||
body equalToXml("""<name>${value(client('Jozo'), server('Denis'))}</name><jobId>${
|
||||
value(client("<test>"), server('1234567890'))
|
||||
body equalToXml("""<name>${value(consumer('Jozo'), producer('Denis'))}</name><jobId>${
|
||||
value(consumer("<test>"), producer('1234567890'))
|
||||
}</jobId>""")
|
||||
}
|
||||
response {
|
||||
@@ -556,10 +556,10 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method('GET')
|
||||
url $(client(regex('/[0-9]{2}')), server('/12'))
|
||||
url $(consumer(regex('/[0-9]{2}')), producer('/12'))
|
||||
body """
|
||||
{
|
||||
"personalId": "${value(client(regex('^[0-9]{11}$')), server('57593728525'))}"
|
||||
"personalId": "${value(consumer(regex('^[0-9]{11}$')), producer('57593728525'))}"
|
||||
}
|
||||
"""
|
||||
}
|
||||
@@ -609,7 +609,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
url '/fraudcheck'
|
||||
body("""
|
||||
{
|
||||
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
|
||||
"clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
|
||||
"loanAmount":123.123
|
||||
}
|
||||
"""
|
||||
@@ -623,7 +623,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
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')
|
||||
@@ -668,15 +668,15 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
urlPath($(client("users"), server("items"))) {
|
||||
urlPath($(consumer("users"), producer("items"))) {
|
||||
queryParameters {
|
||||
parameter 'limit': $(client(equalTo("20")), server("10"))
|
||||
parameter 'offset': $(client(containing("10")), server("10"))
|
||||
parameter 'limit': $(consumer(equalTo("20")), producer("10"))
|
||||
parameter 'offset': $(consumer(containing("10")), producer("10"))
|
||||
parameter 'filter': "email"
|
||||
parameter 'sort': $(client(~/^[0-9]{10}$/), server("1234567890"))
|
||||
parameter 'search': $(client(notMatching(~/^\/[0-9]{2}$/)), server("10"))
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server(10))
|
||||
parameter 'name': $(client(matching("Denis.*")), server("Denis"))
|
||||
parameter 'sort': $(consumer(~/^[0-9]{10}$/), producer("1234567890"))
|
||||
parameter 'search': $(consumer(notMatching(~/^\/[0-9]{2}$/)), producer("10"))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer(10))
|
||||
parameter 'name': $(consumer(matching("Denis.*")), producer("Denis"))
|
||||
parameter 'credit': absent()
|
||||
}
|
||||
}
|
||||
@@ -736,9 +736,9 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
urlPath($(client(regex("/users/[0-9]+")), server("/users/1"))) {
|
||||
urlPath($(consumer(regex("/users/[0-9]+")), producer("/users/1"))) {
|
||||
queryParameters {
|
||||
parameter 'search': $(client(notMatching(~/^\/[0-9]{2}$/)), server("10"))
|
||||
parameter 'search': $(consumer(notMatching(~/^\/[0-9]{2}$/)), producer("10"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -775,7 +775,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
urlPath $(client("boxes"), server("items"))
|
||||
urlPath $(consumer("boxes"), producer("items"))
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
@@ -856,7 +856,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
method 'GET'
|
||||
url("abc") {
|
||||
queryParameters {
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server(regex(".*")))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer(regex(".*")))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -902,7 +902,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
method 'GET'
|
||||
urlPath("users") {
|
||||
queryParameters {
|
||||
parameter 'name': $(client(absent()), server(""))
|
||||
parameter 'name': $(consumer(absent()), producer(""))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -915,7 +915,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
method 'GET'
|
||||
urlPath("users") {
|
||||
queryParameters {
|
||||
parameter 'name': $(client(""), server(absent()))
|
||||
parameter 'name': $(consumer(""), producer(absent()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -928,7 +928,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
method 'GET'
|
||||
urlPath("users") {
|
||||
queryParameters {
|
||||
parameter 'name': $(client(absent()), server(matching("abc")))
|
||||
parameter 'name': $(consumer(absent()), producer(matching("abc")))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -944,10 +944,10 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url($(client(regex(/users\/[0-9]*/)), server("users/123"))) {
|
||||
url($(consumer(regex(/users\/[0-9]*/)), producer("users/123"))) {
|
||||
queryParameters {
|
||||
parameter 'age': $(client(notMatching("^\\w*\$")), server(10))
|
||||
parameter 'name': $(client(matching("Denis.*")), server("Denis"))
|
||||
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer(10))
|
||||
parameter 'name': $(consumer(matching("Denis.*")), producer("Denis"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -986,20 +986,20 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method('GET')
|
||||
url $(client(~/\/[0-9]{2}/), server('/12'))
|
||||
url $(consumer(~/\/[0-9]{2}/), producer('/12'))
|
||||
body """\
|
||||
{
|
||||
"personalId": "${value(client(regex('[0-9]{11}')), server('57593728525'))}",
|
||||
"firstName": "${value(client(regex('.*')), server('Bruce'))}",
|
||||
"lastName": "${value(client(regex('.*')), server('Lee'))}",
|
||||
"birthDate": "${value(client(regex('[0-9]{4}-[0-9]{2}-[0-9]{2}')), server('1985-12-12'))}",
|
||||
"personalId": "${value(consumer(regex('[0-9]{11}')), producer('57593728525'))}",
|
||||
"firstName": "${value(consumer(regex('.*')), producer('Bruce'))}",
|
||||
"lastName": "${value(consumer(regex('.*')), producer('Lee'))}",
|
||||
"birthDate": "${value(consumer(regex('[0-9]{4}-[0-9]{2}-[0-9]{2}')), producer('1985-12-12'))}",
|
||||
"errors": [
|
||||
{
|
||||
"propertyName": "${value(client(regex('[0-9]{2}')), server('04'))}",
|
||||
"propertyName": "${value(consumer(regex('[0-9]{2}')), producer('04'))}",
|
||||
"providerValue": "Test"
|
||||
},
|
||||
{
|
||||
"propertyName": "${value(client(regex('[0-9]{2}')), server('08'))}",
|
||||
"propertyName": "${value(consumer(regex('[0-9]{2}')), producer('08'))}",
|
||||
"providerValue": "Test"
|
||||
}
|
||||
]
|
||||
@@ -1060,10 +1060,10 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
url '/reissue-payment-order'
|
||||
body(
|
||||
loanNumber: "999997001",
|
||||
amount: value(client(regex('[0-9.]+')), server('100.00')),
|
||||
amount: value(consumer(regex('[0-9.]+')), producer('100.00')),
|
||||
currency: "DKK",
|
||||
applicationName: value(client(regex('.*')), server("Auto-Repayments")),
|
||||
username: value(client(regex('.*')), server("scheduler")),
|
||||
applicationName: value(consumer(regex('.*')), producer("Auto-Repayments")),
|
||||
username: value(consumer(regex('.*')), producer("scheduler")),
|
||||
cardId: 1
|
||||
)
|
||||
}
|
||||
@@ -1182,7 +1182,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
method('POST')
|
||||
url("foo")
|
||||
body(
|
||||
property: value(stub("value"), test("value"))
|
||||
property: value(consumer("value"), producer("value"))
|
||||
)
|
||||
}
|
||||
response {
|
||||
@@ -1257,8 +1257,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
body(
|
||||
email: $(client(regex(email())), server('not.existing@user.com')),
|
||||
callback_url: $(client(regex(hostname())), server('http://partners.com'))
|
||||
email: $(consumer(regex(email())), producer('not.existing@user.com')),
|
||||
callback_url: $(consumer(regex(hostname())), producer('http://partners.com'))
|
||||
)
|
||||
}
|
||||
response {
|
||||
@@ -1268,7 +1268,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
body(
|
||||
code: 4,
|
||||
message: "User not found by email = [${value(server(regex(email())), client('not.existing@user.com'))}]"
|
||||
message: "User not found by email = [${value(producer(regex(email())), consumer('not.existing@user.com'))}]"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1311,7 +1311,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
|
||||
request {
|
||||
method 'PUT'
|
||||
url "/partners/${value(client(regex('^[0-9]*$')), server('11'))}/agents/11/customers/09665703Z"
|
||||
url "/partners/${value(consumer(regex('^[0-9]*$')), producer('11'))}/agents/11/customers/09665703Z"
|
||||
headers {
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
@@ -1393,8 +1393,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
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 {
|
||||
@@ -1403,8 +1403,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
body(
|
||||
code: $(stub("123123"), test(optional("123123"))),
|
||||
message: "User not found by email = [${value(test(regex(email())), stub('not.existing@user.com'))}]"
|
||||
code: $(consumer("123123"), producer(optional("123123"))),
|
||||
message: "User not found by email = [${value(producer(regex(email())), consumer('not.existing@user.com'))}]"
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -1418,8 +1418,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
body(
|
||||
""" {
|
||||
"email" : "${value(stub(optional(regex(email()))), test('abc@abc.com'))}",
|
||||
"callback_url" : "${value(client(regex(hostname())), server('http://partners.com'))}"
|
||||
"email" : "${value(consumer(optional(regex(email()))), producer('abc@abc.com'))}",
|
||||
"callback_url" : "${value(consumer(regex(hostname())), producer('http://partners.com'))}"
|
||||
}
|
||||
"""
|
||||
)
|
||||
@@ -1431,8 +1431,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
body(
|
||||
""" {
|
||||
"code" : "${value(stub(123123), test(optional(123123)))}",
|
||||
"message" : "User not found by email = [${value(server(regex(email())), client('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'))}]"
|
||||
}
|
||||
"""
|
||||
)
|
||||
@@ -1461,11 +1461,11 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
method "PUT"
|
||||
url "/multipart"
|
||||
multipart(
|
||||
formParameter: value(client(regex('".+"')), server('"formParameterValue"')),
|
||||
someBooleanParameter: value(client(regex('(true|false)')), server('true')),
|
||||
formParameter: value(consumer(regex('".+"')), producer('"formParameterValue"')),
|
||||
someBooleanParameter: value(consumer(regex('(true|false)')), producer('true')),
|
||||
file: named(
|
||||
name: value(client(regex('.+')), server('filename.csv')),
|
||||
content: value(client(regex('.+')), server('file content')))
|
||||
name: value(consumer(regex('.+')), producer('filename.csv')),
|
||||
content: value(consumer(regex('.+')), producer('file content')))
|
||||
)
|
||||
}
|
||||
response {
|
||||
@@ -1507,16 +1507,16 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
urlPath ('/some/api') {
|
||||
queryParameters {
|
||||
parameter 'size': value(
|
||||
client(regex('[0-9]+')),
|
||||
server(1)
|
||||
consumer(regex('[0-9]+')),
|
||||
producer(1)
|
||||
)
|
||||
parameter 'page': value(
|
||||
client(regex('[0-9]+')),
|
||||
server(0)
|
||||
consumer(regex('[0-9]+')),
|
||||
producer(0)
|
||||
)
|
||||
parameter sort: value(
|
||||
client(optional(regex('^[a-z]+$'))),
|
||||
server('id')
|
||||
consumer(optional(regex('^[a-z]+$'))),
|
||||
producer('id')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,19 +25,19 @@ Contract.make {
|
||||
body("""\
|
||||
{
|
||||
"name": "Jan",
|
||||
"id": "${value(client('abc'), server('def'))}",
|
||||
"id": "${value(consumer('abc'), producer('def'))}",
|
||||
}
|
||||
"""
|
||||
)
|
||||
url $(client('/[0-9]{2}'), server('/12'))
|
||||
url $(consumer('/[0-9]{2}'), producer('/12'))
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body("""\
|
||||
{
|
||||
"name": "Jan",
|
||||
"id": "${value(client('123'), server('321'))}",
|
||||
"surname": "${value(client('Kowalsky'), server('$checkIfSurnameValid($value)'))}"
|
||||
"id": "${value(consumer('123'), producer('321'))}",
|
||||
"surname": "${value(consumer('Kowalsky'), producer('$checkIfSurnameValid($value)'))}"
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user