-
Notifications
You must be signed in to change notification settings - Fork 15
/
rest_app.feature
172 lines (165 loc) · 5.91 KB
/
rest_app.feature
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Using step definitions from: '../steps'
@rest
Feature: REST App
CorePost should be able to build REST applications
for nested REST resources
Background:
Given 'rest_resource' is running
# make sure it is empty
When as user 'None:None' I DELETE 'http://127.0.0.1:8085/customer'
Then I expect HTTP code 200
# add a few default customers
When as user 'None:None' I POST 'http://127.0.0.1:8085/customer' with 'customerId=d1&firstName=John&lastName=Doe1'
Then I expect HTTP code 201
When as user 'None:None' I POST 'http://127.0.0.1:8085/customer' with 'customerId=d2&firstName=John&lastName=Doe2'
Then I expect HTTP code 201
When as user 'None:None' I POST 'http://127.0.0.1:8085/customer' with 'customerId=d3&firstName=John&lastName=Doe3'
Then I expect HTTP code 201
@customer
Scenario: Full Customer lifecycle
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer'
Then I expect HTTP code 200
And I expect JSON content
"""
[
{
"addresses": {},
"customerId": "d2",
"firstName": "John",
"lastName": "Doe2"
},
{
"addresses": {},
"customerId": "d3",
"firstName": "John",
"lastName": "Doe3"
},
{
"addresses": {},
"customerId": "d1",
"firstName": "John",
"lastName": "Doe1"
}
]
"""
# add 1
When as user 'None:None' I POST 'http://127.0.0.1:8085/customer' with 'customerId=c1&firstName=John&lastName=Doe'
Then I expect HTTP code 201
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/c1'
Then I expect HTTP code 200
And I expect JSON content
"""
{
"addresses": {},
"customerId": "c1",
"firstName": "John",
"lastName": "Doe"
}
"""
# update
When as user 'None:None' I PUT 'http://127.0.0.1:8085/customer/c1' with 'firstName=Jill&lastName=Jones'
Then I expect HTTP code 200
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/c1'
Then I expect HTTP code 200
And I expect JSON content
"""
{
"addresses": {},
"customerId": "c1",
"firstName": "Jill",
"lastName": "Jones"
}
"""
# delete
When as user 'None:None' I DELETE 'http://127.0.0.1:8085/customer/c1'
Then I expect HTTP code 200
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/c1'
Then I expect HTTP code 404
# delete all
When as user 'None:None' I DELETE 'http://127.0.0.1:8085/customer'
Then I expect HTTP code 200
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer'
Then I expect HTTP code 200
And I expect JSON content
"""
[]
"""
@customer_address
Scenario: Full Customer Address lifecycle
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/d1/address'
Then I expect HTTP code 200
And I expect JSON content
"""
{}
"""
# add 1
When as user 'None:None' I POST 'http://127.0.0.1:8085/customer/d1/address' with 'addressId=HOME&streetNumber=100&streetName=MyStreet&stateCode=CA&countryCode=US'
Then I expect HTTP code 201
# get just the address
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/d1/address/HOME'
Then I expect HTTP code 200
And I expect JSON content
"""
{
"countryCode": "US",
"stateCode": "CA",
"streetName": "MyStreet",
"streetNumber": "100"
}
"""
# get the customer with the address
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/d1'
Then I expect HTTP code 200
And I expect JSON content
"""
{
"addresses": {
"HOME": {
"countryCode": "US",
"stateCode": "CA",
"streetName": "MyStreet",
"streetNumber": "100"
}
},
"customerId": "d1",
"firstName": "John",
"lastName": "Doe1"
}
"""
# update address
When as user 'None:None' I PUT 'http://127.0.0.1:8085/customer/d1/address/HOME' with 'streetNumber=1002&streetName=MyStreet2&stateCode=CA&countryCode=US'
Then I expect HTTP code 200
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/d1/address/HOME'
Then I expect HTTP code 200
And I expect JSON content
"""
{
"countryCode": "US",
"stateCode": "CA",
"streetName": "MyStreet2",
"streetNumber": "1002"
}
"""
# delete address
When as user 'None:None' I DELETE 'http://127.0.0.1:8085/customer/d1/address/HOME'
Then I expect HTTP code 200
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/d1/address/HOME'
Then I expect HTTP code 404
@customer @xml @issue4
Scenario: Customers as XML (Issue #4)
# all
When I prepare HTTP header 'Accept' = 'application/xml'
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer'
Then I expect HTTP code 200
Then I expect content contains '<list><item><lastName>Doe2</lastName><customerId>d2</customerId><firstName>John</firstName><addresses></addresses></item><item><lastName>Doe3</lastName><customerId>d3</customerId><firstName>John</firstName><addresses></addresses></item><item><lastName>Doe1</lastName><customerId>d1</customerId><firstName>John</firstName><addresses></addresses></item></list>'
# 1
When I prepare HTTP header 'Accept' = 'application/xml'
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/d2'
Then I expect HTTP code 200
Then I expect content contains '<item><lastName>Doe2</lastName><customerId>d2</customerId><firstName>John</firstName><addresses></addresses></item>'
# 1 with address
When as user 'None:None' I POST 'http://127.0.0.1:8085/customer/d2/address' with 'addressId=HOME&streetNumber=100&streetName=MyStreet&stateCode=CA&countryCode=US'
When I prepare HTTP header 'Accept' = 'application/xml'
When as user 'None:None' I GET 'http://127.0.0.1:8085/customer/d2'
Then I expect HTTP code 200
Then I expect content contains '<item><lastName>Doe2</lastName><customerId>d2</customerId><firstName>John</firstName><addresses><HOME><countryCode>US</countryCode><streetName>MyStreet</streetName><streetNumber>100</streetNumber><stateCode>CA</stateCode></HOME></addresses></item>'