summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java')
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java131
1 files changed, 127 insertions, 4 deletions
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 3753ea6..f808ebe 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
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.List;
import java.util.UUID;
import org.junit.Rule;
import org.junit.Test;
@@ -43,6 +44,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
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;
@RunWith(SpringJUnit4ClassRunner.class)
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
@@ -59,6 +63,8 @@ public class RestUtilTest {
@Autowired
private String aaiBasicAuthorization;
+ private static final String DEPTH = "?depth=2";
+
@Rule
public WireMockRule aaiEnricherRule = new WireMockRule(wireMockConfig().port(9808));
@@ -132,7 +138,7 @@ public class RestUtilTest {
////
@Test
- public void testretrieveAAIModelDataFromAAI() throws Exception {
+ public void testretrieveAAIModelDataFromAAI_PNF() throws Exception {
String transactionId = UUID.randomUUID().toString();
String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json
@@ -140,16 +146,16 @@ public class RestUtilTest {
// 1. simulate the response to obtainResourceLink based on ServiceInstanceId
addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule);
// 2. simulate the response of AAI (1 vnf and 1 pnf)
- addResponse( "/aai/v11/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ 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.json", aaiEnricherRule);
// 3. simulate the rsp of VNF
- addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39?depth=2",
+ addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH,
"junit/genericVnfInput.json", aaiEnricherRule);
// 4. simulate the response of PNF based on the resourceLink in (2)
//note: match pnf_id in junit/aai-service-instance.json
- addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName",
+ addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName" + DEPTH,
"junit/pnfSampleInput.json", aaiEnricherRule);
ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization);
@@ -158,5 +164,122 @@ public class RestUtilTest {
assertEquals(modelCtx.getPnfs().size(), 1);
}
+ ///Verify the relationship serviceInstanceId -> vnf -> vserver
+ @Test
+ public void testretrieveAAIModelDataFromAAI_VSERVER_PSERVER() 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_set2.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.json", aaiEnricherRule);
+
+ // 5. simulate the rsp of pserver
+ // note: match pserver hostname to the path of "pserver" in (4)
+ addResponse(
+ "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH,
+ "junit/pserverInput_set2.json", aaiEnricherRule);
+
+ ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization);
+
+ // 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
+ assertEquals(vmList.get(0).getPServer().getName(), "mtn96compute.cci.att.com"); //pserver-name
+ }
+
+ ////
+ @Test
+ public void testretrieveAAIModelDataFromAAI_PInterface_with_PNF() 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 and 1 pnf)
+ 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.json", aaiEnricherRule);
+
+ // 3. simulate the rsp of VNF
+ addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH,
+ "junit/genericVnfInput.json", aaiEnricherRule);
+
+ // 4. simulate the response of PNF based on the resourceLink in (2)
+ //note: match pnf_id in junit/aai-service-instance.json
+ addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName" + DEPTH,
+ "junit/pnfInput_w_pInterface.json", aaiEnricherRule);
+
+ ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization);
+
+ assertEquals(modelCtx.getVnfs().size(), 1);
+ assertEquals(modelCtx.getPnfs().size(), 1);
+
+ }
+
+ @Test
+ public void testretrieveAAIModelDataFromAAI_P_Interface_with_PSERVER() 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_set2.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.json", aaiEnricherRule);
+
+ // 5. simulate the rsp of pserver
+ // note: match pserver hostname to the path of "pserver" in (4)
+ addResponse(
+ "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH,
+ "junit/pserverInput_with_pInterface.json", aaiEnricherRule);
+
+ ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization);
+
+ // 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).getPServer().getPInterfaceList().size(), 1);
+ assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getName(), "bdc3cc2a-c73e-414f-7ddb-367de92801cb"); //interface-name
+ }
}