Sync docs from 1.0.x to gh-pages
This commit is contained in:
@@ -1788,7 +1788,7 @@ org.springframework.cloud.contract.spec.Contract.make {
|
||||
method 'PUT' // (2)
|
||||
url '/fraudcheck' // (3)
|
||||
body([ // (4)
|
||||
clientId: $(regex('[0-9]{10}')),
|
||||
"client.id": $(regex('[0-9]{10}')),
|
||||
loanAmount: 99999
|
||||
])
|
||||
headers { // (5)
|
||||
@@ -1799,7 +1799,7 @@ org.springframework.cloud.contract.spec.Contract.make {
|
||||
status 200 // (7)
|
||||
body([ // (8)
|
||||
fraudCheckStatus: "FRAUD",
|
||||
rejectionReason: "Amount too high"
|
||||
"rejection.reason": "Amount too high"
|
||||
])
|
||||
headers { // (9)
|
||||
contentType('application/vnd.fraud.v1+json')
|
||||
@@ -7059,7 +7059,7 @@ String nonBlank() {
|
||||
response.header('Content-Type') == 'application/json'
|
||||
and:
|
||||
DocumentContext parsedJson = JsonPath.parse(response.body.asString())
|
||||
assertThatJson(parsedJson).field("code").matches("(123123)?")
|
||||
assertThatJson(parsedJson).field("['code']").matches("(123123)?")
|
||||
"""</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
@@ -7074,9 +7074,9 @@ String nonBlank() {
|
||||
"url" : "/users/password",
|
||||
"method" : "POST",
|
||||
"bodyPatterns" : [ {
|
||||
"matchesJsonPath" : "$[?(@.email =~ /([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,4})?/)]"
|
||||
"matchesJsonPath" : "$[?(@.['email'] =~ /([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,4})?/)]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$[?(@.callback_url =~ /((http[s]?|ftp):\\\\/)\\\\/?([^:\\\\/\\\\s]+)(:[0-9]{1,5})?/)]"
|
||||
"matchesJsonPath" : "$[?(@.['callback_url'] =~ /((http[s]?|ftp):\\\\/)\\\\/?([^:\\\\/\\\\s]+)(:[0-9]{1,5})?/)]"
|
||||
} ],
|
||||
"headers" : {
|
||||
"Content-Type" : {
|
||||
@@ -7267,7 +7267,10 @@ will result in calling a <code>foo</code> method to which the value matching the
|
||||
dateTime: "2017-01-01T01:23:45",
|
||||
time: "01:02:34",
|
||||
valueWithoutAMatcher: "foo",
|
||||
valueWithTypeMatch: "string"
|
||||
valueWithTypeMatch: "string",
|
||||
key: [
|
||||
'complex.key' : 'foo'
|
||||
]
|
||||
])
|
||||
stubMatchers {
|
||||
jsonPath('$.duck', byRegex("[0-9]{3}"))
|
||||
@@ -7279,6 +7282,7 @@ will result in calling a <code>foo</code> method to which the value matching the
|
||||
jsonPath('$.date', byDate())
|
||||
jsonPath('$.dateTime', byTimestamp())
|
||||
jsonPath('$.time', byTime())
|
||||
jsonPath("\$.['key'].['complex.key']", byEquality())
|
||||
}
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
@@ -7307,6 +7311,9 @@ will result in calling a <code>foo</code> method to which the value matching the
|
||||
],
|
||||
valueWithMinEmpty: [],
|
||||
valueWithMaxEmpty: [],
|
||||
key: [
|
||||
'complex.key' : 'foo'
|
||||
]
|
||||
])
|
||||
testMatchers {
|
||||
// asserts the jsonpath value against manual regex
|
||||
@@ -7347,6 +7354,7 @@ will result in calling a <code>foo</code> method to which the value matching the
|
||||
})
|
||||
// will execute a method `assertThatValueIsANumber`
|
||||
jsonPath('$.duck', byCommand('assertThatValueIsANumber($it)'))
|
||||
jsonPath("\$.['key'].['complex.key']", byEquality())
|
||||
}
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
@@ -7445,15 +7453,15 @@ assertions and the one from matchers with an <code>and</code> section):</p>
|
||||
}
|
||||
},
|
||||
"bodyPatterns" : [ {
|
||||
"matchesJsonPath" : "$[?(@.valueWithoutAMatcher == 'foo')]"
|
||||
"matchesJsonPath" : "$[?(@.['valueWithoutAMatcher'] == 'foo')]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$[?(@.valueWithTypeMatch == 'string')]"
|
||||
"matchesJsonPath" : "$[?(@.['valueWithTypeMatch'] == 'string')]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$.list.some.nested[?(@.anothervalue == 4)]"
|
||||
"matchesJsonPath" : "$.['list'].['some'].['nested'][?(@.['anothervalue'] == 4)]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$.list.someother.nested[?(@.anothervalue == 4)]"
|
||||
"matchesJsonPath" : "$.['list'].['someother'].['nested'][?(@.['anothervalue'] == 4)]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$.list.someother.nested[?(@.json == 'with value')]"
|
||||
"matchesJsonPath" : "$.['list'].['someother'].['nested'][?(@.['json'] == 'with value')]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$[?(@.duck =~ /([0-9]{3})/)]"
|
||||
}, {
|
||||
@@ -7531,7 +7539,7 @@ assertions and the one from matchers with an <code>and</code> section):</p>
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
// and:
|
||||
DocumentContext parsedJson = JsonPath.parse(responseAsString);
|
||||
assertThatJson(parsedJson).field("property1").isEqualTo("a");
|
||||
assertThatJson(parsedJson).field("['property1']").isEqualTo("a");
|
||||
'''</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user