aboutsummaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-aai-client/provider
diff options
context:
space:
mode:
authorAnand Chaturvedi <ac204h@att.com>2017-08-24 00:10:17 -0400
committerAnand Chaturvedi <ac204h@att.com>2017-08-24 01:01:46 -0400
commit96119e62a35496ecb0093c0f55300dffb95c8d33 (patch)
tree64874a9c7dd5792185237a7e4164f2c025a7fde5 /appc-outbound/appc-aai-client/provider
parentf0f51b3047ea290e2280af64b39ca0983f3377f5 (diff)
Added New Junit Cases for APPC Design Services
Issue-ID: APPC-168 Change-Id: Ib321bb77af3cb47abfce80d96f50a6b75b34b34e Signed-off-by: Anand Chaturvedi <ac204h@att.com>
Diffstat (limited to 'appc-outbound/appc-aai-client/provider')
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java501
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java336
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java48
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java185
4 files changed, 1039 insertions, 31 deletions
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java
index 92f57ff94..a58522ac8 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java
@@ -40,7 +40,502 @@ import org.openecomp.sdnc.sli.SvcLogicResource;
import org.openecomp.sdnc.sli.aai.AAIClient;
public class MockAaiService extends AaiService {
-
- //ONAP migration
-
+
+ //ONAP migration
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
+ private AAIClient aaiClient;
+
+ public MockAaiService(AAIClient aaic) {
+ super(aaic);
+ }
+
+
+ /*public MockAaiService() {
+ super(new AAIClientMock());
+ }*/
+
+ public SvcLogicContext readResource(String query, String prefix, String resourceType) throws Exception {
+ log.info("In MockRead Resource");
+ SvcLogicContext resourceContext = new SvcLogicContext();
+
+ //prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : "";
+ if ( "generic-vnf".equals(resourceType) ) {
+ populateGenericVnfContext(resourceContext, prefix);
+ }
+ else if("vserver".equals(resourceType) ) {
+ populateVmContext(resourceContext, prefix);
+ }
+ else if("vnfc".equals(resourceType) ) {
+ populateVnfcContext(resourceContext, prefix);
+ }
+
+
+ return resourceContext;
+
+
+
+ }
+
+ public void addVnfc(String vnfcName, Map<String, String> params, String prefix) throws Exception {
+
+
+ if ( vnfcName.startsWith("ibcx")) {
+ assertEquals("ibcxvm0002func0001", vnfcName);
+
+
+ log.info("In AddVnfc " + vnfcName);
+ Map<String, String> expectedParams = getExpectedParams();
+
+
+ /* for (Map.Entry<String, String> entry : params.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+
+
+ log.info("key= " + key + "value = " + value );
+
+ }*/
+ assertEquals(params, expectedParams);
+ }
+ }
+
+
+ public void updateResource( String resource, String resourceKey, Map<String, String> params) throws Exception {
+
+ Map<String, String> expectedParams = new HashMap<String, String>();
+
+
+ expectedParams.put("prov-status", "NVTPROV");
+ assertEquals(params, expectedParams);
+
+ if ( "vserver".equals(resource)) {
+
+ String key = "vserver.vserver-id = 'ibcx00000'" +
+ " AND tenant.tenant-id = 'tenantId'" +
+ " AND cloud-region.cloud-owner = 'cloudOwner'" +
+ " AND cloud-region.cloud-region-id = 'cloudRegionId'";
+
+ assertEquals(key, resourceKey);
+ }
+ else if ( "generic-vnf".equals(resource)) {
+ assertEquals(resourceKey, "generic-vnf.vnf-id = 'ibcx000000'");
+ }
+ else
+ fail("Invalid resource " + resource);
+
+
+
+
+ }
+
+ public Map<String, String> getExpectedParams() throws Exception {
+ Map<String, String> vnfcParams = new HashMap<String, String>();
+
+ vnfcParams.put("vnfc-function-code", "func0");
+
+
+
+ vnfcParams.put("vnfc-type", "ssc0");
+
+ vnfcParams.put("ipaddress-v4-oam-vip", "000.00.00.00");
+
+ vnfcParams.put("prov-status", "NVTPROV");
+ vnfcParams.put("orchestration-status", "CONFIGURED");
+ vnfcParams.put("in-maint", "false");
+ vnfcParams.put("is-closed-loop", "false");
+ vnfcParams.put("group-notation","2");
+
+
+ vnfcParams.put("relationship-list.relationship[0].related-to","vserver");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-key","vserver.vserver-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-value","ibcx00000");
+
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-key","tenant.tenant-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-value","tenantId");
+
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-key","cloud-region.cloud-owner");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-value","cloudOwner");
+
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-key","cloud-region.cloud-region-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-value","cloudRegionId");
+
+
+ vnfcParams.put("relationship-list.relationship[1].related-to","generic-vnf");
+ vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-key","generic-vnf.vnf-id");
+ vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-value","ibcx000000");
+
+
+ vnfcParams.put("relationship-list.relationship[2].related-to","vf-module");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-key","generic-vnf.vnf-id");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-value","ibcx000000");
+
+
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-key","vf-module.vf-module-id");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-value","vfModuleId");
+
+ return vnfcParams;
+ }
+ public void populateVnfcContext(SvcLogicContext ctx, String prefix) {
+ log.info("In populateVnfcContext " + prefix);
+
+ ctx.setAttribute(prefix + ".vnfc-type", "vnfctype1");
+ ctx.setAttribute(prefix + ".vnfc-function-code", "funccode1");
+ ctx.setAttribute(prefix + ".group-notation", "grpnot1");
+ }
+
+ public void populateVmContext(SvcLogicContext ctx, String prefix) {
+ log.info("In populateVmContext " + prefix);
+
+ ctx.setAttribute(prefix + ".vserver-name", "ibcx0000000");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+
+ // Junk
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "test");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vnfc.vnfc-name");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "test");
+
+
+
+ // VNFC
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vnfc");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key", "vnfc.vnfc-name");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value", "ibcx0001vm001vnfc1");
+
+
+ // VFModule
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "vf-module");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key", "vf-module.vf-module-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value", "vfModule1");
+
+
+ }
+
+ public void populateGenericVnfContext(SvcLogicContext ctx, String prefix) throws Exception {
+
+ log.info("In populateGenericVnf " + prefix);
+ ctx.setAttribute(prefix + ".vnf-name", "ibvcx0001");
+ ctx.setAttribute(prefix + ".vnf-type", "vUSP-Metaswitch");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+
+ /* // VM1
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "ibcx001vm001-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-key", "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-value", "sometenant");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-value", "testcloudregionid");
+
+
+ //ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+*/
+ // VM1
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "ibcx001vm001-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-key", "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-value", "sometenant");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-value", "testcloudregionid");
+
+
+ // VM2
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key", "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value", "ibcx000000");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-key", "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-value", "sometenant");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-value", "testcloudregionid");
+
+
+ // Unrelated
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "junk");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "4");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key", "test");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value", "ibcx000000");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-key", "test1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-value", "sometenant");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-key", "test2");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-value", "ATTAIC");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-key", "test3");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-value", "testcloudregionid");
+ }
+
+
+
+ public void populateFirstVnfcData(SvcLogicContext ctx, String prefix) throws Exception {
+
+
+
+ ctx.setAttribute(prefix + "vnf.vm-count", "4");
+
+ ctx.setAttribute(prefix+ "vm[0].vnfc-type", "mmc");
+ ctx.setAttribute(prefix+ "vm[0].vnfc-name", "vnfcname1");
+
+ ctx.setAttribute(prefix+ "vm[1].vnfc-type", "mmc");
+ ctx.setAttribute(prefix+ "vm[1].vnfc-name", "vnfcname2");
+
+ ctx.setAttribute(prefix+ "vm[2].vnfc-type", "ssc");
+ ctx.setAttribute(prefix+ "vm[2].vnfc-name", "vnfcname3");
+
+ ctx.setAttribute(prefix+ "vm[3].vnfc-type", "ssc");
+ ctx.setAttribute(prefix+ "vm[3].vnfc-name", "vnfcname4");
+ }
+
+
+
+ public void populateGroupNotation(SvcLogicContext ctx, String prefix) throws Exception {
+
+
+
+ ctx.setAttribute(prefix + "vnf.vm-count", "5");
+
+ ctx.setAttribute(prefix+ "vm[0].vserver-name", "ibcxvm0001");
+ ctx.setAttribute(prefix+ "vm[0].group-notation", "grpNot1");
+
+ ctx.setAttribute(prefix+ "vm[1].vserver-name", "ibcxvm0002");
+ ctx.setAttribute(prefix+ "vm[1].group-notation", "grpNot2");
+
+
+ ctx.setAttribute(prefix+ "vm[2].vserver-name", "ibcxvm0003");
+ ctx.setAttribute(prefix+ "vm[2].group-notation", "grpNot3");
+
+ ctx.setAttribute(prefix+ "vm[3].vserver-name", "ibcxvm0004");
+ ctx.setAttribute(prefix+ "vm[3].group-notation", "4");
+
+ ctx.setAttribute(prefix+ "vm[4].vserver-name", "ibcxvm0005");
+ ctx.setAttribute(prefix+ "vm[4].group-notation", "4");
+ }
+
+
+ public void populateVnfcRef(SvcLogicContext ctx) throws Exception {
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+ //if ( i == 0 || i == 1 ) {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "2");
+ //}
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "ssc"+i );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "func" +i);
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+ public void populateAllVnfInfo(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute("vnf-id", "ibcx000000");
+
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vnf.vm-count", "2");
+
+
+
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-name", "ibcxvm0000");
+ ctx.setAttribute(prefix+ ".vm[0].vnfc-name", "VNFCNAME");
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-id", "ibcxvm0001id");
+ ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId");
+
+ ctx.setAttribute(prefix+ ".vm[0].vf-module-id", "vfModuleId");
+
+
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-name", "ibcxvm0002");
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-id", "ibcx00000");
+ ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantId");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId");
+
+ ctx.setAttribute(prefix+ ".vm[1].vf-module-id", "vfModuleId");
+
+
+ //ctx.setAttribute(prefix+ ".vm[1].vserver-name", "ibcxvm0002");
+
+
+
+
+ }
+
+
+
+ public void populateAllVnfInfo1(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute("vnf-id", "dbjx0001v");
+
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vnf.vm-count", "2");
+
+
+
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-name", "dbjx0001vm001");
+
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-id", "dbjx0001vm0001id");
+ ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid1");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner1");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId1");
+
+ ctx.setAttribute(prefix+ ".vm[0].vf-module-id", "vfModuleId1");
+
+
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-name", "dbjx0001vm002");
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-id", "dbjx0001vm0002id");
+ ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantId2");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner2");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId2");
+
+ ctx.setAttribute(prefix+ ".vm[1].vf-module-id", "vfModuleId2");
+
+
+
+ }
+
+ public void populateVnfcRefFirstVnfcName(SvcLogicContext ctx) throws Exception {
+
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "first-vnfc-name");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "pair");
+
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "vDBE-I? - DBJX" );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+ public void populateVnfcRefRelValueSame(SvcLogicContext ctx) throws Exception {
+
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+
+ if ( i == 0 ) {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "1");
+ }
+ else {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "relative-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "same");
+ }
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "v-I? - DBJX" );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+
+ public void populateVnfcRefRelValueNext(SvcLogicContext ctx) throws Exception {
+
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+
+ if ( i == 0 ) {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "1");
+ }
+ else {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "relative-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "next");
+ }
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "v-I? - DBJX" );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java
index 4cf6acf1f..0207d0a63 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java
@@ -24,40 +24,328 @@
package org.openecomp.appc.aai.client.aai;
-import java.awt.List;
-import java.io.File;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
+import static org.junit.Assert.assertEquals;
+
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openecomp.appc.aai.client.AppcAaiClientConstant;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.aai.AAIClient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.aai.AAIClient;
-import org.openecomp.sdnc.sli.aai.AAIService;
-import org.openecomp.sdnc.sli.SvcLogicResource;
-import java.util.HashMap;
-import java.util.Map;
+public class TestAaiService {
+ // ONAP merging
-import static org.junit.Assert.*;
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(TestAaiService.class);
+ private AAIClient aaiClient;
+ @Test
+ public void testGetGenericVnfInfo() throws Exception {
+ MockAaiService mockAai = new MockAaiService(aaiClient);
-public class TestAaiService {
- // ONAP merging
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vnfId", "ibcxvm0000");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.getGenericVnfInfo(inParams, ctx);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type"), "vUSP-Metaswitch");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm-count"), "2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id"), "ibcx001vm001-id");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vserver-id"), "ibcx000000");
+ }
+
+ @Test
+ public void testGetVmInfo() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vserverId", "vserverId1");
+ inParams.put("tenantId", "tenantId1");
+ inParams.put("cloudOwner", "cloudOwner1");
+ inParams.put("cloudRegionId", "cloudRegionId1");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.getVMInfo(inParams, ctx);
+
+ printContext(ctx);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vserver-name"), "ibcx0000000");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vnfc-count"), "1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vf-module-id"), "vfModule1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vnfc[0].vnfc-name"), "ibcx0001vm001vnfc1");
+
+ }
+
+ @Test
+ public void testGetVnfcInfo() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vnfcName", "vnfcName1");
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.getVnfcInfo(inParams, ctx);
+
+ printContext(ctx);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnfc.vnfc-type"), null);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnfc.vnfc-function-code"), null);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnfc.group-notation"), "grpnot1");
+
+ }
+
+ @Test
+ public void testGetFirstVnfcNameForVnfcType() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ String prefix = "tmp.vnfInfo.";
+
+ SvcLogicContext ctx = new SvcLogicContext(); // VNFC with specified vnfc
+ // type found
+ mockAai.populateFirstVnfcData(ctx, prefix);
+ String firstVnfcName = mockAai.getFirstVnfcNameForVnfcType(ctx, prefix, "ssc");
+ assertEquals(firstVnfcName, "vnfcname3");
+
+ ctx = new SvcLogicContext(); // no VMS found
+ firstVnfcName = mockAai.getFirstVnfcNameForVnfcType(ctx, prefix, "ssc");
+ assertEquals(firstVnfcName, null);
+
+ ctx = new SvcLogicContext(); // no VMS found with specified type
+ mockAai.populateFirstVnfcData(ctx, prefix);
+ firstVnfcName = mockAai.getFirstVnfcNameForVnfcType(ctx, prefix, "test");
+ assertEquals(firstVnfcName, null);
+
+ }
+
+ @Test
+ public void testGroupNotation() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ String prefix = "tmp.vnfInfo.";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+
+ // printContext(ctx);
+ String grpNotation = mockAai.getGroupNotationForVServer(ctx, prefix, "ibcxvm0002");
+ assertEquals(grpNotation, "grpNot2");
+
+ ctx = new SvcLogicContext(); // no VMS found
+ grpNotation = mockAai.getGroupNotationForVServer(ctx, prefix, "ibcxvm0002");
+ assertEquals(grpNotation, null);
+
+ ctx = new SvcLogicContext(); // no VMS found with specified name
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotationForVServer(ctx, prefix, "test");
+ assertEquals(grpNotation, null);
+
+ }
+
+ @Test
+ public void testGetGroupNotation() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ String prefix = "tmp.vnfInfo.";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ String grpNotation = mockAai.getGroupNotation("fixed-value", "2", null, null, null, null, null);
+ assertEquals(grpNotation, "2");
+
+ mockAai.populateFirstVnfcData(ctx, prefix); // Existing VNFC Found
+ grpNotation = mockAai.getGroupNotation("first-vnfc-name", "2", "currentVnfcName", "currentVServerName", prefix,
+ ctx, "ssc");
+ assertEquals(grpNotation, "vnfcname32");
+
+ ctx = new SvcLogicContext(); // no vnfcs exist in A&AI- Use current
+ // vnfcName
+ grpNotation = mockAai.getGroupNotation("first-vnfc-name", "2", "currentVnfcName", "currentVServerName", prefix,
+ ctx, "ssc");
+ assertEquals(grpNotation, "currentVnfcName2");
+
+ ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotation("relative-value", "same", "currentVnfcName", "ibcxvm0003", prefix, ctx,
+ "ssc");
+ assertEquals(grpNotation, "grpNot2");
+
+ ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotation("relative-value", "next", "currentVnfcName", "ibcxvm0006", prefix, ctx,
+ "ssc");
+ assertEquals(grpNotation, "5");
+
+ ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotation("relative-value", "next", "currentVnfcName", "ibcxvm0003", prefix, ctx,
+ "ssc");
+ assertEquals(grpNotation, null); // Null if grpNotation is not numeric
+
+ }
+
+ @Test
+ public void testInsertVnfcs() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRef(ctx);
+
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+
+ // mockAai.insertVnfcs(inParams,ctx,2, 2) ;
+ }
+
+ @Test
+ public void testUpdateVServerStatus() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+
+ mockAai.updateVServerStatus(inParams, ctx, 2);
+ }
+
+ @Test
+ public void testInsertVnfcsForFirstVnfc() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRefFirstVnfcName(ctx);
+
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
+
+
+ }
+ @Test
+ public void testInsertVnfcsForRelativeValueSame() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRefRelValueSame(ctx);
+
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"), "dbjx0001vm001dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].group-notation"), "1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-name"), "dbjx0001vm002dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].group-notation"), "1");
+ }
+
+ @Test
+ public void testInsertVnfcsForRelativeValueNext() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRefRelValueNext(ctx);
+
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
+
+
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"), "dbjx0001vm001dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].group-notation"), "1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-name"), "dbjx0001vm002dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].group-notation"), "2");
+ }
+
+ @Test
+ public void testUpdateVnfStatus() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+
+ mockAai.updateVnfStatus(inParams, ctx);
+ }
+
+ @Test
+ public void testReadResource() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+ // AaiService mockAai = new AaiService(new AAIClientMock());
+
+ String vnfId = "ibcx0001v";
+ String resourceKey = "generic-vnf.vnf-id = '" + vnfId + "'";
+ String resourceType = "generic-vnf";
+ String queryPrefix = "vnfInfo";
+ SvcLogicContext ctx = mockAai.readResource(resourceKey, queryPrefix, resourceType);
+
+ // System.out.println("VNF TYPE " + queryPrefix + ".vnf.vnf-type");
+
+ assertEquals(ctx.getAttribute("vnfInfo.vnf-type"), "vUSP-Metaswitch");
+
+ }
+ private void printContext(SvcLogicContext ctx) throws Exception {
+ for (String key : ctx.getAttributeKeySet()) {
+ log.info(" KEY " + key);
+ log.info(" VALUE " + ctx.getAttribute(key));
+ }
+ }
}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java
index 41fa6da06..ac7a6735d 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java
@@ -22,6 +22,7 @@
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.appc.aai.client.node;
import static junit.framework.Assert.assertEquals;
@@ -39,6 +40,49 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.aai.AAIClient;
public class MockAaiService extends AaiService {
-
- // ONAP merging
+
+ // ONAP merging
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
+ private AAIClient aaiClient;
+
+ /*public MockAaiService() {
+ super(new AAIClientMock());
+ }*/
+
+
+ public MockAaiService(AAIClient aaic) {
+ super(aaic);
+ }
+
+ public void getVMInfo(Map<String, String> params,SvcLogicContext ctx ) throws Exception {
+ log.info("Received Mock getVmInfo call with params : " + params);
+ String vserverId = params.get("vserverId");
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+ if ( vserverId.equals("ibcm0001id")) {
+ ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName1");
+ ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule1");
+ }
+ else {
+ ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName2");
+ ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule2");
+ ctx.setAttribute(prefix + ".vm.vnfc[0].vnfc-name", "vnfcName2");
+ }
+
+ }
+
+
+ public void getVnfcInfo(Map<String, String> params,SvcLogicContext ctx ) throws Exception {
+ log.info("Received Mock getVmInfo call with params : " + params);
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+
+ String vnfcName = params.get("vnfcName");
+
+ if ( vnfcName.equals("vnfcName2") ) {
+ ctx.setAttribute(prefix + ".vnfc.vnfc-type", "vnfcType2");
+ ctx.setAttribute(prefix + ".vnfc.vnfc-function-code", "vnfcFuncCode2");
+ ctx.setAttribute(prefix + ".vnfc.group-notation", "vnfcGrpNot2");
+ }
+
+
+ }
}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java
index 5f88a9af8..c589dc300 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java
@@ -46,12 +46,193 @@ import org.openecomp.appc.aai.client.aai.TestAaiService;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.aai.AAIClient;
import com.fasterxml.jackson.databind.ObjectMapper;
public class TestAAIResourceNode {
-
- //Removed for ONAP integration
+
+ //Removed for ONAP integration
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(TestAAIResourceNode.class);
+
+ @Test
+ public void sortVServer() throws Exception{
+
+ //log.info("Test");
+
+ ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
+ HashMap<String, String> vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId9");
+ vserverMap.put("tenant-id", "tenantId9");
+ vserverMap.put("cloud-owner", "cloudOwner9");
+ vserverMap.put("cloud-region-id", "cloudRegionId9");
+ vserverMap.put("vserver-name", "vServerName9");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId1");
+ vserverMap.put("tenant-id", "tenantId1");
+ vserverMap.put("cloud-owner", "cloudOwner1");
+ vserverMap.put("cloud-region-id", "cloudRegionId1");
+ vserverMap.put("vserver-name", "vServerName1");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId3");
+ vserverMap.put("tenant-id", "tenantId3");
+ vserverMap.put("cloud-owner", "cloudOwner3");
+ vserverMap.put("cloud-region-id", "cloudRegionId3");
+ vserverMap.put("vserver-name", "vServerName3");
+ vservers.add(vserverMap);
+ Collections.sort(vservers, new Comparator<Map<String, String>>() {
+ @Override
+ public int compare(Map<String, String> o1, Map<String, String> o2) {
+ return o1.get("vserver-name").compareTo(o2.get("vserver-name"));
+ }
+ });
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+ aai.populateContext(vservers, ctx, "vserver.");
+ log.info(ctx.getAttribute("vserver.vm[0].vserver-name"));
+ }
+
+ @Test
+ public void testAllVServer() throws Exception{
+
+ MockAAIResourceNode mrn = new MockAAIResourceNode();
+ SvcLogicContext ctx = new SvcLogicContext();
+ populateAllVServerInfo(ctx, "tmp.vnfInfo");
+ Map<String, String> inParams =new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ mrn.getAllVServersVnfcsInfo(inParams, ctx);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm-count"), "2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vm-count"), "2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vm-with-no-vnfcs-count"), "0");
+ // VM1
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id"), "ibcsm0002id");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].tenant-id"), "tenantid2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-owner"), "cloudOwner2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-region-id"), "cloudRegionId2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-name"), "vserverName2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vf-module-id"), "vfModule2");
+ //assertNull(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"));
+
+ // VM2
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vserver-id"), "ibcxvm0001id");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].tenant-id"), "tenantid1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].cloud-owner"), "cloudOwner1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].cloud-region-id"), "cloudRegionId1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vserver-name"), "vserverName2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vf-module-id"), "vfModule2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-name"), "vnfcName2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type"), "vnfcType2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-function-code"), "vnfcFuncCode2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].group-notation"), "vnfcGrpNot2");
+ }
+ public void populateAllVServerInfo(SvcLogicContext ctx, String prefix) throws Exception {
+ ctx.setAttribute("vnf-id", "ibcx0001v");
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vm-count", "2");
+ ctx.setAttribute(prefix+ ".vm[0].vserver-id", "ibcsm0002id");
+ ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid2");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner2");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId2");
+ ctx.setAttribute(prefix+ ".vm[1].vserver-id", "ibcxvm0001id");
+ ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantid1");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner1");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId1");
+
+ }
+
+ public static class MockAAIResourceNode extends AAIResourceNode {
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAAIResourceNode.class);
+ private AAIClient aaiClient;
+
+ public AaiService getAaiService() {
+ log.info("In MockAAI");
+ return new MockAaiService(aaiClient);
+ }
+ }
+
+ @Test
+ public void testPopulateContext() throws Exception{
+
+ ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
+ HashMap<String, String> vserverMap = new HashMap<String, String>();
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId1");
+ vserverMap.put("tenant-id", "tenantId1");
+ vserverMap.put("cloud-owner", "cloudOwner1");
+ vserverMap.put("cloud-region-id", "cloudRegionId1");
+ vserverMap.put("vserver-name", "vServerName1");
+ vserverMap.put("vnfc-name", "vnfcName1");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId3");
+ vserverMap.put("tenant-id", "tenantId3");
+ vserverMap.put("cloud-owner", "cloudOwner3");
+ vserverMap.put("cloud-region-id", "cloudRegionId3");
+ vserverMap.put("vserver-name", "vServerName3");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId9");
+ vserverMap.put("tenant-id", "tenantId9");
+ vserverMap.put("cloud-owner", "cloudOwner9");
+ vserverMap.put("cloud-region-id", "cloudRegionId9");
+ vserverMap.put("vserver-name", "vServerName9");
+ vservers.add(vserverMap);
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+ aai.populateContext(vservers, ctx, "tmp.vnfInfo.");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-name"), "vServerName1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].tenant-id"), "tenantId1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-owner"), "cloudOwner1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-region-id"), "cloudRegionId1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id"), "vserverId1");
+ assertEquals(ctx.getAttribute("vm-name"), "vServerName3");
+ }
+
+ @Test
+ public final void testGetVnfInfo() {
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+Map<String, String> inParams =new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ try {
+ aai.getVnfInfo(inParams, ctx);
+ } catch (SvcLogicException e) {
+ e.printStackTrace();
+ }
+
+ }
+ @Test
+ public final void testaddVnfcs()
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+Map<String, String> inParams =new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ try {
+ aai.addVnfcs(inParams, ctx);
+ } catch (SvcLogicException e) {
+ e.printStackTrace();
+ }
+
+ }
+ @Test
+ public final void testupdateVnfAndVServerStatus(){
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+Map<String, String> inParams =new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ try {
+ aai.updateVnfAndVServerStatus(inParams, ctx);
+ } catch (SvcLogicException e) {
+ e.printStackTrace();
+ }
+ }
}