summaryrefslogtreecommitdiffstats
path: root/dmaap-listener
diff options
context:
space:
mode:
authorSandeep Shah <sandeep.shah2@techmahindra.com>2019-04-14 11:19:29 -0500
committerSandeep Shah <sandeep.shah2@techmahindra.com>2019-04-14 11:19:29 -0500
commitdc1ac454bb77359e466395a4a92891f7cebda2a2 (patch)
tree43846f2f8408d90e50360b424f3215f294b79b10 /dmaap-listener
parentcd1d3ffe4a39154f6bef75108635761828907dd9 (diff)
JUNIT tests for SDNR OOF PCI Dmaap Listener
JUNIT test JAVA files and name change for .vt file Change-Id: I513b9abd72d4c230f57ae3f89a8fafc5f72e7cfa Issue-ID: CCSDK-1226 Signed-off-by: SandeepLinux <sandeep.shah2@techmahindra.com>
Diffstat (limited to 'dmaap-listener')
-rw-r--r--dmaap-listener/src/main/resources/anr-pci-changes-from-policy-to-sdnr.vt (renamed from dmaap-listener/src/main/resources/anr-pci-changes-from-policy-to-sndr.vt)4
-rw-r--r--dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestANRChangesFromPolicyToSDNRDmaapConsumer.java142
-rw-r--r--dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestPciChangesFromPolicyToSDNRDmaapConsumer.java181
3 files changed, 325 insertions, 2 deletions
diff --git a/dmaap-listener/src/main/resources/anr-pci-changes-from-policy-to-sndr.vt b/dmaap-listener/src/main/resources/anr-pci-changes-from-policy-to-sdnr.vt
index 1cdd65e9c..1ded88dc7 100644
--- a/dmaap-listener/src/main/resources/anr-pci-changes-from-policy-to-sndr.vt
+++ b/dmaap-listener/src/main/resources/anr-pci-changes-from-policy-to-sdnr.vt
@@ -1,8 +1,8 @@
{
"input": {
"module-name": "oofpcipoc-api",
- "rpc-name": $rpc_name,
+ "rpc-name": "$rpc_name",
"mode": "sync",
"sli-parameter": $sli_parameters
}
-} \ No newline at end of file
+}
diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestANRChangesFromPolicyToSDNRDmaapConsumer.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestANRChangesFromPolicyToSDNRDmaapConsumer.java
new file mode 100644
index 000000000..66b63a17d
--- /dev/null
+++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestANRChangesFromPolicyToSDNRDmaapConsumer.java
@@ -0,0 +1,142 @@
+package org.onap.ccsdk.sli.northbound.dmaapclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+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 TestANRChangesFromPolicyToSDNRDmaapConsumer {
+ private static final String anrChangesFromPolicyToSDNRInput = "{\n" +
+ " \"body\": {\n" +
+ " \"input\": {\n" +
+ " \"CommonHeader\": {\n" +
+ " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
+ " \"APIVer\": \"1.0\",\n" +
+ " \"RequestID\": \"722ee65a-8afd-48df-bf57-c152ae45bacc\",\n" +
+ " \"SubRequestID\": \"1\",\n" +
+ " \"RequestTrack\": {},\n" +
+ " \"Flags\": {}\n" +
+ " },\n" +
+ "\"Action\": \"ModifyConfigANR\",\n" +
+ " \"Payload\": \"{ \\\"Configurations\\\":[ { \\\"data\\\":{ \\\"FAPService\\\":{ \\\"alias\\\":\\\"Cell1\\\", \\\"CellConfig\\\":{ \\\"LTE\\\":{ \\\"RAN\\\":{ \\\"Common\\\":{ \\\"CellIdentity\\\":\\\"1\\\" }, \\\"NeighborListInUse\\\" : { \\\"LTECellNumberOfEntries\\\" : \\\"1\\\" , \\\"LTECell\\\" : [{ \\\"PLMNID\\\" :\\\"plmnid1\\\", \\\"CID\\\":\\\"Chn0001\\\", \\\"PhyCellID\\\":\\\"3\\\", \\\"PNFName\\\":\\\"ncserver01\\\", \\\"Blacklisted\\\":\\\"false\\\"}] } } } } } } } ] }\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"rpc-name\": \"modifyconfiganr\",\n" +
+ " \"correlation-id\": \"722ee65a-8afd-48df-bf57-c152ae45bacc-1\",\n" +
+ " \"type\": \"request\"\n" +
+ "}\n" +
+ "";
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void testRPCMessageBodyResponse() throws Exception {
+ Properties props = new Properties();
+
+ ObjectMapper oMapper = new ObjectMapper();
+ JsonNode anrChangesRootNode = oMapper.readTree(anrChangesFromPolicyToSDNRInput);
+ JsonNode body = anrChangesRootNode.get("body");
+ JsonNode input = body.get("input");
+ JsonNode payload = input.get("Payload");
+ String payloadText = payload.asText();
+ JsonNode configurationsJsonNode = oMapper.readTree(payloadText);
+ JsonNode configurations = configurationsJsonNode.get("Configurations");
+
+ for(JsonNode dataNode:configurations) {
+ String rpcMsgbody = new ANRChangesFromPolicyToSDNRDmaapConsumer(props).publish("src/main/resources/anr-pci-changes-from-policy-to-sdnr.vt", anrChangesFromPolicyToSDNRInput,dataNode);
+
+ JsonNode rootNode;
+ try {
+ rootNode = oMapper.readTree(rpcMsgbody);
+ } catch (Exception e) {
+ throw new InvalidMessageException("Cannot parse json object", e);
+ }
+
+ assertTrue(rootNode.get("input").get("module-name") != null);
+ assertTrue(rootNode.get("input").get("rpc-name") != null);
+ assertTrue(rootNode.get("input").get("mode") != null);
+ assertTrue(rootNode.get("input").get("sli-parameter") != null);
+ }
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgNullMessage() throws Exception {
+ ANRChangesFromPolicyToSDNRDmaapConsumer consumer = new ANRChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg(null);
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgInvalidMessage() throws Exception {
+ ANRChangesFromPolicyToSDNRDmaapConsumer consumer = new ANRChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg("test");
+ }
+
+ @Test
+ public void testProcessMsgMissingActionHeader() throws Exception {
+ ANRChangesFromPolicyToSDNRDmaapConsumer consumer = new ANRChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg("{\n" +
+ " \"body\": {\n" +
+ " \"input\": {\n" +
+ " \"CommonHeader\": {\n" +
+ " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
+ " \"APIVer\": \"1.0\",\n" +
+ " \"RequestID\": \"722ee65a-8afd-48df-bf57-c152ae45bacc\",\n" +
+ " \"SubRequestID\": \"1\",\n" +
+ " \"RequestTrack\": {},\n" +
+ " \"Flags\": {}\n" +
+ " },\n" +
+ "\"NoAction\": \"ModifyConfigANR\",\n" +
+ " \"Payload\": \"{ \\\"Configurations\\\":[ { \\\"data\\\":{ \\\"FAPService\\\":{ \\\"alias\\\":\\\"Cell1\\\", \\\"CellConfig\\\":{ \\\"LTE\\\":{ \\\"RAN\\\":{ \\\"Common\\\":{ \\\"CellIdentity\\\":\\\"1\\\" }, \\\"NeighborListInUse\\\" : { \\\"LTECellNumberOfEntries\\\" : \\\"1\\\" , \\\"LTECell\\\" : [{ \\\"PLMNID\\\" :\\\"plmnid1\\\", \\\"CID\\\":\\\"Chn0001\\\", \\\"PhyCellID\\\":\\\"3\\\", \\\"PNFName\\\":\\\"ncserver01\\\", \\\"Blacklisted\\\":\\\"false\\\"}] } } } } } } } ] }\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"rpc-name\": \"modifyconfiganr\",\n" +
+ " \"correlation-id\": \"722ee65a-8afd-48df-bf57-c152ae45bacc-1\",\n" +
+ " \"type\": \"request\"\n" +
+ "}\n" +
+ "");
+ }
+
+ @Test
+ public void testProcessMsgInvalidPayloadConfigurations() throws Exception {
+ String msg = "{\n" +
+ " \"body\": {\n" +
+ " \"input\": {\n" +
+ " \"CommonHeader\": {\n" +
+ " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
+ " \"APIVer\": \"1.0\",\n" +
+ " \"RequestID\": \"722ee65a-8afd-48df-bf57-c152ae45bacc\",\n" +
+ " \"SubRequestID\": \"1\",\n" +
+ " \"RequestTrack\": {},\n" +
+ " \"Flags\": {}\n" +
+ " },\n" +
+ "\"Action\": \"ModifyConfigANR\",\n" +
+ " \"Payload\": \"{ \\\"Configurations\\\":{ { \\\"data\\\":{ \\\"FAPService\\\":{ \\\"alias\\\":\\\"Cell1\\\", \\\"CellConfig\\\":{ \\\"LTE\\\":{ \\\"RAN\\\":{ \\\"Common\\\":{ \\\"CellIdentity\\\":\\\"1\\\" }, \\\"NeighborListInUse\\\" : { \\\"LTECellNumberOfEntries\\\" : \\\"1\\\" , \\\"LTECell\\\" : [{ \\\"PLMNID\\\" :\\\"plmnid1\\\", \\\"CID\\\":\\\"Chn0001\\\", \\\"PhyCellID\\\":\\\"3\\\", \\\"PNFName\\\":\\\"ncserver01\\\", \\\"Blacklisted\\\":\\\"false\\\"}} } } } } } } } ] }\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"rpc-name\": \"modifyconfiganr\",\n" +
+ " \"correlation-id\": \"722ee65a-8afd-48df-bf57-c152ae45bacc-1\",\n" +
+ " \"type\": \"request\"\n" +
+ "}\n" +
+ "";
+
+ try {
+ ANRChangesFromPolicyToSDNRDmaapConsumer consumer = new ANRChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg(msg);
+
+ } catch (final InvalidMessageException e) {
+ final String errorMsg = "Cannot parse payload value";
+ assertEquals(errorMsg, e.getMessage());
+ }
+ }
+}
diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestPciChangesFromPolicyToSDNRDmaapConsumer.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestPciChangesFromPolicyToSDNRDmaapConsumer.java
new file mode 100644
index 000000000..a42bc48f6
--- /dev/null
+++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestPciChangesFromPolicyToSDNRDmaapConsumer.java
@@ -0,0 +1,181 @@
+package org.onap.ccsdk.sli.northbound.dmaapclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+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 TestPciChangesFromPolicyToSDNRDmaapConsumer {
+ private static final String pciChangesFromPolicyToSDNRInput = "{\n" +
+ " \"body\": {\n" +
+ " \"input\": {\n" +
+ " \"CommonHeader\": {\n" +
+ " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
+ " \"APIVer\": \"1.0\",\n" +
+ " \"RequestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" +
+ " \"SubRequestID\": \"1\",\n" +
+ " \"RequestTrack\": {},\n" +
+ " \"Flags\": {}\n" +
+ " },\n" +
+ " \"Action\": \"ModifyConfig\",\n" +
+ " \"Payload\": \"{\\\"Configurations\\\":[{\\\"data\\\":{\\\"FAPService\\\":{\\\"alias\\\":\\\"Chn0330\\\",\\\"X0005b9Lte\\\":{\\\"phyCellIdInUse\\\":6,\\\"pnfName\\\":\\\"ncserver23\\\"},\\\"CellConfig\\\":{\\\"LTE\\\":{\\\"RAN\\\":{\\\"Common\\\":{\\\"CellIdentity\\\":\\\"Chn0330\\\"}}}}}}},{\\\"data\\\":{\\\"FAPService\\\":{\\\"alias\\\":\\\"Chn0331\\\",\\\"X0005b9Lte\\\":{\\\"phyCellIdInUse\\\":7,\\\"pnfName\\\":\\\"ncserver23\\\"},\\\"CellConfig\\\":{\\\"LTE\\\":{\\\"RAN\\\":{\\\"Common\\\":{\\\"CellIdentity\\\":\\\"Chn0331\\\"}}}}}}}]}\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"rpc-name\": \"modifyconfig\",\n" +
+ " \"correlation-id\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459-1\",\n" +
+ " \"type\": \"request\"\n" +
+ "}";
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void testRPCMessageBodyResponse() throws Exception {
+ Properties props = new Properties();
+
+ ObjectMapper oMapper = new ObjectMapper();
+ JsonNode pciChangesRootNode = oMapper.readTree(pciChangesFromPolicyToSDNRInput);
+ JsonNode body = pciChangesRootNode.get("body");
+ JsonNode input = body.get("input");
+ JsonNode payload = input.get("Payload");
+ String payloadText = payload.asText();
+ JsonNode configurationsJsonNode = oMapper.readTree(payloadText);
+
+ String rpcMsgbody = new PciChangesFromPolicyToSDNRDmaapConsumer(props).publish("src/main/resources/anr-pci-changes-from-policy-to-sdnr.vt", pciChangesFromPolicyToSDNRInput,configurationsJsonNode);
+
+ JsonNode rootNode;
+ try {
+ rootNode = oMapper.readTree(rpcMsgbody);
+ } catch (Exception e) {
+ throw new InvalidMessageException("Cannot parse json object", e);
+ }
+
+ assertTrue(rootNode.get("input").get("module-name") != null);
+ assertTrue(rootNode.get("input").get("rpc-name") != null);
+ assertTrue(rootNode.get("input").get("mode") != null);
+ assertTrue(rootNode.get("input").get("sli-parameter") != null);
+
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgNullMessage() throws Exception {
+ PciChangesFromPolicyToSDNRDmaapConsumer consumer = new PciChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg(null);
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgInvalidMessage() throws Exception {
+ PciChangesFromPolicyToSDNRDmaapConsumer consumer = new PciChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg("test");
+ }
+
+ @Test
+ public void testProcessMsgMissingActionHeader() throws Exception {
+ PciChangesFromPolicyToSDNRDmaapConsumer consumer = new PciChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg("{\n" +
+ " \"body\": {\n" +
+ " \"input\": {\n" +
+ " \"CommonHeader\": {\n" +
+ " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
+ " \"APIVer\": \"1.0\",\n" +
+ " \"RequestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" +
+ " \"SubRequestID\": \"1\",\n" +
+ " \"RequestTrack\": {},\n" +
+ " \"Flags\": {}\n" +
+ " },\n" +
+ " \"RenamedAction\": \"ModifyConfig\",\n" +
+ " \"Payload\": {\n" +
+ " \"Configurations \": {\n" +
+ " \"data \": {\n" +
+ " \"FAPService \": {\n" +
+ " \"alias\": \"Chn0330\",\n" +
+ " \"X0005b9Lte\": {\n" +
+ " \"phyCellIdInUse\": 6,\n" +
+ " \"pnfName\": \"ncserver23\"\n" +
+ " },\n" +
+ " \"CellConfig\": {\n" +
+ " \"LTE\": {\n" +
+ " \"RAN\": {\n" +
+ " \"Common\": {\n" +
+ " \"CellIdentity\": \"Chn0330\"\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"rpc-name\": \"modifyconfig\",\n" +
+ " \"correlation-id\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459-1\",\n" +
+ " \"type\": \"request\"\n" +
+ "}");
+ }
+
+ @Test
+ public void testProcessMsgInvalidPayloadConfigurations() throws Exception {
+ String msg = "{\n" +
+ " \"body\": {\n" +
+ " \"input\": {\n" +
+ " \"CommonHeader\": {\n" +
+ " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
+ " \"APIVer\": \"1.0\",\n" +
+ " \"RequestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" +
+ " \"SubRequestID\": \"1\",\n" +
+ " \"RequestTrack\": {},\n" +
+ " \"Flags\": {}\n" +
+ " },\n" +
+ " \"Action\": \"ModifyConfig\",\n" +
+ " \"Payload\": {\n" +
+ " \"Configurations \": {\n" +
+ " \"data \": {\n" +
+ " \"FAPService \": {\n" +
+ " \"alias\": \"Chn0330\",\n" +
+ " \"X0005b9Lte\": {\n" +
+ " \"phyCellIdInUse\": 6,\n" +
+ " \"pnfName\": \"ncserver23\"\n" +
+ " },\n" +
+ " \"CellConfig\": {\n" +
+ " \"LTE\": {\n" +
+ " \"RAN\": {\n" +
+ " \"Common\": {\n" +
+ " \"CellIdentity\": \"Chn0330\"\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"rpc-name\": \"modifyconfig\",\n" +
+ " \"correlation-id\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459-1\",\n" +
+ " \"type\": \"request\"\n" +
+ "}";
+
+ try {
+ PciChangesFromPolicyToSDNRDmaapConsumer consumer = new PciChangesFromPolicyToSDNRDmaapConsumer();
+ consumer.processMsg(msg);
+
+ } catch (final InvalidMessageException e) {
+ final String errorMsg = "Configurations is not of Type Array. Could not read configuration changes";
+ assertEquals(errorMsg, e.getMessage());
+ }
+ }
+}