aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorNorm Traxler <normant@amdocs.com>2019-01-17 20:57:54 +0000
committerNorm Traxler <normant@amdocs.com>2019-01-17 20:58:15 +0000
commitcdad28821c2ac6834e284aae72f10ad2d0529147 (patch)
tree3fc4bb2be3fb373e013a6436fd821d570251a6fb /src/test
parentfbcdb700fdf2bcc469317d19838ecfac075f1729 (diff)
Fix NetworkDisc Ctx Builder
Issue-ID: LOG-931 Change-Id: I0a1d26b51a5690380210d026637c9c4cd1f56cfc Signed-off-by: Norm Traxler <normant@amdocs.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java69
-rw-r--r--src/test/resources/jolt/serviceDecompToNdQuery-expected.json16
-rw-r--r--src/test/resources/jolt/serviceDecompToNdQuery-input.json260
3 files changed, 345 insertions, 0 deletions
diff --git a/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java b/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java
new file mode 100644
index 0000000..7518591
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java
@@ -0,0 +1,69 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=====================================================
+ */
+
+package org.onap.pomba.contextbuilder.networkdiscovery.test.jolt;
+
+import com.bazaarvoice.jolt.Chainr;
+import com.bazaarvoice.jolt.JsonUtils;
+import com.google.gson.Gson;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.pomba.contextbuilder.networkdiscovery.model.NdQuery;
+
+public class TransformationTest {
+
+ private static final String TEST_RESOURCES = "src/test/resources/jolt/";
+
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+
+ @Test
+ public void testTransformNdQuery() {
+
+ Object sourceObject = JsonUtils.filepathToObject(TEST_RESOURCES + "serviceDecompToNdQuery-input.json");
+ Object sourceObject1 = JsonUtils.jsonToObject(JsonUtils.toJsonString(sourceObject));
+
+ List<Object> chainrSpecJSON = JsonUtils.filepathToList("config/ndQuery.spec");
+ Chainr chainr = Chainr.fromSpec(chainrSpecJSON);
+ Object output = chainr.transform(sourceObject1);
+
+ String resultJson = JsonUtils.toJsonString(output);
+
+ // read the result into the NqQuery class:
+ Gson gson = new Gson();
+ NdQuery ndQuery = gson.fromJson(resultJson, NdQuery.class);
+
+ // convert ndQuery back to json:
+ String ndQueryToJson = gson.toJson(ndQuery);
+
+ // Compare with expected output:
+ Object expectedObject = JsonUtils.filepathToObject(TEST_RESOURCES + "serviceDecompToNdQuery-expected.json");
+
+ Assert.assertEquals("Json transformation result does not match expected content",
+ JsonUtils.toPrettyJsonString(expectedObject),
+ JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(ndQueryToJson)));
+
+ }
+
+}
diff --git a/src/test/resources/jolt/serviceDecompToNdQuery-expected.json b/src/test/resources/jolt/serviceDecompToNdQuery-expected.json
new file mode 100644
index 0000000..cfc5a5b
--- /dev/null
+++ b/src/test/resources/jolt/serviceDecompToNdQuery-expected.json
@@ -0,0 +1,16 @@
+{
+ "ndQuery": [
+ {
+ "ndResourcesList": [
+ {
+ "ndResources": [
+ {
+ "resourceId": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "resourceType": "vserver"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/test/resources/jolt/serviceDecompToNdQuery-input.json b/src/test/resources/jolt/serviceDecompToNdQuery-input.json
new file mode 100644
index 0000000..2954141
--- /dev/null
+++ b/src/test/resources/jolt/serviceDecompToNdQuery-input.json
@@ -0,0 +1,260 @@
+{
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001-VNF-id-001",
+ "relationship-key": "generic-vnf.vnf-id"
+ }
+ ],
+ "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/PombaDemoCust_001-VNF-id-001",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "Firewall-1"
+ }
+ ]
+ },
+ {
+ "related-to": "l3-network",
+ "relationship-data": [
+ {
+ "relationship-value": "2ea02809-7279-4b5e-931a-62b231615497",
+ "relationship-key": "l3-network.network-id"
+ }
+ ],
+ "related-link": "/aai/v13/network/l3-networks/l3-network/2ea02809-7279-4b5e-931a-62b231615497",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-to-property": [
+ {
+ "property-key": "l3-network.network-name",
+ "property-value": "NET_1105"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001-PNF2-id-001",
+ "relationship-key": "pnf.pnf-name"
+ }
+ ],
+ "related-link": "/aai/v13/network/pnfs/pnf/PombaDemoCust_001-PNF2-id-001",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf"
+ },
+ {
+ "related-to": "pnf",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001-PNF-id-001",
+ "relationship-key": "pnf.pnf-name"
+ }
+ ],
+ "related-link": "/aai/v13/network/pnfs/pnf/PombaDemoCust_001-PNF-id-001",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf"
+ },
+ {
+ "related-to": "l3-network",
+ "relationship-data": [
+ {
+ "relationship-value": "01e8d84a-17a6-47b5-a167-6a45d1d56603",
+ "relationship-key": "l3-network.network-id"
+ }
+ ],
+ "related-link": "/aai/v13/network/l3-networks/l3-network/01e8d84a-17a6-47b5-a167-6a45d1d56603",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-to-property": [
+ {
+ "property-key": "l3-network.network-name",
+ "property-value": "NET_1106"
+ }
+ ]
+ }
+ ]
+ },
+ "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
+ "service-instance-id": "PombaDemoCust_001-SerivceInst-001",
+ "resource-version": "1545324562797",
+ "generic-vnfs": [
+ {
+ "nf-role": "",
+ "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001",
+ "relationship-key": "customer.global-customer-id"
+ },
+ {
+ "relationship-value": "SDN-ETHERNET-INTERNET",
+ "relationship-key": "service-subscription.service-type"
+ },
+ {
+ "relationship-value": "PombaDemoCust_001-SerivceInst-001",
+ "relationship-key": "service-instance.service-instance-id"
+ }
+ ],
+ "related-link": "/aai/v13/business/customers/customer/PombaDemoCust_001/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/PombaDemoCust_001-SerivceInst-001",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "relationship-data": [
+ {
+ "relationship-value": "CloudOwner",
+ "relationship-key": "cloud-region.cloud-owner"
+ },
+ {
+ "relationship-value": "PombaRegion001",
+ "relationship-key": "cloud-region.cloud-region-id"
+ },
+ {
+ "relationship-value": "PombaRegion001-tenant-001",
+ "relationship-key": "tenant.tenant-id"
+ },
+ {
+ "relationship-value": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "relationship-key": "vserver.vserver-id"
+ }
+ ],
+ "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/PombaRegion001/tenants/tenant/PombaRegion001-tenant-001/vservers/vserver/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "Firewall-001"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001-pserver-id-001",
+ "relationship-key": "pserver.hostname"
+ }
+ ],
+ "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/PombaDemoCust_001-pserver-id-001",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2",
+ "property-value": "PombaDemoCust_001-pserver-id-001-name2"
+ }
+ ]
+ }
+ ]
+ },
+ "vnf-id": "PombaDemoCust_001-VNF-id-001",
+ "nf-type": "",
+ "prov-status": "PREPROV",
+ "vnf-type": "vFW-vSINK-service/vFWvSINK 0",
+ "orchestration-status": "Created",
+ "nf-naming-code": "",
+ "in-maint": false,
+ "nf-function": "",
+ "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
+ "vservers": [
+ {
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001-VNF-id-001",
+ "relationship-key": "generic-vnf.vnf-id"
+ }
+ ],
+ "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/PombaDemoCust_001-VNF-id-001",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "Firewall-1"
+ }
+ ]
+ },
+ {
+ "related-to": "flavor",
+ "relationship-data": [
+ {
+ "relationship-value": "CloudOwner",
+ "relationship-key": "cloud-region.cloud-owner"
+ },
+ {
+ "relationship-value": "PombaRegion001",
+ "relationship-key": "cloud-region.cloud-region-id"
+ },
+ {
+ "relationship-value": "PombaRegion001-flavor001",
+ "relationship-key": "flavor.flavor-id"
+ }
+ ],
+ "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/PombaRegion001/flavors/flavor/PombaRegion001-flavor001",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-to-property": [
+ {
+ "property-key": "flavor.flavor-name",
+ "property-value": "m1.medium"
+ }
+ ]
+ },
+ {
+ "related-to": "image",
+ "relationship-data": [
+ {
+ "relationship-value": "CloudOwner",
+ "relationship-key": "cloud-region.cloud-owner"
+ },
+ {
+ "relationship-value": "PombaRegion001",
+ "relationship-key": "cloud-region.cloud-region-id"
+ },
+ {
+ "relationship-value": "PombaRegion001-image001",
+ "relationship-key": "image.image-id"
+ }
+ ],
+ "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/PombaRegion001/images/image/PombaRegion001-image001",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-to-property": [
+ {
+ "property-key": "image.image-name",
+ "property-value": "unknown"
+ }
+ ]
+ }
+ ]
+ },
+ "in-maint": false,
+ "resource-version": "1545323228761",
+ "vserver-name": "Firewall-001",
+ "prov-status": "ACTIVE",
+ "vserver-id": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "vserver-name2": "Firewall-001",
+ "vserver-selflink": "http://10.12.25.2:8774/v2.1/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9/servers/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "is-closed-loop-disabled": false
+ }
+ ],
+ "resource-version": "1545324724996",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820",
+ "vnf-name": "Firewall-1",
+ "is-closed-loop-disabled": false
+ }
+ ],
+ "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820"
+} \ No newline at end of file