-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCatalogItems.groovy
46 lines (44 loc) · 1.39 KB
/
getCatalogItems.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
35
36
37
38
39
40
41
42
43
44
45
46
package contracts
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method 'GET'
url '/catalog/items'
headers {
accept('application/json')
}
}
response {
status OK()
headers {
contentType('application/json')
}
body([
[
"id": "6b76148d-0fda-4ebf-8966-d91bfaeb0236",
"name": "Breakfast with homemade bread",
"img": "https://images.unsplash.com/photo-1590688178590-bb8370b70528",
"price": 16,
],
[
"id": "52d59380-79da-49d5-9d09-9716e20ccbc4",
"name": "Brisket",
"img": "https://images.unsplash.com/photo-1592894869086-f828b161e90a",
"price": 24,
],
[
"id": "a7be01f8-b76e-4384-bf1d-e69d7bdbe4b4",
"name": "Pork Ribs",
"img": "https://images.unsplash.com/photo-1544025162-d76694265947",
"price": 20,
],
])
bodyMatchers {
jsonPath('$', byType { minOccurrence(1) })
jsonPath('$[*].id', byRegex(uuid()))
jsonPath('$[*].name', byRegex("[a-zA-Z \\-]+"))
jsonPath('$[*].img', byRegex(url()))
jsonPath('$[*].price', byRegex(positiveInt()))
}
}
}