From 15c6cfa5faaa3445e7fdad2650d72c76dda1e0b9 Mon Sep 17 00:00:00 2001 From: "Leigh, Phillip (pl876u)" Date: Thu, 14 Feb 2019 18:44:57 -0500 Subject: Fix:align attributes after Pomba Audit model Chg Issue-ID: SDNC-644 Change-Id: I784b312261ee6016ec61cabd8b007901e221cbab Signed-off-by: Leigh, Phillip (pl876u) --- .../test/RestServiceTest.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src/test/java') 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 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 vnfList = modelCtx.getVnfs(); + assertEquals(vnfList.size(), 1); + List vfModuleList = vnfList.get(0).getVfModules(); + assertEquals(vfModuleList.size(), 1); + List vmList = vfModuleList.get(0).getVms(); + assertEquals(vmList.size(), 1); + assertEquals(vmList.get(0).getUuid(), "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a"); //vserver-id + + List vnfcList = vnfList.get(0).getVnfcs(); + assertEquals(vnfcList.size(), 1); + assertEquals(vnfcList.get(0).getName(), "junit-vnfc-name1212"); //vnfc-name + } } -- cgit 1.2.3-korg