summaryrefslogtreecommitdiffstats
path: root/appc-outbound
diff options
context:
space:
mode:
Diffstat (limited to 'appc-outbound')
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java47
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java456
2 files changed, 290 insertions, 213 deletions
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
index cb439ee16..c1f42a73d 100644
--- a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
@@ -247,7 +247,7 @@ public class AaiService {
String vserverName = ctx.getAttribute(aaiRefKey + "vserver-name");
String vnfcName = vserverName + vnfcFuncCode + "001";
String groupNotation = getGroupNotation(groupNotationType, groupNotationValue, vnfcName, vserverName,
- prefix, ctx, vnfcType);
+ prefix, ctx, vnfcType, vnfcFuncCode, vmCount);
String ipAddressV4OamVip = null;
if ("Y".equals(populateIpAddressV4OamVip)) {
@@ -372,7 +372,7 @@ public class AaiService {
}
public String getGroupNotation(String groupNotationType, String groupNotationValue, String vnfcName,
- String vserverName, String prefix, SvcLogicContext ctx, String vnfcRefVnfcType) throws Exception {
+ String vserverName, String prefix, SvcLogicContext ctx, String vnfcRefVnfcType, String vnfcFuncCode, int vmCount) throws Exception {
String grpNotation = null;
@@ -446,11 +446,54 @@ public class AaiService {
}
}
}
+ else if ("existing-value".equals(groupNotationType)) {
+ /* This is a new value being added. Find the existing vnfc records in A&AI inventory with the same vnfc-function code as the value in vnfc_reference table.
+ * Verify that the group-notation value is the same for all such records found in inventory.
+ * if all records do not have the same group-notation value, write the new vnfc record to A&AI inventory without a group-notation value and continue to the next VM in the vnfc_reference table. A 501 intermediate error message should be sent after all new VNFC records have been added to A&AI.
+ If all records match, use the same group-notation value for the new vnfc record as found in the existing vnfc records.
+*/
+ grpNotation = getGroupNotationForExistigValue(ctx, prefix, vnfcFuncCode, vmCount);
+ }
log.info("RETURNED GROUPNOTATION " + grpNotation);
return grpNotation;
}
+ public String getGroupNotationForExistigValue(SvcLogicContext ctx, String prefix, String vnfcFuncCode, int vmCount) {
+ String vfModuleId = ctx.getAttribute("req-vf-module-id"); //Coming from request-params
+ boolean first=true;
+ String aaiGroupNotationValue=null;
+ for (int i=0;i<vmCount;i++ )
+ {
+ String ind = "tmp.vnfInfo.vm["+i+"].";
+ String aaiFuncCode = ctx.getAttribute(ind+"vnfc-function-code");
+ String aaiGroupNotation = ctx.getAttribute(ind+"group-notation");
+ String aaiVfModuleId = ctx.getAttribute(ind+"vf-module-id");
+
+ log.info("getGroupNotationForExistigValue()::: vfModuleId="+vfModuleId+", aaiFuncCode="+aaiFuncCode
+ +", aaiGroupNotation="+aaiGroupNotation+",aaiVfMOduleId="+aaiVfModuleId);
+
+ if (StringUtils.isNotBlank(aaiFuncCode) && aaiFuncCode.equals(vnfcFuncCode) &&
+ (StringUtils.isNotBlank(vfModuleId) && StringUtils.isNotBlank(aaiVfModuleId) && aaiVfModuleId.equals(vfModuleId))) {
+ if (null==aaiGroupNotationValue && first) {
+ if (null == aaiGroupNotation) {//Return if null
+ return null;
+ }
+ aaiGroupNotationValue = ctx.getAttribute(ind+"group-notation");
+ first=false;
+ }
+ else {
+ if (!StringUtils.equals(aaiGroupNotationValue, ctx.getAttribute(ind+"group-notation"))) {
+ log.info("Values are different, returning null");
+ return null;
+ }
+ }
+ }
+ }
+
+ return aaiGroupNotationValue;
+ }
+
public String getGroupNotationForVServer(SvcLogicContext ctx, String prefix, String vserverName) {
String vmCountStr = ctx.getAttribute(prefix + "vnf.vm-count");
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
index aa807087f..717348584 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
@@ -2,22 +2,22 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
@@ -29,6 +29,7 @@ import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
@@ -37,315 +38,348 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class TestAaiService {
- // ONAP merging
+ // ONAP merging
- private static final EELFLogger log = EELFManager.getInstance().getLogger(TestAaiService.class);
- private AAIClient aaiClient;
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(TestAaiService.class);
+ private AAIClient aaiClient;
- @Test
- public void testGetGenericVnfInfo() throws Exception {
+ @Test
+ public void testGetGenericVnfInfo() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- Map<String, String> inParams = new HashMap<String, String>();
- inParams.put("vnfId", "ibcxvm0000");
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vnfId", "ibcxvm0000");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.getGenericVnfInfo(inParams, ctx);
+ 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");
- }
+ 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 {
+ @Test
+ public void testGetVmInfo() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ 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");
+ 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();
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.getVMInfo(inParams, ctx);
+ mockAai.getVMInfo(inParams, ctx);
- printContext(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");
+ 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 {
+ @Test
+ public void testGetVnfcInfo() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- Map<String, String> inParams = new HashMap<String, String>();
- inParams.put("vnfcName", "vnfcName1");
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vnfcName", "vnfcName1");
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.getVnfcInfo(inParams, ctx);
+ mockAai.getVnfcInfo(inParams, ctx);
- printContext(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");
+ 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 {
+ @Test
+ public void testGetFirstVnfcNameForVnfcType() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- String prefix = "tmp.vnfInfo.";
+ 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");
+ 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
+ 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);
+ 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 {
+ @Test
+ public void testGroupNotation() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- String prefix = "tmp.vnfInfo.";
+ String prefix = "tmp.vnfInfo.";
- SvcLogicContext ctx = new SvcLogicContext();
- mockAai.populateGroupNotation(ctx, prefix);
+ SvcLogicContext ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
- // printContext(ctx);
- String grpNotation = mockAai.getGroupNotationForVServer(ctx, prefix, "ibcxvm0002");
- assertEquals(grpNotation, "grpNot2");
+ // 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
+ 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);
+ 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 {
+ @Test
+ public void testGetGroupNotation() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- String prefix = "tmp.vnfInfo.";
+ String prefix = "tmp.vnfInfo.";
- SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicContext ctx = new SvcLogicContext();
- String grpNotation = mockAai.getGroupNotation("fixed-value", "2", null, null, null, null, null);
- assertEquals(grpNotation, "2");
+ String grpNotation = mockAai.getGroupNotation("fixed-value", "2", null, null, null, null, null,null, 0);
+ 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");
+ mockAai.populateFirstVnfcData(ctx, prefix); // Existing VNFC Found
+ grpNotation = mockAai.getGroupNotation("first-vnfc-name", "2", "currentVnfcName", "currentVServerName", prefix,
+ ctx, "ssc", null, 0);
+ 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(); // no vnfcs exist in A&AI- Use current
+ // vnfcName
+ grpNotation = mockAai.getGroupNotation("first-vnfc-name", "2", "currentVnfcName", "currentVServerName", prefix,
+ ctx, "ssc", null, 0);
+ 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", "same", "currentVnfcName", "ibcxvm0003", prefix, ctx,
+ "ssc", null, 0);
+ 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", "ibcxvm0006", prefix, ctx,
+ "ssc",null,0);
+ 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
+ ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotation("relative-value", "next", "currentVnfcName", "ibcxvm0003", prefix, ctx,
+ "ssc",null,0);
+ assertEquals(grpNotation, null); // Null if grpNotation is not numeric
- }
+ }
- @Test
- public void testInsertVnfcs() throws Exception {
+@Test
+ public void testInsertVnfcs() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- Map<String, String> inParams = new HashMap<String, String>();
+ Map<String, String> inParams = new HashMap<String, String>();
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.populateVnfcRef(ctx);
+ mockAai.populateVnfcRef(ctx);
- mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
- // mockAai.insertVnfcs(inParams,ctx,2, 2) ;
- }
+ // mockAai.insertVnfcs(inParams,ctx,2, 2) ;
+ }
- @Test
- public void testUpdateVServerStatus() throws Exception {
+ @Test
+ public void testUpdateVServerStatus() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- Map<String, String> inParams = new HashMap<String, String>();
+ Map<String, String> inParams = new HashMap<String, String>();
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
- mockAai.updateVServerStatus(inParams, ctx, 2);
- }
+ mockAai.updateVServerStatus(inParams, ctx, 2);
+ }
- @Test
- public void testInsertVnfcsForFirstVnfc() throws Exception {
+ @Test
+ public void testInsertVnfcsForFirstVnfc() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- Map<String, String> inParams = new HashMap<String, String>();
+ Map<String, String> inParams = new HashMap<String, String>();
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.populateVnfcRefFirstVnfcName(ctx);
+ mockAai.populateVnfcRefFirstVnfcName(ctx);
- mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
- mockAai.insertVnfcs(inParams, ctx, 2, 2);
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
-
- }
- @Test
- public void testInsertVnfcsForRelativeValueSame() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ }
+ @Test
+ public void testInsertVnfcsForRelativeValueSame() throws Exception {
- Map<String, String> inParams = new HashMap<String, String>();
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ Map<String, String> inParams = new HashMap<String, String>();
- SvcLogicContext ctx = new SvcLogicContext();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- mockAai.populateVnfcRefRelValueSame(ctx);
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+ mockAai.populateVnfcRefRelValueSame(ctx);
- mockAai.insertVnfcs(inParams, ctx, 2, 2);
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
- 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");
- }
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
- @Test
- public void testInsertVnfcsForRelativeValueNext() throws Exception {
+ 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");
+ }
- MockAaiService mockAai = new MockAaiService(aaiClient);
+ @Test
+ public void testInsertVnfcsForRelativeValueNext() throws Exception {
- Map<String, String> inParams = new HashMap<String, String>();
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ Map<String, String> inParams = new HashMap<String, String>();
- SvcLogicContext ctx = new SvcLogicContext();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- mockAai.populateVnfcRefRelValueNext(ctx);
+ SvcLogicContext ctx = new SvcLogicContext();
- mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+ mockAai.populateVnfcRefRelValueNext(ctx);
- mockAai.insertVnfcs(inParams, ctx, 2, 2);
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
-
-
- 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");
- }
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
- @Test
- public void testUpdateVnfStatus() throws Exception {
- MockAaiService mockAai = new MockAaiService(aaiClient);
- Map<String, String> inParams = new HashMap<String, String>();
+ 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");
+ }
- inParams.put("responsePrefix", "tmp.vnfInfo");
+ @Test
+ public void testUpdateVnfStatus() throws Exception {
- SvcLogicContext ctx = new SvcLogicContext();
+ MockAaiService mockAai = new MockAaiService(aaiClient);
- mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+ Map<String, String> inParams = new HashMap<String, String>();
- mockAai.updateVnfStatus(inParams, ctx);
- }
+ inParams.put("responsePrefix", "tmp.vnfInfo");
- @Test
- public void testReadResource() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
- MockAaiService mockAai = new MockAaiService(aaiClient);
- // AaiService mockAai = new AaiService(new AAIClientMock());
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
- String vnfId = "ibcx0001v";
- String resourceKey = "generic-vnf.vnf-id = '" + vnfId + "'";
- String resourceType = "generic-vnf";
- String queryPrefix = "vnfInfo";
- SvcLogicContext ctx = mockAai.readResource(resourceKey, queryPrefix, resourceType);
+ mockAai.updateVnfStatus(inParams, ctx);
+ }
- // System.out.println("VNF TYPE " + queryPrefix + ".vnf.vnf-type");
+ @Test
+ public void testReadResource() throws Exception {
- assertEquals(ctx.getAttribute("vnfInfo.vnf-type"), "vUSP-Metaswitch");
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+ // AaiService mockAai = new AaiService(new AAIClientMock());
- }
- private void printContext(SvcLogicContext ctx) throws Exception {
- for (String key : ctx.getAttributeKeySet()) {
- log.info(" KEY " + key);
- log.info(" VALUE " + ctx.getAttribute(key));
- }
- }
+ 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));
+ }
+ }
+
+ @Test
+ public void testGetGroupNotationForExistingValue() throws Exception {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("req-vf-module-id", "vfmodule01");
+ ctx.setAttribute("tmp.vnfInfo.vm[0].vf-module-id", "vfmodule01");
+ ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-function-code", "fc1");
+ ctx.setAttribute("tmp.vnfInfo.vm[0].group-notation", "gn1");
+ ctx.setAttribute("tmp.vnfInfo.vm[1].vf-module-id", "vfmodule01");
+ ctx.setAttribute("tmp.vnfInfo.vm[1].vnfc-function-code", "fc1");
+ ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-function-code", "fc1");
+ ctx.setAttribute("tmp.vnfInfo.vm[0].group-notation", "gn2");
+ MockAaiService aai=new MockAaiService(aaiClient);
+ String groupNotationValue1 = aai.getGroupNotationForExistigValue(ctx, "tmp.vnfInfo", "fc1", 2);
+ assertEquals (groupNotationValue1,null);
+
+ ctx.setAttribute("tmp.vnfInfo.vm[0].group-notation", "gn1");
+ ctx.setAttribute("tmp.vnfInfo.vm[1].group-notation", "gn1");
+ String groupNotationValue2 = aai.getGroupNotationForExistigValue(ctx, "tmp.vnfInfo", "fc1", 2);
+ assertEquals (groupNotationValue2,"gn1");
+
+ ctx.setAttribute("tmp.vnfInfo.vm[2].vf-module-id", "vfmodule01");
+ ctx.setAttribute("tmp.vnfInfo.vm[2].vnfc-function-code", "fc1");
+ ctx.setAttribute("tmp.vnfInfo.vm[2].group-notation", "gn2");
+ String groupNotationValue3 = aai.getGroupNotationForExistigValue(ctx, "tmp.vnfInfo", "fc1", 3);
+ assertEquals (groupNotationValue3,null);
+
+ ctx.setAttribute("tmp.vnfInfo.vm[2].group-notation", "gn1");
+ String groupNotationValue4 = aai.getGroupNotationForExistigValue(ctx, "tmp.vnfInfo", "fc1", 3);
+ assertEquals (groupNotationValue4,"gn1");
+
+ }
}