aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java60
-rw-r--r--src/test/resources/junit/genericVnfInput_set5.json100
-rw-r--r--src/test/resources/junit/vnfc-input1.json15
3 files changed, 175 insertions, 0 deletions
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java
index bc649fb..9f82c69 100644
--- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java
+++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java
@@ -51,6 +51,7 @@ import org.onap.pomba.common.datatypes.ModelContext;
import org.onap.pomba.common.datatypes.VFModule;
import org.onap.pomba.common.datatypes.VM;
import org.onap.pomba.common.datatypes.VNF;
+import org.onap.pomba.common.datatypes.VNFC;
import org.json.JSONObject;
import com.google.gson.Gson;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
@@ -227,4 +228,63 @@ public class RestServiceTest {
assertEquals(vmList.get(0).getLInterfaceList().get(0).getName(), "junit-l-interface-name1"); //l-interface-name
assertEquals(vmList.get(0).getLInterfaceList().get(1).getName(), "junit-l-interface-name2"); //l-interface-name
}
+
+ ///Verify the relationship serviceInstanceId -> vnf + vnfc
+ @Test
+ public void testGetContext_VNFC() throws Exception {
+
+ String transactionId = UUID.randomUUID().toString();
+ String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json
+ String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId;
+
+ // Test with No Partner Name
+ final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders(
+ transactionId, testRestHeaders, httpBasicAuthorization);
+
+ // 1. simulate the response to obtainResourceLink based on ServiceInstanceId
+ addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule);
+ // 2. simulate the response of AAI (1 vnf)
+ // note: match serviceInstanceId in (1)
+ addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ "junit/aai-service-instance_set2.json", aaiEnricherRule);
+
+ // 3. simulate the rsp of VNF (with 1 vserver)
+ // note: match vnf_id in (2)
+ addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH,
+ "junit/genericVnfInput_set5.json", aaiEnricherRule);
+
+ // 4. simulate the rsp of vserer
+ // note: match to vserver-id to the path of "vserver" in (3)
+ addResponse(
+ "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant"
+ + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a",
+ "junit/aai-vserver-set2.json", aaiEnricherRule);
+
+ // 5. simulate the rsp of vnfc
+ // note: match to vnfc-name to the path of "vnfc" in (3)
+ addResponse(
+ "/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212",
+ "junit/vnfc-input1.json", aaiEnricherRule);
+
+ when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl);
+
+ Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId,
+ serviceInstanceId);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+ Gson gson = new Gson();
+ ModelContext modelCtx = gson.fromJson((String) response.getEntity(), ModelContext.class);
+ // verify results
+ List<VNF> vnfList = modelCtx.getVnfs();
+ assertEquals(vnfList.size(), 1);
+ List<VFModule> vfModuleList = vnfList.get(0).getVfModules();
+ assertEquals(vfModuleList.size(), 1);
+ List<VM> vmList = vfModuleList.get(0).getVms();
+ assertEquals(vmList.size(), 1);
+ assertEquals(vmList.get(0).getUuid(), "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a"); //vserver-id
+
+ List<VNFC> vnfcList = vnfList.get(0).getVnfcs();
+ assertEquals(vnfcList.size(), 1);
+ assertEquals(vnfcList.get(0).getName(), "junit-vnfc-name1212"); //vnfc-name
+ }
}
diff --git a/src/test/resources/junit/genericVnfInput_set5.json b/src/test/resources/junit/genericVnfInput_set5.json
new file mode 100644
index 0000000..05e39a0
--- /dev/null
+++ b/src/test/resources/junit/genericVnfInput_set5.json
@@ -0,0 +1,100 @@
+{
+ "vnf-id": "8a9ddb25-2e79-449c-a40d-5011bac0da39",
+ "vnf-name": "Firewall-1",
+ "vnf-type": "vFW-vSINK-service/vFWvSINK 0",
+ "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
+ "prov-status": "PREPROV",
+ "orchestration-status": "Created",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1527637940029",
+ "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820",
+ "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "nf-type": "nf-type1121",
+ "nf-function": "nf-function1123",
+ "nf-role": "nf-role1213",
+ "nf-naming-code": "nf-naming-code1212",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "b49b830686654191bb1e952a74b014ad"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a"
+ }
+ ]
+ },
+ {
+ "related-to": "vnfc",
+ "related-link": "/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "junit-vnfc-name1212"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vnfc.nfc-naming-code",
+ "property-value": "nfc-naming-code-1212"
+ }
+ ]
+ },
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v13/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFWCL/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vFWCL"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "adc3cc2a-c73e-414f-8ddb-367de81300cb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Firewall1"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "1563b649-9e05-4288-b7d9-e3639a54ace6",
+ "vf-module-name": "vFW_SINC_Module-2",
+ "heat-stack-id": "vFW_SINC_Module-2/41c4533a-748d-4cf4-a8d3-eccdd0aeb0d4",
+ "orchestration-status": "active",
+ "is-base-vf-module": true,
+ "resource-version": "1527638439198",
+ "model-invariant-id": "74bc1518-282d-4148-860f-8892b6369456",
+ "model-version-id": "4e3d28cf-d654-41af-a47b-04b4bd0ac58e",
+ "model-customization-id": "cc51ab7d-9b03-4bd6-9104-09df0c7c7907",
+ "module-index": 0
+ }
+ ]
+ }
+}
diff --git a/src/test/resources/junit/vnfc-input1.json b/src/test/resources/junit/vnfc-input1.json
new file mode 100644
index 0000000..d76de8b
--- /dev/null
+++ b/src/test/resources/junit/vnfc-input1.json
@@ -0,0 +1,15 @@
+{
+ "vnfc-name": "junit-vnfc-name1212",
+ "nfc-naming-code": "nfc-naming-code-1212",
+ "nfc-function": "nfcFunction1",
+ "prov-status": "11112222provStatus",
+ "orchestration-status": "orchestrationStatus1",
+ "ipaddress-v4-oam-vip": "8df84f0a-737a-4628-be9c-c3c78454f9d9",
+ "in-maint": "false",
+ "is-closed-loop-disabled": "true",
+ "model-invariant-id": "model-invariant-id1212",
+ "model-version-id": "model-version-id1212",
+ "model-customization-id": "modelCustomizationId99888",
+ "resource-version": "resourceVersion4989d67b2a6b7",
+ "cps": "cps12123"
+} \ No newline at end of file