Improve license scan result
[externalapi/nbi.git] / src / test / resources / karatetest / features / 03--Subscriber.feature
1 #    Copyright (c) 2018 Orange
2 #
3 #    Licensed under the Apache License, Version 2.0 (the "License");
4 #    you may not use this file except in compliance with the License.
5 #    You may obtain a copy of the License at
6 #
7 #        http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS,
11 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #    See the License for the specific language governing permissions and
13 #    limitations under the License.swagger: "2.0"
14
15 # new feature
16 # Tags: optional
17     
18 Feature: Subscriber
19
20 Background:
21 * url nbiBaseUrl
22 * def Context = Java.type('org.onap.nbi.test.Context');
23 * call Context.startServers();
24 * def data = read('../data/subscriber.json')
25 * def serviceOrderData = read('../data/serviceOrder.json')
26 * configure retry = { count: 10, interval: 500 }
27 * def checkDateFormat =
28 """
29 function(s) {
30   var SimpleDateFormat = Java.type("java.text.SimpleDateFormat");
31   var sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
32   return sdf.parse(s);
33 }
34 """
35
36 Scenario: testFindWhenNoSubscriber
37 Given path 'hub'
38 When method get
39 Then status 200
40 And match $ == '#[0]'
41
42 Scenario: testCreationAndFindSubscriber
43 Given path 'hub'
44 And request data[0]
45 When method post
46 Then status 201
47 And def location = responseHeaders['Location'][0]
48 Given path 'hub'
49 When method get
50 And match $ == '#[1]'
51 Given url location
52 When method delete
53 Then status 204
54
55 Scenario: testCreation2SameSubscribers
56 Given path 'hub'
57 And request data[0]
58 When method post
59 Then status 201
60 And def location = responseHeaders['Location'][0]
61 Given path 'hub'
62 And request data[0]
63 When method post
64 Then status 400
65 And match $ contains { message : 'Bad Request'}
66 Given path 'hub'
67 When method get
68 And match $ == '#[1]'
69 Given url location
70 When method delete
71 Then status 204
72
73 Scenario: testGetByIdSubscriber
74 Given path 'hub'
75 And request data[0]
76 When method post
77 Then status 201
78 Given path 'hub'
79 When method get
80 And def Id = $[0].id
81 Given path 'hub',Id
82 When method get
83 And match $ contains { callback : 'http://localhost:8080/test' , query : 'eventType=ServiceOrderCreationNotification' }
84 Given path 'hub',Id
85 When method delete
86 Then status 204
87
88 Scenario: testFindSubscriber
89 Given path 'hub'
90 And request data[1]
91 When method post
92 Then status 201
93 And def location1 = responseHeaders['Location'][0]
94 Given path 'hub'
95 And request data[2]
96 When method post
97 Then status 201
98 And def location2 = responseHeaders['Location'][0]
99 Given path 'hub'
100 When method get
101 Then status 200
102 And match $ == '#notnull'
103 Given url location1
104 When method delete
105 Then status 204
106 Given url location2
107 When method delete
108 Then status 204
109
110 Scenario: testFindWithFilteringSubscriber
111 Given path 'hub'
112 And request data[0]
113 When method post
114 Then status 201
115 And def location = responseHeaders['Location'][0]
116 Given path 'hub'
117 And params { query.eventType : 'ServiceOrderCreationNotification' }
118 When method get
119 Then status 200
120 And match $ == '#[1]'
121 Given url location
122 When method delete
123 Then status 204
124
125 Scenario: testSubscriberDeletion
126 Given path 'hub'
127 And request { id : 'id', callback : 'http://localhost:8080/test' , query : 'eventType = ServiceOrderCreationNotification' }
128 When method post
129 Then status 201
130 Given path 'hub'
131 When method get
132 And def Id = $[0].id
133 Given path 'hub',Id
134 When method delete
135 Then status 204
136
137 Scenario: testSubscriberWithTestListener
138 * def listenerUrl = nbiBaseUrl + "/test/listener"
139 Given path 'test/listener'
140 When method delete
141 Then status 204
142 Given path 'hub'
143 And request { id : 'id', callback : '#(listenerUrl)' , query : 'eventType = ServiceOrderCreationNotification' }
144 When method post
145 Then status 201
146 Given path 'hub'
147 When method get
148 And def hubId = $[0].id
149 Given path 'serviceOrder'
150 And request serviceOrderData[17]
151 When method post
152 Then status 201
153 And def serviceOrderId = $.id
154 Given path 'test/listener'
155 And params {serviceOrderId : '#(serviceOrderId)'}
156 And retry until responseStatus == 200
157 When method get
158 And assert response.length == 1
159 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceOrderCreationNotification' , eventDate : '#notnull' , event :'#notnull'}
160 And def eventId = $[0].eventId
161 And def eventDate = $[0].eventDate
162 And call checkDateFormat(eventDate)
163 Given path 'hub',hubId
164 When method delete
165 Then status 204
166 Given path 'test/listener',eventId
167 When method delete
168 Then status 204
169 Given path 'serviceOrder',serviceOrderId
170 When method delete
171 Then status 204
172
173
174 Scenario: testSubscriberWithTestListenerForServiceInventorCreationEvents
175 * def listenerUrl = nbiBaseUrl + "/test/listener"
176 Given path 'test/listener'
177 When method delete
178 Then status 204
179 Given path 'hub'
180 And request { id : 'id', callback : '#(listenerUrl)' , query : 'eventType = ServiceCreationNotification' }
181 When method post
182 Then status 201
183 Given path 'hub'
184 When method get
185 And def hubId = $[0].id
186 Given path 'hub/testaaievents'
187 Then status 200
188 When method get
189 Given path 'test/listener'
190 And params {serviceInstanceId : 'new-test5'}
191 And retry until responseStatus == 200
192 When method get
193 And assert response.length == 1
194 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceCreationNotification' , eventDate : '#notnull' , event :'#notnull'}
195 And def eventId = $[0].eventId
196 And def eventDate = $[0].eventDate
197 And call checkDateFormat(eventDate)
198 Given path 'hub',hubId
199 When method delete
200 Then status 204
201 Given path 'test/listener',eventId
202 When method delete
203 Then status 204
204
205 Scenario: testSubscriberWithTestListenerForServiceInventoryUpdateEvents
206 * def listenerUrl = nbiBaseUrl + "/test/listener"
207 Given path 'test/listener'
208 When method delete
209 Then status 204
210 Given path 'hub'
211 And request { id : 'id', callback : '#(listenerUrl)' , query : 'eventType = ServiceAttributeValueChangeNotification' }
212 When method post
213 Then status 201
214 Given path 'hub'
215 When method get
216 And def hubId = $[0].id
217 Given path 'hub/testaaievents'
218 Then status 200
219 When method get
220 Given path 'test/listener'
221 And params {serviceInstanceId : 'new-test5'}
222 And retry until responseStatus == 200
223 When method get
224 And assert response.length == 1
225 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceAttributeValueChangeNotification' , eventDate : '#notnull' , event :'#notnull'}
226 And def eventId = $[0].eventId
227 And def eventDate = $[0].eventDate
228 And call checkDateFormat(eventDate)
229 Given path 'hub',hubId
230 When method delete
231 Then status 204
232 Given path 'test/listener',eventId
233 When method delete
234 Then status 204
235
236 Scenario: testSubscriberWithTestListenerForServiceInventoryRemoveEvents
237 * def listenerUrl = nbiBaseUrl + "/test/listener"
238 Given path 'test/listener'
239 When method delete
240 Then status 204
241 Given path 'hub'
242 And request { id : 'id', callback : '#(listenerUrl)' , query : 'eventType = ServiceRemoveNotification' }
243 When method post
244 Then status 201
245 Given path 'hub'
246 When method get
247 And def hubId = $[0].id
248 Given path 'hub/testaaievents'
249 Then status 200
250 When method get
251 Given path 'test/listener'
252 And params {serviceInstanceId : 'new-test5'}
253 And retry until responseStatus == 200
254 When method get
255 And assert response.length == 1
256 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceRemoveNotification' , eventDate : '#notnull' , event :'#notnull'}
257 And def eventId = $[0].eventId
258 And def eventDate = $[0].eventDate
259 And call checkDateFormat(eventDate)
260 Given path 'hub',hubId
261 When method delete
262 Then status 204
263 Given path 'test/listener',eventId
264 When method delete
265 Then status 204