aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound
diff options
context:
space:
mode:
authorDilip kumar Pampana <dp583p@att.com>2018-06-19 17:50:30 -0400
committerTakamune Cho <tc012c@att.com>2018-06-22 13:30:47 +0000
commitacc007df9af5de867678282e49c3ab38e045157c (patch)
treeaad98f20c69c71a9a8af1d1508a50f3a9f881b1d /appc-inbound
parent2184f1d78c25d0a487ecd8014cd9ac1ff173303b (diff)
Artifact-Handler - Appc-Inbound
Support Multiple Templates For Configure and ConfigModify for VNFs with VNFC level templates Issue-ID: APPC-1010 Change-Id: I7540af3b793bac696bdc28aabc3c0c8e0c13d29e Signed-off-by: Dilip kumar Pampana <dp583p@att.com>
Diffstat (limited to 'appc-inbound')
-rwxr-xr-xappc-inbound/appc-artifact-handler/provider/pom.xml5
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java126
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java62
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java3
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java48
5 files changed, 146 insertions, 98 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/pom.xml b/appc-inbound/appc-artifact-handler/provider/pom.xml
index 44331d3bb..ed25b1684 100755
--- a/appc-inbound/appc-artifact-handler/provider/pom.xml
+++ b/appc-inbound/appc-artifact-handler/provider/pom.xml
@@ -221,5 +221,10 @@ limitations under the License.
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.54</version>
+ </dependency>
</dependencies>
</project>
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java
index e1c76ecf8..873c45006 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java
@@ -237,7 +237,6 @@ public class DBService {
whereClause = WHERE_VNF_TYPE_QUERY_STR + SdcArtifactHandlerConstants.VNF_TYPE;
whereClause = resolveWhereClause(context, db, whereClause);
if (validate(db)) {
- if (!db.equals(SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION)) {
String key = "select COUNT(*) from " + db + whereClause;
log.info("SELECT String : " + key);
status = serviceLogic.query("SQL", false, null, key, null, null, context);
@@ -245,19 +244,9 @@ public class DBService {
String count = context.getAttribute("COUNT(*)");
log.info("Number of row Returned : " + count + ": " + status + ":");
return tryAddCountAttribute(context, count);
- } else {
- log.info("Check for update or insert for properties file");
- String protocol = context.getAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL);
- String action = context.getAttribute(SdcArtifactHandlerConstants.ACTION);
- String vnfType = context.getAttribute(SdcArtifactHandlerConstants.VNF_TYPE);
- PropertiesConfiguration conf = new PropertiesConfiguration(
- System.getenv("APPC_CONFIG_DIR") + "/appc_southbound.properties");
- String property = tryCreatePropertyStr(protocol, action, vnfType);
- return keyExists(conf, property);
- }
}
return false;
- } catch (SvcLogicException | ConfigurationException e) {
+ } catch (SvcLogicException e) {
throw new DBException("An error occurred while checking for artifact update", e);
}
}
@@ -294,14 +283,6 @@ public class DBService {
}
}
- private String tryCreatePropertyStr(String protocol, String action, String vnfType) {
-
- if (StringUtils.isNotBlank(vnfType) && StringUtils.isNotBlank(protocol) && StringUtils
- .isNotBlank(action)) {
- return vnfType + "." + protocol + "." + action;
- }
- return "";
- }
private String resolveWhereClause(SvcLogicContext context, String db, String whereClause) {
if (db != null) {
@@ -313,6 +294,12 @@ public class DBService {
+ SdcArtifactHandlerConstants.ACTION;
} else if (db.equals(SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE)) {
return " where PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
+ } else if (db.equals(SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION)) {
+ log.info(" DB validation for Device authentication " + whereClause + " AND PROTOCOL = $"
+ + SdcArtifactHandlerConstants.DEVICE_PROTOCOL + " AND ACTION = $"
+ + SdcArtifactHandlerConstants.ACTION);
+ return whereClause + " AND PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL
+ + " AND ACTION = $" + SdcArtifactHandlerConstants.ACTION;
} else if (db.equals(SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG)) {
return whereClause + AND_ACTION_QUERY_STR + SdcArtifactHandlerConstants.ACTION;
} else if (db.equals(SdcArtifactHandlerConstants.DB_VNFC_REFERENCE)) {
@@ -362,77 +349,64 @@ public class DBService {
try {
String fn = "DBService.processDeviceAuthentication";
log.info(fn + "Starting DB operation for Device Authentication " + isUpdate);
- String protocol = context.getAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL);
- String action = context.getAttribute(SdcArtifactHandlerConstants.ACTION);
- String vnfType = context.getAttribute(SdcArtifactHandlerConstants.VNF_TYPE);
- String url = context.getAttribute(SdcArtifactHandlerConstants.URL);
String port = context.getAttribute(SdcArtifactHandlerConstants.PORT_NUMBER);
String user = context.getAttribute(SdcArtifactHandlerConstants.USER_NAME);
- String property = vnfType + "." + protocol + "." + action;
- log.info("property :" + property);
- if (StringUtils.isBlank(url)) {
- url = "";
- }
+ String protocol = context.getAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL);
+ String action = context.getAttribute(SdcArtifactHandlerConstants.ACTION);
+ String vnftype = context.getAttribute(SdcArtifactHandlerConstants.VNF_TYPE);
+
if (StringUtils.isBlank(port)) {
- port = "";
+ port = "0";
}
if (StringUtils.isBlank(user)) {
user = "";
}
- if (isInvalidInput(protocol, action, vnfType)) {
+ if (isInvalidInput(SdcArtifactHandlerConstants.DEVICE_PROTOCOL, SdcArtifactHandlerConstants.ACTION,
+ SdcArtifactHandlerConstants.VNF_TYPE)) {
throw new SvcLogicException(
"Error While processing reference File as few or all of parameters VNF_TYPE,PROTOCOL,ACTION are missing ");
}
- PropertiesConfiguration conf =
- new PropertiesConfiguration(System.getenv("APPC_CONFIG_DIR") + "/appc_southbound.properties");
- log.info("is Updating to southbound properties : " + isUpdate);
-
- resolveUserAction(isUpdate, user, property, conf);
- resolvePortAction(port, property, conf);
- resolveUrlAction(url, property, conf);
- tryAddPasswordProperty(property, conf);
-
- log.info("About to save to properties file");
- conf.save();
- log.info("saved to properties file");
- } catch (SvcLogicException | ConfigurationException e) {
- throw new DBException("An error occurred when processing device authentication", e);
- }
- }
- private void tryAddPasswordProperty(String property, PropertiesConfiguration conf) {
- if (!conf.containsKey(property + "." + "password")) {
- conf.addProperty(property + "." + "password", "");
- }
- }
-
- private void resolveUrlAction(String url, String property, PropertiesConfiguration conf) {
- if (conf.containsKey(property + "." + "url") ) {
- if (url != null && !url.isEmpty()) {
- conf.setProperty(property + "." + "url", url);
+ log.info("Starting DB operation for Device authentication " + isUpdate);
+ log.info("credentials"+user + "user" + "port" + port +"protocol"+protocol+"action"+action+"vnftype"+vnftype);
+ String key;
+ QueryStatus status;
+ if (isUpdate) {
+ key = UPDATE_QUERY_STR + SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION + " set USER_NAME = $"
+ + SdcArtifactHandlerConstants.USER_NAME + " , PORT_NUMBER = $" + SdcArtifactHandlerConstants.PORT_NUMBER + "";
+ if (context.getAttributeKeySet().contains(SdcArtifactHandlerConstants.URL)) {
+ String url = context.getAttribute(SdcArtifactHandlerConstants.URL);
+ if (StringUtils.isBlank(url)) {
+ url = "" ;
+ }
+ key = key + ", URL = $" + SdcArtifactHandlerConstants.USER_NAME + "";
+ }
+ key = key + WHERE_VNF_TYPE_QUERY_STR + SdcArtifactHandlerConstants.VNF_TYPE + " AND PROTOCOL = $"
+ + SdcArtifactHandlerConstants.DEVICE_PROTOCOL + " AND ACTION = $"
+ + SdcArtifactHandlerConstants.ACTION;
+ } else {
+ key = "insert into DEVICE_AUTHENTICATION set VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE + " , PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL + " , " + "ACTION = $" + SdcArtifactHandlerConstants.ACTION + " , USER_NAME = $" + SdcArtifactHandlerConstants.USER_NAME + " , PORT_NUMBER = $" + SdcArtifactHandlerConstants.PORT_NUMBER + "";
+ if (context.getAttributeKeySet().contains(SdcArtifactHandlerConstants.URL)) {
+ String url = context.getAttribute(SdcArtifactHandlerConstants.URL);
+ if (StringUtils.isBlank(url)) {
+ url = "";
+ }
+ key = key + ", URL = $" + SdcArtifactHandlerConstants.USER_NAME + "";
+ }
}
- } else {
- conf.addProperty(property + "." + "url", url);
- }
- }
- private void resolvePortAction(String port, String property, PropertiesConfiguration conf) {
- if (conf.containsKey(property + "." + "port")) {
- if (port != null && !port.isEmpty()) {
- conf.setProperty(property + "." + "port", port);
- }
- } else {
- conf.addProperty(property + "." + "port", port);
- }
- }
+ log.info("Query forDevice authentication " + key);
+ if (serviceLogic != null && context != null) {
- private void resolveUserAction(boolean isUpdate, String user, String property, PropertiesConfiguration conf) {
- if (conf.containsKey(property + "." + "user")) {
- if (user != null && !user.isEmpty()) {
- conf.setProperty(property + "." + "user", user);
+ status = serviceLogic.save("SQL", false, false, key, null, null, context);
+ if (status.toString().equals(FAILURE_PARAM)) {
+ throw new SvcLogicException("Error While processing DEVICE_AUTHENTICATION table ");
+ }
}
- } else {
- conf.addProperty(property + "." + "user", user);
+
+ } catch (SvcLogicException e) {
+
+ throw new DBException("An error occurred when processing device authentication", e);
}
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java
index 12cd7f7a5..4118d6822 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java
@@ -75,8 +75,10 @@ import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.V
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE_LIST;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.VNFC_INSTANCE;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.VNFC_TYPE;
+import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.VNFC_TYPE_LIST;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.VNF_TYPE;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.URL;
+import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.OPENSTACK;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -310,7 +312,8 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
setAttribute(context, documentInfo::getString, ARTIFACT_TYPE);
processActionLists(content, actionLevel, vnfcActionList, vfModuleActionList, vnfActionList,
vmActionVnfcFunctionCodesList);
- storeCapabilityArtifact = isCapabilityArtifactNeeded(scope, context);
+ JSONArray vnfcTypeList = setVnfcTypeInformation(scope, context);
+ storeCapabilityArtifact = isCapabilityArtifactNeeded(context);
if (content.has(DEVICE_PROTOCOL)) {
setAttribute(context, content::getString, DEVICE_PROTOCOL);
}
@@ -323,12 +326,15 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
if (content.has(URL)) {
setAttribute(context, content::getString, URL);
}
- processArtifactList(content, dbservice, context);
+ processArtifactList(content, dbservice, context, vnfcTypeList);
processConfigTypeActions(content, dbservice, context);
dbservice.processDeviceAuthentication(context,
dbservice.isArtifactUpdateRequired(context, DB_DEVICE_AUTHENTICATION));
- populateProtocolReference(dbservice, content);
+ String actionProtocol = tryGetProtocol(content);
+ if (!StringUtils.equalsIgnoreCase(actionProtocol, OPENSTACK)) {
+ populateProtocolReference(dbservice, content);
+ }
context.setAttribute(VNFC_TYPE, null);
@@ -356,22 +362,37 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
return true;
}
- public boolean isCapabilityArtifactNeeded(JSONObject scope, SvcLogicContext context) {
- boolean storeCapabilityArtifact = true;
+ public boolean isCapabilityArtifactNeeded(SvcLogicContext context) {
+ String vnfcType = context.getAttribute(VNFC_TYPE);
+ if (StringUtils.isNotBlank(vnfcType)) {
+ log.info("No capability Artifact for this reference data as it is at VNFC level!!" );
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ public JSONArray setVnfcTypeInformation(JSONObject scope, SvcLogicContext context) {
+ JSONArray vnfcTypeList = null;
if (scope.has(VNFC_TYPE)
&& !scope.isNull(VNFC_TYPE)) {
String vnfcTypeScope = scope.getString(VNFC_TYPE);
if (StringUtils.isNotBlank(vnfcTypeScope)) {
setAttribute(context, scope::getString, VNFC_TYPE);
- storeCapabilityArtifact = false;
- log.info("No capability Artifact for this reference data as it is at VNFC level!!");
+ log.info("VNFC Type has been set for this reference artifact!!"+vnfcTypeScope);
} else {
context.setAttribute(VNFC_TYPE, null);
}
} else {
context.setAttribute(VNFC_TYPE, null);
}
- return storeCapabilityArtifact;
+ if (scope.has(VNFC_TYPE_LIST) && !scope.isNull(VNFC_TYPE_LIST)
+ && scope.get(VNFC_TYPE_LIST) instanceof JSONArray) {
+ vnfcTypeList = scope.getJSONArray(VNFC_TYPE_LIST);
+ log.info("VNFC TYPE LIST found for this artifact!! "+ vnfcTypeList.toString());
+ }
+ return vnfcTypeList;
}
public void processActionLists(JSONObject content, String actionLevel, JSONArray vnfcActionList,
@@ -406,7 +427,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
return null != actionLevel && actionLevel.equalsIgnoreCase(actionLevelVnfc);
}
- public void processArtifactList(JSONObject content, DBService dbservice, SvcLogicContext context)
+ public void processArtifactList(JSONObject content, DBService dbservice, SvcLogicContext context, JSONArray vnfcTypeList)
throws ArtifactHandlerInternalException {
@@ -418,7 +439,8 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
&& content.get("template-id-list") instanceof JSONArray) {
templateIdList = content.getJSONArray("template-id-list");
}
- doProcessArtifactList(dbservice, context, artifactLists, templateIdList);
+ doProcessArtifactList(dbservice, context, artifactLists, templateIdList, vnfcTypeList);
+
}
} catch (Exception e) {
log.error("An error occurred when processing artifact list", e);
@@ -427,11 +449,10 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
}
private void doProcessArtifactList(DBService dbservice, SvcLogicContext context, JSONArray artifactLists,
- JSONArray templateIdList)
+ JSONArray templateIdList, JSONArray vnfcTypeList)
throws SvcLogicException, SQLException, ConfigurationException, DBException {
boolean pdFile = false;
- int modelInd = 0;
-
+ int modelInd = 0, vnfcRefInd = 0;
for (int i = 0; i < artifactLists.length(); i++) {
String suffix = null;
String model = null;
@@ -439,10 +460,13 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
log.info("artifact is " + artifact);
//Get Model details
- if (null != templateIdList && i>0 && i%2==0) {
+ if (null != templateIdList && i>0 && i%2==0) {//Should this be changed to 3 to account for 3 artifacts
modelInd++;
}
-
+ if (null != vnfcTypeList && i>0 && i%3==0) {
+ //TDP 517180 - CD tool has made changes to send 3 artifacts instead of 2
+ vnfcRefInd++;
+ }
setAttribute(context, artifact::getString, ARTIFACT_NAME);
context.setAttribute(FILE_CATEGORY,
artifact.getString(ARTIFACT_TYPE));
@@ -460,7 +484,13 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
model = templateIdList.getString(modelInd);
log.info("Model is ::: "+model+" ,modelInd = "+modelInd);
}
-
+ if (null != vnfcTypeList && vnfcRefInd < vnfcTypeList.length() ) {
+ String vnfcType = vnfcTypeList.getString(vnfcRefInd);
+ if (StringUtils.isNotBlank(vnfcType)) {
+ context.setAttribute(VNFC_TYPE, vnfcType);
+ }
+ log.info("Setting vnfc type from vnfc-type-list ::"+vnfcType);
+ }
if (StringUtils.isNotBlank(model)) {
dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context,
DB_SDC_REFERENCE, model),model);
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java
index 3d86db416..13941b369 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java
@@ -70,7 +70,7 @@ public class SdcArtifactHandlerConstants {
public static final String USER_NAME = "user-name";
public static final String PORT_NUMBER = "port-number";
public static final String DOWNLOAD_DG_REFERENCE = "download-dg-reference";
-
+ public static final String VNFC_TYPE_LIST = "vnfc-type-list";
public static final String DB_DOWNLOAD_DG_REFERENCE = "DOWNLOAD_DG_REFERENCE";
public static final String DB_SDC_REFERENCE = "ASDC_REFERENCE";
@@ -92,5 +92,6 @@ public class SdcArtifactHandlerConstants {
public static final String ARTIFACT_NAME_CAPABILITY = "capability";
public static final String APPC_CONFIG_DIR="/opt/appcauth";
public static final String URL="url";
+ public static final String OPENSTACK = "OS";
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java
index dc57d246e..5b8300935 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java
@@ -39,7 +39,9 @@ import java.util.Map;
import java.util.HashMap;
import java.nio.charset.Charset;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class ArtifactHandlerNodeTest {
@@ -225,7 +227,7 @@ public class ArtifactHandlerNodeTest {
JSONObject content=new JSONObject(contentStr);
MockDBService dbService = MockDBService.initialise();
SvcLogicContext context = new SvcLogicContext();
- artifactHandlerNode.processArtifactList(content,dbService,context);
+ artifactHandlerNode.processArtifactList(content,dbService,context, null);
}
@Test
@@ -252,12 +254,14 @@ public class ArtifactHandlerNodeTest {
JSONObject scope1 = new JSONObject(scopeObjStr1);
JSONObject scope2 = new JSONObject(scopeObjStr2);
SvcLogicContext context = new SvcLogicContext();
- assertFalse(artifactHandlerNode.isCapabilityArtifactNeeded(scope1, context));
- assertTrue(artifactHandlerNode.isCapabilityArtifactNeeded(scope2, context));
+ artifactHandlerNode.setVnfcTypeInformation(scope1, context);
+ assertFalse(artifactHandlerNode.isCapabilityArtifactNeeded(context));
+ artifactHandlerNode.setVnfcTypeInformation(scope2, context);
+ assertTrue(artifactHandlerNode.isCapabilityArtifactNeeded(context));
}
@Test
- public void testProcessArtifactListsWithMultipleTemplatesThrowsExceptionOnFailure() throws Exception {
+ public void testProcessArtifactListsWithMultipleTemplates() throws Exception {
String contentStr = "{\r\n\t\t\"action\": \"ConfigScaleOut\",\r\n\t\t\"action-level\": \"vnf\",\r\n\t\t\"scope\": {\r\n\t\t\t\"vnf-type\": "
+ "\"vCfgSO-0405\",\r\n\t\t\t\"vnfc-type\": \"\"\r\n\t\t},\r\n\t\t\"template\": \"Y\",\r\n\t\t\"vm\": [{\r\n\t\t\t\"template-id\": "
+ "\"TID-0405-EZ\",\r\n\t\t\t\"vm-instance\": 1,\r\n\t\t\t\"vnfc\": [{\r\n\t\t\t\t\"vnfc-instance\": \"1\",\r\n\t\t\t\t\"vnfc-function-code\": "
@@ -277,7 +281,41 @@ public class ArtifactHandlerNodeTest {
SvcLogicContext context = new SvcLogicContext();
context.setAttribute("vnf-type", "someVnf");
context.setAttribute("action", "ConfigScaleOut");
- artifactHandlerNode.processArtifactList(content, dbService, context);;
+ artifactHandlerNode.processArtifactList(content, dbService, context, null);
+ }
+
+ @Test
+ public void testProcessArtifactListsWithVnfcTypeList() throws Exception {
+ String contentStr = "{\r\n\t\"action\": \"Configure\",\r\n\t\"action-level\": \"vnf\",\r\n\t\"scope\": {\r\n\t\t\"vnf-type\": "
+ + "\"newtypeofvnf\",\r\n\t\t\"vnfc-type-list\": [\"vnfctype1\",\"vnfctype2\"]\r\n\t},\r\n\t\"template\": \"Y\",\r\n\t\"vm\":"
+ + " [{\r\n\t\t\t\"vm-instance\": 1,\r\n\t\t\t\"template-id\": \"vnfctype1\",\r\n\t\t\t\"vnfc\": [{\r\n\t\t\t\t\"vnfc-instance\": "
+ + "\"1\",\r\n\t\t\t\t\"vnfc-function-code\": \"fcx\",\r\n\t\t\t\t\"ipaddress-v4-oam-vip\": \"Y\",\r\n\t\t\t\t\"group-notation-type\": "
+ + "\"first-vnfc-name\",\r\n\t\t\t\t\"group-notation-value\": \"pair\",\r\n\t\t\t\t\"vnfc-type\": \"vDBE\"\r\n\t\t\t}]\r\n\t\t},"
+ + "\r\n\t\t{\r\n\t\t\t\"vm-instance\": 1,\r\n\t\t\t\"template-id\": \"vnfctype2\",\r\n\t\t\t\"vnfc\": [{\r\n\t\t\t\t\"vnfc-instance\": "
+ + "\"1\",\r\n\t\t\t\t\"vnfc-function-code\": \"fcx\",\r\n\t\t\t\t\"ipaddress-v4-oam-vip\": \"Y\",\r\n\t\t\t\t\"group-notation-type\": "
+ + "\"first-vnfc-name\",\r\n\t\t\t\t\"group-notation-value\": \"pair\",\r\n\t\t\t\t\"vnfc-type\": \"vDBE\"\r\n\t\t\t}]\r\n\t\t},"
+ + "\r\n\t\t{\r\n\t\t\t\"vm-instance\": 2,\r\n\t\t\t\"template-id\": \"vnfctype2\",\r\n\t\t\t\"vnfc\": [{\r\n\t\t\t\t\"vnfc-instance\": "
+ + "\"1\",\r\n\t\t\t\t\"vnfc-function-code\": \"fcx\",\r\n\t\t\t\t\"ipaddress-v4-oam-vip\": \"Y\",\r\n\t\t\t\t\"group-notation-type\": "
+ + "\"first-vnfc-name\",\r\n\t\t\t\t\"group-notation-value\": \"pair\",\r\n\t\t\t\t\"vnfc-type\": \"vDBE\"\r\n\t\t\t}]\r\n\t\t}\r\n\t],"
+ + "\r\n\t\"device-protocol\": \"NETCONF-XML\",\r\n\t\"user-name\": \"netconf\",\r\n\t\"port-number\": \"20\",\r\n\t\"artifact-list\": "
+ + "[{\r\n\t\t\t\"artifact-name\": \"template_ConfigScaleOut_newtypeofvnf_0.0.1V_vnfctype1.xml\",\r\n\t\t\t\"artifact-type\": "
+ + "\"config_template\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"artifact-name\": \"pd_ConfigScaleOut_newtypeofvnf_0.0.1V_vnfctype1.yaml\","
+ + "\r\n\t\t\t\"artifact-type\": \"parameter_definitions\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"artifact-name\": "
+ + "\"template_ConfigScaleOut_newtypeofvnf_0.0.1V_vnfctype2.xml\",\r\n\t\t\t\"artifact-type\": "
+ + "\"config_template\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"artifact-name\": \"pd_ConfigScaleOut_newtypeofvnf_0.0.1V_vnfctype2.yaml\","
+ + "\r\n\t\t\t\"artifact-type\": \"parameter_definitions\"\r\n\t\t}\r\n\t],\r\n\t\"scopeType\": \"vnf-type\"\r\n}";
+ JSONObject content = new JSONObject(contentStr);
+ MockDBService dbService = MockDBService.initialise();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("vnf-type", "someVnf");
+ context.setAttribute("action", "Configure");
+ JSONObject scope = (JSONObject)content.get("scope");
+ JSONArray vnfcTypeList = artifactHandlerNode.setVnfcTypeInformation(scope, context);
+ artifactHandlerNode.processArtifactList(content, dbService, context, vnfcTypeList);
+ JSONArray vnfcLists = scope.getJSONArray("vnfc-type-list");
+ assertEquals(vnfcLists.toString(), "[\"vnfctype1\",\"vnfctype2\"]");
+ assertEquals(context.getAttribute("vnfc-type"),"vnfctype2");
+ assertNotNull (vnfcTypeList);
}