6e4b884604b83ae95e7cb7085e2066c302b6fc35
[externalapi/nbi.git] / src / test / resources / karatetest / features / 03--Subscriber.feature
1 # new feature
2 # Tags: optional
3     
4 Feature: Subscriber
5
6 Background:
7 * url nbiBaseUrl
8 * def Context = Java.type('org.onap.nbi.test.Context');
9 * call Context.startServers();
10 * def data = read('../data/subscriber.json')
11 * def serviceOrderData = read('../data/serviceOrder.json')
12 * configure retry = { count: 10, interval: 500 }
13 * def checkDateFormat =
14 """
15 function(s) {
16   var SimpleDateFormat = Java.type("java.text.SimpleDateFormat");
17   var sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
18   return sdf.parse(s);
19 }
20 """
21
22 Scenario: testFindWhenNoSubscriber
23 Given path 'hub'
24 When method get
25 Then status 200
26 And match $ == '#[0]'
27
28 Scenario: testCreationAndFindSubscriber
29 Given path 'hub'
30 And request data[0]
31 When method post
32 Then status 201
33 And def location = responseHeaders['Location'][0]
34 Given path 'hub'
35 When method get
36 And match $ == '#[1]'
37 Given url location
38 When method delete
39 Then status 204
40
41 Scenario: testCreation2SameSubscribers
42 Given path 'hub'
43 And request data[0]
44 When method post
45 Then status 201
46 And def location = responseHeaders['Location'][0]
47 Given path 'hub'
48 And request data[0]
49 When method post
50 Then status 400
51 And match $ contains { message : 'Bad Request'}
52 Given path 'hub'
53 When method get
54 And match $ == '#[1]'
55 Given url location
56 When method delete
57 Then status 204
58
59 Scenario: testGetByIdSubscriber
60 Given path 'hub'
61 And request data[0]
62 When method post
63 Then status 201
64 Given path 'hub'
65 When method get
66 And def Id = $[0].id
67 Given path 'hub',Id
68 When method get
69 And match $ contains { callback : 'http://localhost:8080/test' , query : 'eventType=ServiceOrderCreationNotification' }
70 Given path 'hub',Id
71 When method delete
72 Then status 204
73
74 Scenario: testFindSubscriber
75 Given path 'hub'
76 And request data[1]
77 When method post
78 Then status 201
79 And def location1 = responseHeaders['Location'][0]
80 Given path 'hub'
81 And request data[2]
82 When method post
83 Then status 201
84 And def location2 = responseHeaders['Location'][0]
85 Given path 'hub'
86 When method get
87 Then status 200
88 And match $ == '#notnull'
89 Given url location1
90 When method delete
91 Then status 204
92 Given url location2
93 When method delete
94 Then status 204
95
96 Scenario: testFindWithFilteringSubscriber
97 Given path 'hub'
98 And request data[0]
99 When method post
100 Then status 201
101 And def location = responseHeaders['Location'][0]
102 Given path 'hub'
103 And params { query.eventType : 'ServiceOrderCreationNotification' }
104 When method get
105 Then status 200
106 And match $ == '#[1]'
107 Given url location
108 When method delete
109 Then status 204
110
111 Scenario: testSubscriberDeletion
112 Given path 'hub'
113 And request { id : 'id', callback : 'http://localhost:8080/test' , query : 'eventType = ServiceOrderCreationNotification' }
114 When method post
115 Then status 201
116 Given path 'hub'
117 When method get
118 And def Id = $[0].id
119 Given path 'hub',Id
120 When method delete
121 Then status 204
122
123 Scenario: testSubscriberWithTestListener
124 * def listenerUrl = nbiBaseUrl + "/test/listener"
125 Given path 'test/listener'
126 When method delete
127 Then status 204
128 Given path 'hub'
129 And request { id : 'id', callback : '#(listenerUrl)' , query : 'eventType = ServiceOrderCreationNotification' }
130 When method post
131 Then status 201
132 Given path 'hub'
133 When method get
134 And def hubId = $[0].id
135 Given path 'serviceOrder'
136 And request serviceOrderData[17]
137 When method post
138 Then status 201
139 And def serviceOrderId = $.id
140 Given path 'test/listener'
141 And params {serviceOrderId : '#(serviceOrderId)'}
142 And retry until responseStatus == 200
143 When method get
144 And assert response.length == 1
145 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceOrderCreationNotification' , eventDate : '#notnull' , event :'#notnull'}
146 And def eventId = $[0].eventId
147 And def eventDate = $[0].eventDate
148 And call checkDateFormat(eventDate)
149 Given path 'hub',hubId
150 When method delete
151 Then status 204
152 Given path 'test/listener',eventId
153 When method delete
154 Then status 204
155 Given path 'serviceOrder',serviceOrderId
156 When method delete
157 Then status 204