0d21ccbc6c05458f82bd1ef18ee15ba862718712
[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: testGetByIdSubscriber
42 Given path 'hub'
43 And request data[0]
44 When method post
45 Then status 201
46 Given path 'hub'
47 When method get
48 And def Id = $[0].id
49 Given path 'hub',Id
50 When method get
51 And match $ contains { callback : 'http://localhost:8080/test' , query : 'eventType=ServiceOrderCreationNotification' }
52 Given path 'hub',Id
53 When method delete
54 Then status 204
55
56 Scenario: testFindSubscriber
57 Given path 'hub'
58 And request data[1]
59 When method post
60 Then status 201
61 And def location1 = responseHeaders['Location'][0]
62 Given path 'hub'
63 And request data[2]
64 When method post
65 Then status 201
66 And def location2 = responseHeaders['Location'][0]
67 Given path 'hub'
68 When method get
69 Then status 200
70 And match $ == '#notnull'
71 Given url location1
72 When method delete
73 Then status 204
74 Given url location2
75 When method delete
76 Then status 204
77
78 Scenario: testFindWithFilteringSubscriber
79 Given path 'hub'
80 And request data[0]
81 When method post
82 Then status 201
83 And def location = responseHeaders['Location'][0]
84 Given path 'hub'
85 And params { query.eventType : 'ServiceOrderCreationNotification' }
86 When method get
87 Then status 200
88 And match $ == '#[1]'
89 Given url location
90 When method delete
91 Then status 204
92
93 Scenario: testSubscriberDeletion
94 Given path 'hub'
95 And request { id : 'id', callback : 'http://localhost:8080/test' , query : 'eventType = ServiceOrderCreationNotification' }
96 When method post
97 Then status 201
98 Given path 'hub'
99 When method get
100 And def Id = $[0].id
101 Given path 'hub',Id
102 When method delete
103 Then status 204
104
105 Scenario: testSubscriberWithTestListener
106 * def listenerUrl = nbiBaseUrl + "/test/listener"
107 Given path 'test/listener'
108 When method delete
109 Then status 204
110 Given path 'hub'
111 And request { id : 'id', callback : '#(listenerUrl)' , query : 'eventType = ServiceOrderCreationNotification' }
112 When method post
113 Then status 201
114 Given path 'hub'
115 When method get
116 And def hubId = $[0].id
117 Given path 'serviceOrder'
118 And request serviceOrderData[17]
119 When method post
120 Then status 201
121 And def serviceOrderId = $.id
122 Given path 'test/listener'
123 And params {serviceOrderId : '#(serviceOrderId)'}
124 And retry until responseStatus == 200
125 When method get
126 And assert response.length == 1
127 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceOrderCreationNotification' , eventDate : '#notnull' , event :'#notnull'}
128 And def eventId = $[0].eventId
129 And def eventDate = $[0].eventDate
130 And call checkDateFormat(eventDate)
131 Given path 'hub',hubId
132 When method delete
133 Then status 204
134 Given path 'test/listener',eventId
135 When method delete
136 Then status 204
137 Given path 'serviceOrder',serviceOrderId
138 When method delete
139 Then status 204