Add Aai event listener 79/39679/1
authorSerban Popescu <sp5226@att.com>
Wed, 28 Mar 2018 13:32:44 +0000 (13:32 +0000)
committerSerban Popescu <sp5226@att.com>
Wed, 28 Mar 2018 13:32:44 +0000 (13:32 +0000)
Add support for Aai and Pserver incoming messages from Dmaap

Change-Id: I6ace2395476a1410ea3b7ffe0bebc1766d19e474
Issue-ID: CCSDK-223
Signed-off-by: Serban Popescu <sp5226@att.com>
dmaap-listener/src/main/resources/generic-vnf.map [new file with mode: 0644]
dmaap-listener/src/main/resources/template-generic-vnf.vt [new file with mode: 0644]
dmaap-listener/src/main/resources/template-pserver.vt
dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncPserverDmaapReceiver.java
dmaap-listener/src/test/resources/dmaap-consumer-generic-vnf.properties [new file with mode: 0644]
dmaap-listener/src/test/resources/dmaap-consumer-pserver.properties

diff --git a/dmaap-listener/src/main/resources/generic-vnf.map b/dmaap-listener/src/main/resources/generic-vnf.map
new file mode 100644 (file)
index 0000000..bc375eb
--- /dev/null
@@ -0,0 +1,5 @@
+# SDN-C URL
+SDNC.endpoint => config-selfservice-api:notification-callback
+
+# Field mapping 
+SDNC.template => template-generic-vnf.vt
diff --git a/dmaap-listener/src/main/resources/template-generic-vnf.vt b/dmaap-listener/src/main/resources/template-generic-vnf.vt
new file mode 100644 (file)
index 0000000..c8a6b78
--- /dev/null
@@ -0,0 +1,15 @@
+{
+       "input": {
+               "common-header": {
+                       "request-id": "$event-header.id",
+                       "timestamp": "$curr_time",
+                       "originator-id": "AAI",
+                       "api-ver": "2.00"
+               },
+               "action-identifiers": {
+                       "action-name": "dmaap-notification",
+                       "mode": "async"
+               },
+               "payload": $full_message
+       }
+}
\ No newline at end of file
index 1df659e..c8a6b78 100644 (file)
@@ -6,6 +6,10 @@
                        "originator-id": "AAI",
                        "api-ver": "2.00"
                },
+               "action-identifiers": {
+                       "action-name": "dmaap-notification",
+                       "mode": "async"
+               },
                "payload": $full_message
        }
 }
\ No newline at end of file
index db7cbd7..b9b20a6 100644 (file)
@@ -9,12 +9,16 @@
 package org.onap.ccsdk.sli.northbound.dmaapclient;
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 import java.util.Properties;
 
 import org.junit.Before;
 import org.junit.Test;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
 public class TestSdncPserverDmaapReceiver {
     private static final String aaiInput = "{\r\n" + 
             "    \"cambria.partition\": \"AAI\",\r\n" + 
@@ -75,10 +79,20 @@ public class TestSdncPserverDmaapReceiver {
                Properties props = new Properties();
  
            String rpcMsgbody = new SdncAaiDmaapConsumer(props).publish("src/main/resources/template-pserver.vt", aaiInput);
+        
+           ObjectMapper oMapper = new ObjectMapper();
+        JsonNode aaiRootNode;
+        try {
+            aaiRootNode = oMapper.readTree(rpcMsgbody);
+        } catch (Exception e) {
+            throw new InvalidMessageException("Cannot parse json object", e);
+        }       
 
-        assertTrue(rpcMsgbody.indexOf("input") != -1); 
-        assertTrue(rpcMsgbody.indexOf("payload") != -1); 
-        assertTrue(rpcMsgbody.indexOf("common-header") != -1);
+        assertTrue(aaiRootNode.get("input").get("payload") != null); 
+        assertTrue(aaiRootNode.get("input").get("common-header") != null); 
+        
+        assertEquals(aaiRootNode.get("input").get("action-identifiers").get("action-name").textValue(), "dmaap-notification");
+        assertEquals(aaiRootNode.get("input").get("action-identifiers").get("mode").textValue(), "async");
        }
 
 
diff --git a/dmaap-listener/src/test/resources/dmaap-consumer-generic-vnf.properties b/dmaap-listener/src/test/resources/dmaap-consumer-generic-vnf.properties
new file mode 100644 (file)
index 0000000..710a7c7
--- /dev/null
@@ -0,0 +1,34 @@
+TransportType=DME2
+Latitude =47.778998
+Longitude =-122.182883
+Version =1.0
+ServiceName =dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+Environment =TEST
+Partner =
+SubContextPath =/
+Protocol =https
+MethodType =GET
+username =test
+password =test
+contenttype =application/json
+authKey=ABC123
+authDate=2016-05-10T13:13:50-0700
+host=localhost:3904
+topic=AAI-EVENT
+group=vnf
+id=1
+timeout=20000
+limit=10000
+filter={"class":"And","filters":[{"class":"Equals","field":"event-header.entity-type","value":"generic-vnf"},{"class":"Equals","field":"entity.vnf-type","value":"kvm-vpe"}]}
+AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
+AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
+AFT_DME2_REQ_TRACE_ON=true
+AFT_ENVIRONMENT=AFTUAT
+AFT_DME2_EP_CONN_TIMEOUT=55000
+AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000
+AFT_DME2_EP_READ_TIMEOUT_MS=50000
+sessionstickinessrequired=NO
+DME2preferredRouterFilePath=src/test/resources/dmaap-listener.preferredRoute.txt
+sdnc.odl.user=admin
+sdnc.odl.password=admin
+sdnc.odl.url-base=http://localhost:8181/restconf/operations
\ No newline at end of file
index e3c4fda..9f5cfe7 100644 (file)
@@ -14,7 +14,7 @@ contenttype =application/json
 authKey=ABC123
 authDate=2016-05-10T13:13:50-0700
 host=localhost:3904
-topic=ccsdk-topic
+topic=AAI-EVENT
 group=pserver
 id=1
 timeout=20000