-
Notifications
You must be signed in to change notification settings - Fork 0
/
placeOrder.groovy
34 lines (32 loc) · 1.06 KB
/
placeOrder.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package contracts
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method 'POST'
url '/orders'
headers {
contentType('application/json')
}
body(
"name": $(consumer(regex('[^0-9\\_\\!\\¡\\?\\÷\\?\\¿\\/\\+\\=\\@\\#\$\\%\\ˆ\\&\\*\\(\\)\\{\\}\\|\\~\\<\\>\\;\\:\\[\\]]{2,}')), producer('Jane Doe')),
"items": [
[
"id": "6b76148d-0fda-4ebf-8966-d91bfaeb0236",
"amount": 1
],
],
)
bodyMatchers {
jsonPath('$.items', byType { minOccurrence(1) })
jsonPath('$.items[0].id', byRegex(uuid()))
jsonPath('$.items[0].amount', byRegex(positiveInt()))
}
}
response {
status CREATED()
headers {
header('Location', $(consumer('/orders/9bb544af-3df5-476b-bff9-17984e8e5e0a'),
producer(regex('\\/orders\\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}'))))
}
}
}