Added HttpStatus delegate in the Groovy DSL Response
with this change there are numerous helper methods that should provide a more descriptive DSL for the response status. Instead of a numerical status you can now call a method e.g. instead of 200 call OK() fixes gh-575
This commit is contained in:
@@ -371,7 +371,7 @@ Contract.make {
|
||||
}
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
status OK()
|
||||
body('''
|
||||
bar
|
||||
''')
|
||||
|
||||
@@ -357,10 +357,13 @@ include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=response,
|
||||
include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=response_obligatory,indent=0]
|
||||
----
|
||||
|
||||
|
||||
Besides status, the response may contain **headers** and a **body**, both of which are
|
||||
specified the same way as in the request (see the previous paragraph).
|
||||
|
||||
TIP: Via the Groovy DSL you can reference the `org.springframework.cloud.contract.spec.internal.HttpStatus`
|
||||
methods to provide a meaningful status instead of a digit. E.g. you can call
|
||||
`OK()` for a status `200` or `BAD_REQUEST()` for `400`.
|
||||
|
||||
=== Dynamic properties
|
||||
|
||||
The contract can contain some dynamic properties: timestamps, IDs, and so on. You do not
|
||||
@@ -929,7 +932,7 @@ Contract.make {
|
||||
url("/foo")
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
status OK()
|
||||
body(events: [[
|
||||
operation : 'EXPORT',
|
||||
eventId : '16f1ed75-0bcc-4f0d-a04d-3121798faf99',
|
||||
@@ -1007,7 +1010,7 @@ org.springframework.cloud.contract.spec.Contract.make {
|
||||
url '/get'
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
status OK()
|
||||
body 'Passed'
|
||||
async()
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ org.springframework.cloud.contract.spec.Contract.make {
|
||||
])
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
status OK()
|
||||
body([
|
||||
time : value(producer(regex('[0-9]{4}-[0-9]{2}-[0-9]{2} [0-2][0-9]-[0-5][0-9]-[0-5][0-9]')),
|
||||
id: value([producer(regex('[0-9a-zA-z]{8}-[0-9a-zA-z]{4}-[0-9a-zA-z]{4}-[0-9a-zA-z]{12}'))
|
||||
|
||||
@@ -249,7 +249,7 @@ org.springframework.cloud.contract.spec.Contract.make {
|
||||
}
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
status OK()
|
||||
body([
|
||||
fraudCheckStatus: "FRAUD",
|
||||
"rejection.reason": "Amount too high"
|
||||
|
||||
Reference in New Issue
Block a user