3a41c349035e2250e9ce05dd58ed1309b98ef120
[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 * def checkDateFormat =
13 """
14 function(s) {
15   var SimpleDateFormat = Java.type("java.text.SimpleDateFormat");
16   var sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
17   return sdf.parse(s);
18 }
19 """
20
21 Scenario: testFindWhenNoSubscriber
22 Given path 'hub'
23 When method get
24 Then status 200
25 And match $ == '#[0]'
26
27 Scenario: testCreationAndFindSubscriber
28 Given path 'hub'
29 And request data[0]
30 When method post
31 Then status 201
32 Given url 'http://localhost:8080/nbi/api/v3/hub/'
33 When method get
34 And match $ == '#[1]'
35
36 Scenario: testGetByIdSubscriber
37 Given path 'hub'
38 When method get
39 And def Id = $[0].id
40 Given path 'hub',Id
41 When method get
42 And match $ contains { callback : 'http://localhost:8080/test' , query : 'eventType=ServiceOrderCreationNotification' }
43
44 Scenario: testFindSubscriber
45 Given path 'hub'
46 And request data[1]
47 When method post
48 Then status 201
49 Given path 'hub'
50 And request data[2]
51 When method post
52 Then status 201
53 Given path 'hub'
54 When method get
55 Then status 200
56 And match $ == '#notnull'
57
58 Scenario: testFindWithFilteringSubscriber
59 Given path 'hub'
60 And params { query.eventType : 'ServiceOrderCreationNotification' }
61 When method get
62 Then status 200
63 And match $ == '#[1]'
64
65 Scenario: testSubscriberDeletion
66 Given path 'hub'
67 And request { id : 'id', callback : 'http://localhost:8080/test' , query : 'eventType = ServiceOrderCreationNotification' }
68 When method post
69 Then status 201
70 Given path 'hub'
71 When method get
72 And def Id = $[0].id
73 Given path 'hub',Id
74 When method delete
75 Then status 204
76
77 Scenario: testSubscriberWithTestListener
78 * def listenerUrl = nbiBaseUrl + "/test/listener"
79 Given path 'test/listener'
80 When method delete
81 Then status 204
82 Given path 'hub'
83 And request { id : 'id', callback : '#(listenerUrl)' , query : 'eventType = ServiceOrderCreationNotification' }
84 When method post
85 Then status 201
86 Given path 'hub'
87 When method get
88 And def hubId = $[0].id
89 Given path 'serviceOrder'
90 And request serviceOrderData[17]
91 When method post
92 Then status 201
93 And def serviceOrderId = $.id
94 Given path 'test/listener'
95 And params {serviceOrderId : '#(serviceOrderId)'}
96 When method get
97 Then status 200
98 And assert response.length == 1
99 And match $[0] contains { eventId : '#notnull' , eventType : 'ServiceOrderCreationNotification' , eventDate : '#notnull' , event :'#notnull'}
100 And def eventId = $[0].eventId
101 And def eventDate = $[0].eventDate
102 And call checkDateFormat(eventDate)
103 Given path 'hub',hubId
104 When method delete
105 Then status 204
106 Given path 'test/listener',eventId
107 When method delete
108 Then status 204
109 Given path 'serviceOrder',serviceOrderId
110 When method delete
111 Then status 204