Allows passing of regex type (#832)

without this change if one does $(regex("[0-9]")) we have no knowledge of whether the result should be text or a number. What we do ATM is we always generate a String
with this change once can pass the type of regular expression and we will generate the concrete value of that given type

fixes gh-768
This commit is contained in:
Marcin Grzejszczak
2018-12-28 16:29:32 +01:00
committed by GitHub
parent 58bf533462
commit 56fbc11f62
40 changed files with 989 additions and 263 deletions

View File

@@ -1333,7 +1333,8 @@ DATA
builder.appendTo(blockBuilder)
def test = blockBuilder.toString()
then:
test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
!test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
test.contains('''.cookie("cookie-key", "''')
test.contains('''assertThat(response.getCookies().get("cookie-key")).isNotNull();''')
test.contains('''assertThat(response.getCookies().get("cookie-key").getValue()).matches("[A-Za-z]+");''')
and:
@@ -1376,7 +1377,8 @@ DATA
builder.appendTo(blockBuilder)
def test = blockBuilder.toString()
then:
test.contains('''.cookie('cookie-key', '[A-Za-z]+')''')
!test.contains('''.cookie('cookie-key', '[A-Za-z]+')''')
test.contains('''.cookie('cookie-key', ''')
test.contains('''response.getCookies().get('cookie-key') != null''')
test.contains('''response.getCookies().get('cookie-key').getValue() ==~ java.util.regex.Pattern.compile('[A-Za-z]+')''')
and:

View File

@@ -528,7 +528,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
body(
[
"name" : $(consumer(~/.+/), producer('string-1')),
"updatedTs" : $(consumer(~/\d{13}/), producer(1531916906000L)),
"updatedTs" : $(consumer(regex(~/1531916906000/).asLong())),
"isDisabled": $(consumer(regex(anyBoolean())), producer(true))
]
)
@@ -557,6 +557,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
String test = blockBuilder.toString()
SyntaxChecker.tryToCompileWithoutCompileStatic(methodBuilderName, test)
test.contains('''assertThatJson(parsedJson).field("['updatedTs']").isEqualTo(1531916906000L)''')
!test.contains('''"updatedTs":"1531916906000"''')
and:
stubMappingIsValidWireMockStub(contractDsl)
where:

View File

@@ -62,12 +62,12 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
]
])
bodyMatchers {
jsonPath('$.duck', byRegex("[0-9]{3}"))
jsonPath('$.duck', byRegex("[0-9]{3}").asInteger())
jsonPath('$.duck', byEquality())
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()))
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()).asString())
jsonPath('$.alpha', byEquality())
jsonPath('$.number', byRegex(number()))
jsonPath('$.aBoolean', byRegex(anyBoolean()))
jsonPath('$.number', byRegex(number()).asInteger())
jsonPath('$.aBoolean', byRegex(anyBoolean()).asBooleanType())
jsonPath('$.date', byDate())
jsonPath('$.dateTime', byTimestamp())
jsonPath('$.time', byTime())
@@ -111,18 +111,18 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
])
bodyMatchers {
// asserts the jsonpath value against manual regex
jsonPath('$.duck', byRegex("[0-9]{3}"))
jsonPath('$.duck', byRegex("[0-9]{3}").asInteger())
// asserts the jsonpath value against the provided value
jsonPath('$.duck', byEquality())
// asserts the jsonpath value against some default regex
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()))
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()).asString())
jsonPath('$.alpha', byEquality())
jsonPath('$.number', byRegex(number()))
jsonPath('$.positiveInteger', byRegex(anInteger()))
jsonPath('$.negativeInteger', byRegex(anInteger()))
jsonPath('$.positiveDecimalNumber', byRegex(aDouble()))
jsonPath('$.negativeDecimalNumber', byRegex(aDouble()))
jsonPath('$.aBoolean', byRegex(anyBoolean()))
jsonPath('$.number', byRegex(number()).asInteger())
jsonPath('$.positiveInteger', byRegex(anInteger()).asInteger())
jsonPath('$.negativeInteger', byRegex(anInteger()).asInteger())
jsonPath('$.positiveDecimalNumber', byRegex(aDouble()).asDouble())
jsonPath('$.negativeDecimalNumber', byRegex(aDouble()).asDouble())
jsonPath('$.aBoolean', byRegex(anyBoolean()).asBooleanType())
// asserts vs inbuilt time related regex
jsonPath('$.date', byDate())
jsonPath('$.dateTime', byTimestamp())

View File

@@ -2794,7 +2794,8 @@ DocumentContext parsedJson = JsonPath.parse(json);
builder.appendTo(blockBuilder)
def test = blockBuilder.toString()
then:
test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
!test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
test.contains('''.cookie("cookie-key", "''')
test.contains('''assertThat(response.getCookie("cookie-key")).isNotNull();''')
test.contains('''assertThat(response.getCookie("cookie-key")).matches("[A-Za-z]+");''')
and:
@@ -2845,7 +2846,8 @@ DocumentContext parsedJson = JsonPath.parse(json);
builder.appendTo(blockBuilder)
def test = blockBuilder.toString()
then:
test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
!test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
test.contains('''.cookie("cookie-key", "''')
test.contains('''response.cookie('cookie-key') != null''')
test.contains('''response.cookie('cookie-key') ==~ java.util.regex.Pattern.compile('[A-Za-z]+')''')
and:

View File

@@ -540,6 +540,7 @@ response:
- path: $.property2
type: by_regex
value: "[0-9]{3}"
regexType: as_integer
'''
Contract contractDsl = fromYaml(contract)
MethodBodyBuilder builder = methodBuilder(contractDsl)
@@ -929,10 +930,12 @@ request:
headers:
- key: 'Content-Type'
regex: 'application/json.*'
regexType: as_string
body:
- path: $.first_name
type: by_regex
value: '[\\p{L}]*'
regexType: as_string
- path: $.last_name
type: by_regex
value: '[\\p{L}]*'
@@ -1127,8 +1130,10 @@ request:
params:
- key: formParameter
regex: ".+"
regexType: as_string
- key: someBooleanParameter
predefined: any_boolean
regexType: as_boolean
named:
- paramName: file
fileName:
@@ -1191,6 +1196,7 @@ response:
- path: $.authorities[0]
type: by_regex
value: '^[a-zA-Z0-9_\\- ]+$'
regexType: as_string
'''
Contract contractDsl = fromYaml(contract)
MethodBodyBuilder builder = new HttpSpockMethodRequestProcessingBodyBuilder(contractDsl, properties, generatedClassDataForMethod)

View File

@@ -33,7 +33,6 @@ import org.springframework.cloud.contract.spec.internal.RegexPatterns
import org.springframework.cloud.contract.spec.internal.Url
import org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter
import org.springframework.cloud.contract.verifier.util.MapConverter
/**
* @author Marcin Grzejszczak
* @author Tim Ysewyn
@@ -125,7 +124,7 @@ class YamlContractConverterSpec extends Specification {
contract.request.body.clientValue == [foo: "bar"]
contract.request.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.foo'
contract.request.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.request.bodyMatchers.jsonPathRegexMatchers[0].value() == 'bar'
contract.request.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == 'bar'
and:
contract.response.status.clientValue == 200
if (yamlFile == ymlWithRest) contract.response.delay.clientValue == 1000 else !contract.response.delay
@@ -138,7 +137,7 @@ class YamlContractConverterSpec extends Specification {
contract.response.body.clientValue == [foo2: "bar", foo3: "baz", nullValue: null]
contract.response.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.foo2'
contract.response.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.response.bodyMatchers.jsonPathRegexMatchers[0].value() == 'bar'
contract.response.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == 'bar'
contract.response.bodyMatchers.jsonPathRegexMatchers[1].path() == '$.foo3'
contract.response.bodyMatchers.jsonPathRegexMatchers[1].matchingType() == MatchingType.COMMAND
contract.response.bodyMatchers.jsonPathRegexMatchers[1].value() == new ExecutionProperty('executeMe($it)')
@@ -217,29 +216,29 @@ class YamlContractConverterSpec extends Specification {
MatchingStrategy.Type.ABSENT, null)
contract.request.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.duck'
contract.request.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.request.bodyMatchers.jsonPathRegexMatchers[0].value() == '[0-9]{3}'
contract.request.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == '[0-9]{3}'
contract.request.bodyMatchers.jsonPathRegexMatchers[1].path() == '$.duck'
contract.request.bodyMatchers.jsonPathRegexMatchers[1].matchingType() == MatchingType.EQUALITY
contract.request.bodyMatchers.jsonPathRegexMatchers[2].path() == '$.alpha'
contract.request.bodyMatchers.jsonPathRegexMatchers[2].matchingType() == MatchingType.REGEX
contract.request.bodyMatchers.jsonPathRegexMatchers[2].value() == patterns.onlyAlphaUnicode().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[3].path() == '$.alpha'
contract.request.bodyMatchers.jsonPathRegexMatchers[3].matchingType() == MatchingType.EQUALITY
contract.request.bodyMatchers.jsonPathRegexMatchers[4].path() == '$.number'
contract.request.bodyMatchers.jsonPathRegexMatchers[4].matchingType() == MatchingType.REGEX
contract.request.bodyMatchers.jsonPathRegexMatchers[4].value() == patterns.number().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[4].value().pattern() == patterns.number().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[5].path() == '$.aBoolean'
contract.request.bodyMatchers.jsonPathRegexMatchers[5].matchingType() == MatchingType.REGEX
contract.request.bodyMatchers.jsonPathRegexMatchers[5].value() == patterns.anyBoolean().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[5].value().pattern() == patterns.anyBoolean().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[6].path() == '$.date'
contract.request.bodyMatchers.jsonPathRegexMatchers[6].matchingType() == MatchingType.DATE
contract.request.bodyMatchers.jsonPathRegexMatchers[6].value() == patterns.isoDate()
contract.request.bodyMatchers.jsonPathRegexMatchers[6].value().pattern() == patterns.isoDate().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[7].path() == '$.dateTime'
contract.request.bodyMatchers.jsonPathRegexMatchers[7].matchingType() == MatchingType.TIMESTAMP
contract.request.bodyMatchers.jsonPathRegexMatchers[7].value() == patterns.isoDateTime()
contract.request.bodyMatchers.jsonPathRegexMatchers[7].value().pattern() == patterns.isoDateTime().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[8].path() == '$.time'
contract.request.bodyMatchers.jsonPathRegexMatchers[8].matchingType() == MatchingType.TIME
contract.request.bodyMatchers.jsonPathRegexMatchers[8].value() == patterns.isoTime()
contract.request.bodyMatchers.jsonPathRegexMatchers[8].value().pattern() == patterns.isoTime().pattern()
contract.request.bodyMatchers.jsonPathRegexMatchers[9].path() == "\$.['key'].['complex.key']"
contract.request.bodyMatchers.jsonPathRegexMatchers[9].matchingType() == MatchingType.EQUALITY
contract.request.bodyMatchers.jsonPathRegexMatchers[10].path() == '$.valueWithMin'
@@ -258,29 +257,29 @@ class YamlContractConverterSpec extends Specification {
contract.response.status.clientValue == 200
contract.response.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.duck'
contract.response.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.response.bodyMatchers.jsonPathRegexMatchers[0].value() == '[0-9]{3}'
contract.response.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == '[0-9]{3}'
contract.response.bodyMatchers.jsonPathRegexMatchers[1].path() == '$.duck'
contract.response.bodyMatchers.jsonPathRegexMatchers[1].matchingType() == MatchingType.EQUALITY
contract.response.bodyMatchers.jsonPathRegexMatchers[2].path() == '$.alpha'
contract.response.bodyMatchers.jsonPathRegexMatchers[2].matchingType() == MatchingType.REGEX
contract.response.bodyMatchers.jsonPathRegexMatchers[2].value() == patterns.onlyAlphaUnicode().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[3].path() == '$.alpha'
contract.response.bodyMatchers.jsonPathRegexMatchers[3].matchingType() == MatchingType.EQUALITY
contract.response.bodyMatchers.jsonPathRegexMatchers[4].path() == '$.number'
contract.response.bodyMatchers.jsonPathRegexMatchers[4].matchingType() == MatchingType.REGEX
contract.response.bodyMatchers.jsonPathRegexMatchers[4].value() == patterns.number().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[4].value().pattern() == patterns.number().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[5].path() == '$.aBoolean'
contract.response.bodyMatchers.jsonPathRegexMatchers[5].matchingType() == MatchingType.REGEX
contract.response.bodyMatchers.jsonPathRegexMatchers[5].value() == patterns.anyBoolean().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[5].value().pattern() == patterns.anyBoolean().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[6].path() == '$.date'
contract.response.bodyMatchers.jsonPathRegexMatchers[6].matchingType() == MatchingType.DATE
contract.response.bodyMatchers.jsonPathRegexMatchers[6].value() == patterns.isoDate()
contract.response.bodyMatchers.jsonPathRegexMatchers[6].value().pattern() == patterns.isoDate().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[7].path() == '$.dateTime'
contract.response.bodyMatchers.jsonPathRegexMatchers[7].matchingType() == MatchingType.TIMESTAMP
contract.response.bodyMatchers.jsonPathRegexMatchers[7].value() == patterns.isoDateTime()
contract.response.bodyMatchers.jsonPathRegexMatchers[7].value().pattern() == patterns.isoDateTime().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[8].path() == '$.time'
contract.response.bodyMatchers.jsonPathRegexMatchers[8].matchingType() == MatchingType.TIME
contract.response.bodyMatchers.jsonPathRegexMatchers[8].value() == patterns.isoTime()
contract.response.bodyMatchers.jsonPathRegexMatchers[8].value().pattern() == patterns.isoTime().pattern()
contract.response.bodyMatchers.jsonPathRegexMatchers[9].path() == '$.valueWithTypeMatch'
contract.response.bodyMatchers.jsonPathRegexMatchers[9].matchingType() == MatchingType.TYPE
contract.response.bodyMatchers.jsonPathRegexMatchers[10].path() == '$.valueWithMin'
@@ -329,57 +328,57 @@ class YamlContractConverterSpec extends Specification {
((Pattern) it.clientValue).pattern == "application/json.*" && it.serverValue == "application/json" }
contract.input.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.duck'
contract.input.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.input.bodyMatchers.jsonPathRegexMatchers[0].value() == '[0-9]{3}'
contract.input.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == '[0-9]{3}'
contract.input.bodyMatchers.jsonPathRegexMatchers[1].path() == '$.duck'
contract.input.bodyMatchers.jsonPathRegexMatchers[1].matchingType() == MatchingType.EQUALITY
contract.input.bodyMatchers.jsonPathRegexMatchers[2].path() == '$.alpha'
contract.input.bodyMatchers.jsonPathRegexMatchers[2].matchingType() == MatchingType.REGEX
contract.input.bodyMatchers.jsonPathRegexMatchers[2].value() == patterns.onlyAlphaUnicode().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[3].path() == '$.alpha'
contract.input.bodyMatchers.jsonPathRegexMatchers[3].matchingType() == MatchingType.EQUALITY
contract.input.bodyMatchers.jsonPathRegexMatchers[4].path() == '$.number'
contract.input.bodyMatchers.jsonPathRegexMatchers[4].matchingType() == MatchingType.REGEX
contract.input.bodyMatchers.jsonPathRegexMatchers[4].value() == patterns.number().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[4].value().pattern() == patterns.number().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[5].path() == '$.aBoolean'
contract.input.bodyMatchers.jsonPathRegexMatchers[5].matchingType() == MatchingType.REGEX
contract.input.bodyMatchers.jsonPathRegexMatchers[5].value() == patterns.anyBoolean().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[5].value().pattern() == patterns.anyBoolean().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[6].path() == '$.date'
contract.input.bodyMatchers.jsonPathRegexMatchers[6].matchingType() == MatchingType.DATE
contract.input.bodyMatchers.jsonPathRegexMatchers[6].value() == patterns.isoDate()
contract.input.bodyMatchers.jsonPathRegexMatchers[6].value().pattern() == patterns.isoDate().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[7].path() == '$.dateTime'
contract.input.bodyMatchers.jsonPathRegexMatchers[7].matchingType() == MatchingType.TIMESTAMP
contract.input.bodyMatchers.jsonPathRegexMatchers[7].value() == patterns.isoDateTime()
contract.input.bodyMatchers.jsonPathRegexMatchers[7].value().pattern() == patterns.isoDateTime().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[8].path() == '$.time'
contract.input.bodyMatchers.jsonPathRegexMatchers[8].matchingType() == MatchingType.TIME
contract.input.bodyMatchers.jsonPathRegexMatchers[8].value() == patterns.isoTime()
contract.input.bodyMatchers.jsonPathRegexMatchers[8].value().pattern() == patterns.isoTime().pattern()
contract.input.bodyMatchers.jsonPathRegexMatchers[9].path() == "\$.['key'].['complex.key']"
contract.input.bodyMatchers.jsonPathRegexMatchers[9].matchingType() == MatchingType.EQUALITY
and:
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.duck'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].value() == '[0-9]{3}'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == '[0-9]{3}'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[1].path() == '$.duck'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[1].matchingType() == MatchingType.EQUALITY
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[2].path() == '$.alpha'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[2].matchingType() == MatchingType.REGEX
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[2].value() == patterns.onlyAlphaUnicode().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[3].path() == '$.alpha'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[3].matchingType() == MatchingType.EQUALITY
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[4].path() == '$.number'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[4].matchingType() == MatchingType.REGEX
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[4].value() == patterns.number().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[4].value().pattern() == patterns.number().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[5].path() == '$.aBoolean'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[5].matchingType() == MatchingType.REGEX
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[5].value() == patterns.anyBoolean().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[5].value().pattern() == patterns.anyBoolean().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[6].path() == '$.date'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[6].matchingType() == MatchingType.DATE
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[6].value() == patterns.isoDate()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[6].value().pattern() == patterns.isoDate().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[7].path() == '$.dateTime'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[7].matchingType() == MatchingType.TIMESTAMP
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[7].value() == patterns.isoDateTime()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[7].value().pattern() == patterns.isoDateTime().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[8].path() == '$.time'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[8].matchingType() == MatchingType.TIME
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[8].value() == patterns.isoTime()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[8].value().pattern() == patterns.isoTime().pattern()
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[9].path() == '$.valueWithTypeMatch'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[9].matchingType() == MatchingType.TYPE
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[10].path() == '$.valueWithMin'
@@ -462,7 +461,7 @@ class YamlContractConverterSpec extends Specification {
contract.input.messageBody.clientValue == [foo: "bar"]
contract.input.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.bar'
contract.input.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.input.bodyMatchers.jsonPathRegexMatchers[0].value() == 'bar'
contract.input.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == 'bar'
and:
contract.outputMessage.assertThat.toString() == "baz()"
contract.outputMessage.headers.entries.find { it.name == "foo2" &&
@@ -474,7 +473,7 @@ class YamlContractConverterSpec extends Specification {
contract.outputMessage.body.clientValue == [foo2: "bar", foo3: "baz"]
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].path() == '$.foo2'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].matchingType() == MatchingType.REGEX
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].value() == 'bar'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[0].value().pattern() == 'bar'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[1].path() == '$.foo3'
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[1].matchingType() == MatchingType.COMMAND
contract.outputMessage.bodyMatchers.jsonPathRegexMatchers[1].value() == new ExecutionProperty('executeMe($it)')

View File

@@ -906,7 +906,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
stubMappingIsValidWireMockStub(json)
}
def "should not allow regexp in url for server value"() {
def "should not allow not matching query param for server value"() {
when:
org.springframework.cloud.contract.spec.Contract.make {
request {
@@ -924,7 +924,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
then:
def e = thrown(IllegalStateException)
e.message.contains "Url can't be a pattern for the server side"
e.message.contains "Query parameter 'age' can't be of a matching type: NOT_MATCHING for the server side"
}
def "should not allow regexp in query parameter for server value"() {