From 09e3af8778d9a84ecea2f2085708f22554bd04b8 Mon Sep 17 00:00:00 2001 From: "Leigh, Phillip (pl876u)" Date: Wed, 30 Jan 2019 18:21:27 -0500 Subject: Handle l3Network in AaiCtxBuilder Issue-ID: LOG-763 Change-Id: I7c1d24727824eb43603b096f63201e4e7195f35b Signed-off-by: Leigh, Phillip (pl876u) --- .../pomba_aai_context_builder/RestUtilTest.java | 125 +++++++++++++++++++++ .../pomba_aai_context_builder/VfModuleTest.java | 13 ++- 2 files changed, 132 insertions(+), 6 deletions(-) (limited to 'src/test/java/org/onap') diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java index f808ebe..5ded51f 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java +++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java @@ -47,6 +47,7 @@ import org.onap.pomba.common.datatypes.ModelContext; import org.onap.pomba.common.datatypes.VNF; import org.onap.pomba.common.datatypes.VFModule; import org.onap.pomba.common.datatypes.VM; +import org.onap.pomba.common.datatypes.Network; @RunWith(SpringJUnit4ClassRunner.class) @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) @@ -282,4 +283,128 @@ public class RestUtilTest { assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getName(), "bdc3cc2a-c73e-414f-7ddb-367de92801cb"); //interface-name } + ///Verify the relationship serviceInstanceId -> l3network + @Test + public void testretrieveAAIModelDataFromAAI_L3_network_in_service_level () 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; + // 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_set3.json", aaiEnricherRule); + + // 3. simulate the rsp of l3-network + // note: match to network-id to the path of "l3network" in (2: aai-service-instance_set3) + addResponse( + "/aai/v13/network/l3-networks/l3-network/01e8d84a-l3-network-1" + DEPTH, + "junit/l3-network-1.json", aaiEnricherRule); + addResponse( + "/aai/v13/network/l3-networks/l3-network/01e8d84a-l3-network-2" + DEPTH, + "junit/l3-network-2.json", aaiEnricherRule); + + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + + // verify results + List networkList = modelCtx.getNetworkList(); + assertEquals(networkList.size(), 2); + assertEquals(networkList.get(0).getUuid(), "01e8d84a-l3-network-1"); + assertEquals(networkList.get(1).getUuid(), "01e8d84a-l3-network-2"); + } + + ///Verify the relationship serviceInstanceId -> vnf -> l3network + @Test + public void testretrieveAAIModelDataFromAAI_L3_network_in_VNF_level() 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; + // 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_set3.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 l3-network + // note: match to network-id to the path of "l3network" in (3: genericVnfInput_set3) + addResponse( + "/aai/v13/network/l3-networks/l3-network/01e8d84a-l3-network-1" + DEPTH, + "junit/l3-network-1.json", aaiEnricherRule); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + + // verify results + List vnfList = modelCtx.getVnfs(); + assertEquals(vnfList.size(), 1); + List networkList = vnfList.get(0).getNetworks(); + assertEquals(networkList.size(), 1); + assertEquals(networkList.get(0).getUuid(), "01e8d84a-l3-network-1"); + } + + @Test + public void testretrieveAAIModelDataFromAAI_L3_network_in_vModule_level() 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; + // 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_set4.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 l3-network + // note: match to network-id to the path of "l3network" in (3: genericVnfInput_set4) + addResponse( + "/aai/v13/network/l3-networks/l3-network/01e8d84a-l3-network-1" + DEPTH, + "junit/l3-network-1.json", aaiEnricherRule); + addResponse( + "/aai/v13/network/l3-networks/l3-network/01e8d84a-l3-network-2" + DEPTH, + "junit/l3-network-2.json", aaiEnricherRule); + + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + + // verify results + List vnfList = modelCtx.getVnfs(); + assertEquals(vnfList.size(), 1); + List vfModuleList = vnfList.get(0).getVfModules(); + assertEquals(vfModuleList.size(), 1); + + List networkList = vfModuleList.get(0).getNetworks(); + assertEquals(networkList.size(), 2); + assertEquals(networkList.get(0).getUuid(), "01e8d84a-l3-network-1"); + assertEquals(networkList.get(1).getUuid(), "01e8d84a-l3-network-2"); + } + } diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModuleTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModuleTest.java index b79f8ca..77da591 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModuleTest.java +++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModuleTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.L3networkInstance; import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; import org.onap.pomba.contextbuilder.aai.datatype.Relationship; import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; @@ -53,7 +54,7 @@ public class VfModuleTest { vfModule.setRelationshipList(relationshipList); assertEquals("vfModuleId", vfModule.getVfModuleId()); - assertEquals("vfModuleName", vfModule.getVfMduleName()); + assertEquals("vfModuleName", vfModule.getVfModuleName()); assertEquals("heatStackId", vfModule.getHeatStackId()); assertEquals("orchestrationStatus", vfModule.getOrchestrationStatus()); assertTrue(vfModule.getIsBaseVfModule()); @@ -67,10 +68,10 @@ public class VfModuleTest { @Test public void testVfModuleWithParameters() { - VfModule vfModule = new VfModule("vfModuleId", "vfModuleName", "heatStackId", "orchestrationStatus", true, "resourceVersion", "modelInvariantId", "modelVersionId", "modelCustomizationId", 1, new RelationshipList() ); + VfModule vfModule = new VfModule("vfModuleId", "vfModuleName", "heatStackId", "orchestrationStatus", true, "resourceVersion", "modelInvariantId", "modelVersionId", "modelCustomizationId", 1, new RelationshipList() , new ArrayList()); assertEquals("vfModuleId", vfModule.getVfModuleId()); - assertEquals("vfModuleName", vfModule.getVfMduleName()); + assertEquals("vfModuleName", vfModule.getVfModuleName()); assertEquals("heatStackId", vfModule.getHeatStackId()); assertEquals("orchestrationStatus", vfModule.getOrchestrationStatus()); assertTrue(vfModule.getIsBaseVfModule()); @@ -87,9 +88,9 @@ public class VfModuleTest { @Test public void testVfModuleEquals() { - VfModule vfModule1 = new VfModule("vfModuleId1", "vfModuleName1", "heatStackId1", "orchestrationStatus1", true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", 1, new RelationshipList() ); - VfModule vfModule2 = new VfModule("vfModuleId2", "vfModuleName2", "heatStackId2", "orchestrationStatus2", true, "resourceVersion2", "modelInvariantId2", "modelVersionId2", "modelCustomizationId2", 1, new RelationshipList() ); - VfModule vfModule3 = new VfModule("vfModuleId1", "vfModuleName1", "heatStackId1", "orchestrationStatus1", true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", 1, new RelationshipList() ); + VfModule vfModule1 = new VfModule("vfModuleId1", "vfModuleName1", "heatStackId1", "orchestrationStatus1", true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", 1, new RelationshipList() , new ArrayList()); + VfModule vfModule2 = new VfModule("vfModuleId2", "vfModuleName2", "heatStackId2", "orchestrationStatus2", true, "resourceVersion2", "modelInvariantId2", "modelVersionId2", "modelCustomizationId2", 1, new RelationshipList() , new ArrayList()); + VfModule vfModule3 = new VfModule("vfModuleId1", "vfModuleName1", "heatStackId1", "orchestrationStatus1", true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", 1, new RelationshipList() , new ArrayList()); assertTrue(vfModule1.equals(vfModule1)); assertTrue(!vfModule1.equals(vfModule2)); -- cgit 1.2.3-korg