diff options
author | akanshad <akansha.dua@amdocs.com> | 2019-03-28 14:27:01 +0530 |
---|---|---|
committer | akanshad <akansha.dua@amdocs.com> | 2019-03-29 10:06:51 +0530 |
commit | a5e02123aea6f24850470a3f54865cfed6540740 (patch) | |
tree | ff87310ce7dbd6f3beb78407cc1c8030151b41b7 | |
parent | db00c26116449ef0a4a882811545fc5c2cb1d34f (diff) |
Test Cases & Modification of ExtApi Listener Implementation
Issue-ID: EXTAPI-204
Change-Id: I3526151c16c6fba111bec78635a32ffbed8d81b8
Signed-off-by: akanshad <akansha.dua@amdocs.com>
6 files changed, 71 insertions, 3 deletions
diff --git a/src/main/java/org/onap/nbi/apis/hub/HubResource.java b/src/main/java/org/onap/nbi/apis/hub/HubResource.java index a37c522..28e1313 100755 --- a/src/main/java/org/onap/nbi/apis/hub/HubResource.java +++ b/src/main/java/org/onap/nbi/apis/hub/HubResource.java @@ -72,6 +72,7 @@ public class HubResource extends ResourceManagement { @RequestParam MultiValueMap<String, String> params, @RequestHeader(required = false) String targetURL) { logger.debug("POST request for subscription : {}", subscription); if(targetURL != null) { + Subscriber subscriber = subscriptionService.createSubscription(subscription); return extApiClientForHub.postEventSubscription(subscription,targetURL); }else { Subscriber subscriber = subscriptionService.createSubscription(subscription); diff --git a/src/main/java/org/onap/nbi/apis/hub/ListenerResource.java b/src/main/java/org/onap/nbi/apis/hub/ListenerResource.java index def2ff0..aa236d1 100644 --- a/src/main/java/org/onap/nbi/apis/hub/ListenerResource.java +++ b/src/main/java/org/onap/nbi/apis/hub/ListenerResource.java @@ -33,7 +33,6 @@ import org.onap.nbi.apis.hub.model.Event; @RestController @RequestMapping("/listener") -@EnableScheduling public class ListenerResource extends ResourceManagement { @Autowired diff --git a/src/test/resources/karatetest/data/Event.json b/src/test/resources/karatetest/data/Event.json new file mode 100644 index 0000000..5887deb --- /dev/null +++ b/src/test/resources/karatetest/data/Event.json @@ -0,0 +1,13 @@ +[{ + "eventType": "ServiceOrderStateChangeNotification", + "eventDate": "2019-03-27T14:58:32.740Z", + "eventId": "12345", + "event": { + "id": "testEventId", + "href": "www.testHref.com", + "externalId": "testExternalId", + "state": "acknowledged", + "orderDate": "2019-03-27T04:58:32.740Z" + + } +}]
\ No newline at end of file diff --git a/src/test/resources/karatetest/data/subscriber.json b/src/test/resources/karatetest/data/subscriber.json index 8fa7370..1853952 100644 --- a/src/test/resources/karatetest/data/subscriber.json +++ b/src/test/resources/karatetest/data/subscriber.json @@ -1,4 +1,5 @@ [ + { "callback": "http://localhost:8080/test", "query": "eventType = ServiceOrderCreationNotification" @@ -10,5 +11,9 @@ { "callback": "http://localhost/test", "query": "eventType=ServiceOrderItemStateChangeNotification" + }, + { + "callback": "http://localhost:8080/nbi/api/v3/test/listener", + "query": "eventType=ServiceOrderStateChangeNotification" } ]
\ No newline at end of file diff --git a/src/test/resources/karatetest/features/02--ServiceOrder.feature b/src/test/resources/karatetest/features/02--ServiceOrder.feature index 31aeff1..756a00e 100644 --- a/src/test/resources/karatetest/features/02--ServiceOrder.feature +++ b/src/test/resources/karatetest/features/02--ServiceOrder.feature @@ -435,4 +435,18 @@ And match $.orderMessage[0] contains { code : '500' , messageInformation : 'Pro Given path 'serviceOrder',serviceOrderId When method get Then status 200 -* call Context.startServers();
\ No newline at end of file +* call Context.startServers(); + +Scenario: testCheckServiceOrderWithTargetURLPresent +Given path 'serviceOrder' +And header targetURL = '127.0.0.1' +And request data[0] +When method post +Then status 201 +And match $.id contains '#notnull' +And match $.state == 'acknowledged' +And def serviceOrderId = $.id +Given path 'serviceOrder', serviceOrderId +And header targetURL = '127.0.0.1' +When method get +Then status 200
\ No newline at end of file diff --git a/src/test/resources/karatetest/features/03--Subscriber.feature b/src/test/resources/karatetest/features/03--Subscriber.feature index e4704ea..ea8c24a 100644 --- a/src/test/resources/karatetest/features/03--Subscriber.feature +++ b/src/test/resources/karatetest/features/03--Subscriber.feature @@ -9,6 +9,7 @@ Background: * call Context.startServers(); * def data = read('../data/subscriber.json') * def serviceOrderData = read('../data/serviceOrder.json') +* def eventData = read('../data/Event.json') * configure retry = { count: 10, interval: 500 } * def checkDateFormat = """ @@ -248,4 +249,39 @@ When method delete Then status 204 Given path 'test/listener',eventId When method delete -Then status 204
\ No newline at end of file +Then status 204 + + +Scenario: testHubAndListenerResourceWhenTargetURLIsPresent +Given path 'hub' +And header targetURL = '127.0.0.1' +And request data[3] +When method post +Then status 201 +And def location = responseHeaders['Location'][0] +Given path "listener" +And request eventData[0] +When method post +Then status 200 +Given path "test/listener/12345" +When method get +Then status 200 +And match $ contains +""" +{ + "eventType": "ServiceOrderStateChangeNotification", + "eventDate": "2019-03-27T14:58:32.740Z", + "eventId": "12345", + "event": { + "id": "testEventId", + "href": "www.testHref.com", + "externalId": "testExternalId", + "state": "acknowledged", + "orderDate": "2019-03-27T04:58:32.740Z" + + } +} +""" +Given url location +When method delete +Then status 204 |