Improve license scan result
[externalapi/nbi.git] / src / test / resources / karatetest / features / 05--ListenerResourceTestTarget.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: Listener
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: testcreateEventSubscription
37 Given path 'hub'
38 And header Target = 'http://localhost:8080/nbi/api/v4'
39 And request data[0]
40 When method post
41 Then status 201
42 And def hubId = $.id
43 And header Target = 'http://localhost:8080/nbi/api/v4'
44 Given path 'hub',hubId
45 When method get
46 Then status 200
47 And match hubId == $.id
48 Given path 'hub',hubId
49 And header Target = 'http://localhost:8080/nbi/api/v4'
50 When method delete
51 Then status 204
52
53 Scenario: testPostListenerResource
54 * def listenerUrl = nbiBaseUrl + "/test/listener"
55 Given path 'test/listener'
56 When method delete
57 Then status 204
58 Given path 'hub'
59 And header Target = 'http://localhost:8080/nbi/api/v4'
60 And request { callback : '#(listenerUrl)' , query : 'eventType = ServiceOrderCreationNotification' }
61 When method post
62 Then status 201
63 And def hubId = $.id
64 Given path 'serviceOrder'
65 And request serviceOrderData[17]
66 And header Target = 'http://localhost:8080/nbi/api/v4'
67 When method post
68 Then status 201
69 And def serviceOrderId = $.id
70 Given path 'test/listener'
71 And params {serviceOrderId : '#(serviceOrderId)'}
72 And retry until responseStatus == 200
73 When method get
74 And assert response.length == 1
75 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceOrderCreationNotification' , eventDate : '#notnull' , event :'#notnull'}
76 And def eventId = $[0].eventId
77 And def eventDate = $[0].eventDate
78 And call checkDateFormat(eventDate)
79 Given path 'serviceOrder',serviceOrderId
80 When method delete
81 Then status 204
82 Given path 'hub',hubId
83 And header Target = 'http://localhost:8080/nbi/api/v4'
84 When method delete
85 Then status 204
86 Given path 'test/listener',eventId
87 When method delete
88 Then status 204