2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.artifact.handler.node;
26 import org.apache.commons.io.IOUtils;
27 import org.json.JSONArray;
28 import org.json.JSONObject;
29 import org.junit.Before;
30 import org.junit.Ignore;
31 import org.junit.Test;
32 import org.mockito.Mockito;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
34 import org.powermock.reflect.Whitebox;
35 import org.onap.appc.artifact.handler.dbservices.MockDBService;
36 import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
37 import org.onap.appc.artifact.handler.utils.ArtifactHandlerProviderUtilTest;
39 import java.util.HashMap;
40 import java.nio.charset.Charset;
42 import static org.junit.Assert.assertEquals;
43 import static org.junit.Assert.assertFalse;
44 import static org.junit.Assert.assertNotNull;
45 import static org.junit.Assert.assertTrue;
47 public class ArtifactHandlerNodeTest {
49 private ArtifactHandlerNode artifactHandlerNode;
52 public void setUp() throws Exception {
53 artifactHandlerNode = Mockito.spy(ArtifactHandlerNode.class);
54 Mockito.doReturn(true)
55 .when(artifactHandlerNode)
56 .updateStoreArtifacts(Mockito.any(JSONObject.class), Mockito.any(JSONObject.class));
57 Mockito.doReturn(true)
58 .when(artifactHandlerNode)
59 .storeReferenceData(Mockito.any(JSONObject.class), Mockito.any(JSONObject.class));
63 public void testProcessArtifact() throws Exception {
64 SvcLogicContext ctx = new SvcLogicContext();
65 ctx.setAttribute("test", "test");
66 Map<String, String> inParams = new HashMap<>();
67 JSONObject postData = new JSONObject();
68 JSONObject input = new JSONObject();
69 inParams.put("response_prefix", "prefix");
70 JSONObject requestInfo = new JSONObject();
71 JSONObject documentInfo = new JSONObject();
72 String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
73 .getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
74 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, artifactContent);
75 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
76 requestInfo.put("RequestInfo", "testValue");
77 input.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, documentInfo);
78 input.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo);
79 postData.put("input", input);
80 inParams.put("postData", postData.toString());
81 artifactHandlerNode.processArtifact(inParams, ctx);
84 @Ignore("Test is taking 60 seconds")
85 @Test(expected = Exception.class)
86 public void testStoreReferenceData() throws Exception {
87 JSONObject documentInfo = new JSONObject();
88 String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
89 .getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
90 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, artifactContent);
91 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
92 JSONObject requestInfo = new JSONObject();
93 requestInfo.put("RequestInfo", "testStoreReferenceData");
94 artifactHandlerNode.storeReferenceData(requestInfo, documentInfo);
98 public void testPopulateProtocolReference() throws Exception {
99 ArtifactHandlerNode ah = new ArtifactHandlerNode();
101 "{\"action\": \"TestAction\",\"action-level\": \"vnf\",\"scope\": {\"vnf-type\": \"vDBE-I\",\"vnfc-type\": null},\"template\": \"N\",\"device-protocol\": \"REST\"}";
102 JSONObject content = new JSONObject(contentStr);
103 MockDBService dbService = MockDBService.initialise();
104 Whitebox.invokeMethod(ah, "populateProtocolReference", dbService, content);
108 public void testProcessAndStoreCapablitiesArtifact() throws Exception {
109 ArtifactHandlerNode ah = new ArtifactHandlerNode();
110 JSONObject capabilities = new JSONObject();
111 JSONObject documentInfo = new JSONObject();
112 MockDBService dbService = MockDBService.initialise();
113 documentInfo.put(SdcArtifactHandlerConstants.SERVICE_UUID, "testuid");
114 documentInfo.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, "testDist");
115 documentInfo.put(SdcArtifactHandlerConstants.SERVICE_NAME, "testName");
116 documentInfo.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, "testDesc");
117 documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_UUID, "testRes");
118 documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, "testResIns");
119 documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_VERSION, "testVers");
120 documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_TYPE, "testResType");
121 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, "testArtifactUuid");
122 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, "testArtifactVers");
123 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, "testArtifactDesc");
124 Whitebox.invokeMethod(ah, "processAndStoreCapabilitiesArtifact", dbService, documentInfo, capabilities,
125 "artifactName", "someVnf");
129 public void testCleanVnfcInstance() throws Exception {
130 ArtifactHandlerNode ah = new ArtifactHandlerNode();
131 SvcLogicContext ctx = new SvcLogicContext();
132 Whitebox.invokeMethod(ah, "cleanVnfcInstance", ctx);
136 @Ignore("Test is taking 60 seconds")
137 @Test(expected = Exception.class)
138 public void testGetArtifactIDException() throws Exception {
139 ArtifactHandlerNode ah = new ArtifactHandlerNode();
140 String yFileName = "yFileName";
141 Whitebox.invokeMethod(ah, "getArtifactID", yFileName);
144 @Ignore("Test is taking 60 seconds")
145 @Test(expected = Exception.class)
146 public void testStoreUpdateSdcArtifacts() throws Exception {
147 ArtifactHandlerNode ah = new ArtifactHandlerNode();
149 "{\"request-information\":{},\"document-parameters\":{\"artifact-name\":\"testArtifact\",\"artifact-contents\":{\"content\":\"TestContent\"}}}";
150 JSONObject postData = new JSONObject(postDataStr);
151 Whitebox.invokeMethod(ah, "storeUpdateSdcArtifacts", postData);
154 @Ignore("Test is taking 60 seconds")
155 @Test(expected = Exception.class)
156 public void testUpdateStoreArtifacts() throws Exception {
157 JSONObject documentInfo = new JSONObject();
158 String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
159 .getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
160 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, artifactContent);
161 documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
162 JSONObject requestInfo = new JSONObject();
163 requestInfo.put("RequestInfo", "testupdateStoreArtifacts");
164 artifactHandlerNode.updateStoreArtifacts(requestInfo, documentInfo);
168 public void testCleanArtifactInstanceData() throws Exception {
169 SvcLogicContext ctx = new SvcLogicContext();
170 Whitebox.invokeMethod(artifactHandlerNode, "cleanArtifactInstanceData", ctx);
173 @Ignore("Test is taking 60 seconds")
174 @Test(expected = Exception.class)
175 public void testUpdateYangContents() throws Exception {
176 String artifactId = "1";
177 String yangContents = "SomeContent";
178 Whitebox.invokeMethod(artifactHandlerNode, "updateYangContents", artifactId, yangContents);
182 public void testProcessVmList() throws Exception{
183 String contentStr = "{\r\n\t\"action\": \"ConfigScaleOut\",\r\n\t\"action-level\": \"VNF\",\r\n\t\"scope\": "
184 + "{\r\n\t\t\"vnf-type\": \"ScaleOutVNF\",\r\n\t\t\"vnfc-type\": \"\"\r\n\t},\r\n\t\"template\": \"Y\",\r\n\t\"vm\": "
185 + "[\r\n\t{ \r\n\t\t\"vm-instance\": 1,\r\n\t\t\"template-id\":\"id1\",\r\n\t\t\r\n\t\t\"vnfc\": [{\r\n\t\t\t\"vnfc-instance\": 1,\r\n\t\t\t\"vnfc-type\": \"t1\",\r\n\t\t\t\"vnfc-function-code\": "
186 + "\"Testdbg\",\r\n\t\t\t\"group-notation-type\": \"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"N\",\r\n\t\t\t\"group-notation-value\": "
187 + "\"GNValue\"\r\n\t\t}]\r\n\t},\r\n\t{ \r\n\t\t\"vm-instance\": 1,\r\n\t\t\"template-id\":\"id2\",\r\n\t\t\r\n\t\t\"vnfc\": [{\r\n\t\t\t\"vnfc-instance\": 1,\r\n\t\t\t\"vnfc-type\": "
188 + "\"t1\",\r\n\t\t\t\"vnfc-function-code\": \"Testdbg\",\r\n\t\t\t\"group-notation-type\": \"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"N\",\r\n\t\t\t\"group-notation-value\": "
189 + "\"GNValue\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"vnfc-instance\": 2,\r\n\t\t\t\"vnfc-type\": \"t2\",\r\n\t\t\t\"vnfc-function-code\": \"Testdbg\",\r\n\t\t\t\"group-notation-type\": "
190 + "\"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"Y\",\r\n\t\t\t\"group-notation-value\": \"GNValue\"\r\n\t\t}]\r\n\t},\r\n\t{\r\n\t\t\"vm-instance\": 2,\r\n\t\t\"template-id\":\"id3\",\r\n\t\t\"vnfc\": "
191 + "[{\r\n\t\t\t\"vnfc-instance\": 1,\r\n\t\t\t\"vnfc-type\": \"t3\",\r\n\t\t\t\"vnfc-function-code\": \"Testdbg\",\r\n\t\t\t\"group-notation-type\": "
192 + "\"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"Y\",\r\n\t\t\t\"group-notation-value\": \"GNValue\"\r\n\t\t}]\r\n\t}],\r\n\t\"device-protocol\": "
193 + "\"TEST-PROTOCOL\",\r\n\t\"user-name\": \"Testnetconf\",\r\n\t\"port-number\": \"22\",\r\n\t\"artifact-list\": [{\r\n\t\t\"artifact-name\": \"Testv_template.json\",\r\n\t\t\"artifact-type\": "
194 + "\"Testconfig_template\"\r\n\t},\r\n\t{\r\n\t\t\"artifact-name\": \"TESTv_parameter_definitions.json\",\r\n\t\t\"artifact-type\": \"Testparameter_definitions\"\r\n\t},\r\n\t{\r\n\t\t\"artifact-name\": "
195 + "\"PD_JunitTESTv_parameter_yang.json\",\r\n\t\t\"artifact-type\": \"PD_definations\"\r\n\t}]\r\n}";
196 JSONObject content=new JSONObject(contentStr);
197 MockDBService dbService = MockDBService.initialise();
198 SvcLogicContext context = new SvcLogicContext();
199 artifactHandlerNode.processVmList(content, context, dbService);
203 public void testProcessConfigTypeActions() throws Exception{
204 String contentStr = "{\"action\": \"ConfigScaleOut\"}";
205 JSONObject content=new JSONObject(contentStr);
206 MockDBService dbService = MockDBService.initialise();
207 SvcLogicContext context = new SvcLogicContext();
208 context.setAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL,"Test");
209 artifactHandlerNode.processConfigTypeActions(content, dbService, context);
213 public void testProcessArtifactLists() throws Exception{
214 String contentStr = "{\r\n\t\"action\": \"ConfigScaleOut\",\r\n\t\"action-level\": \"VNF\",\r\n\t\"scope\": "
215 + "{\r\n\t\t\"vnf-type\": \"ScaleOutVNF\",\r\n\t\t\"vnfc-type\": \"\"\r\n\t},\r\n\t\"template\": \"Y\",\r\n\t\"vm\": "
216 + "[\r\n\t{ \r\n\t\t\"vm-instance\": 1,\r\n\t\t\"template-id\":\"id1\",\r\n\t\t\r\n\t\t\"vnfc\": [{\r\n\t\t\t\"vnfc-instance\": 1,\r\n\t\t\t\"vnfc-type\": \"t1\",\r\n\t\t\t\"vnfc-function-code\": "
217 + "\"Testdbg\",\r\n\t\t\t\"group-notation-type\": \"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"N\",\r\n\t\t\t\"group-notation-value\": "
218 + "\"GNValue\"\r\n\t\t}]\r\n\t},\r\n\t{ \r\n\t\t\"vm-instance\": 1,\r\n\t\t\"template-id\":\"id2\",\r\n\t\t\r\n\t\t\"vnfc\": [{\r\n\t\t\t\"vnfc-instance\": 1,\r\n\t\t\t\"vnfc-type\": "
219 + "\"t1\",\r\n\t\t\t\"vnfc-function-code\": \"Testdbg\",\r\n\t\t\t\"group-notation-type\": \"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"N\",\r\n\t\t\t\"group-notation-value\": "
220 + "\"GNValue\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"vnfc-instance\": 2,\r\n\t\t\t\"vnfc-type\": \"t2\",\r\n\t\t\t\"vnfc-function-code\": \"Testdbg\",\r\n\t\t\t\"group-notation-type\": "
221 + "\"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"Y\",\r\n\t\t\t\"group-notation-value\": \"GNValue\"\r\n\t\t}]\r\n\t},\r\n\t{\r\n\t\t\"vm-instance\": 2,\r\n\t\t\"template-id\":\"id3\",\r\n\t\t\"vnfc\": "
222 + "[{\r\n\t\t\t\"vnfc-instance\": 1,\r\n\t\t\t\"vnfc-type\": \"t3\",\r\n\t\t\t\"vnfc-function-code\": \"Testdbg\",\r\n\t\t\t\"group-notation-type\": "
223 + "\"GNType\",\r\n\t\t\t\"ipaddress-v4-oam-vip\": \"Y\",\r\n\t\t\t\"group-notation-value\": \"GNValue\"\r\n\t\t}]\r\n\t}],\r\n\t\"device-protocol\": "
224 + "\"TEST-PROTOCOL\",\r\n\t\"user-name\": \"Testnetconf\",\r\n\t\"port-number\": \"22\",\r\n\t\"artifact-list\": [{\r\n\t\t\"artifact-name\": \"Testv_template.json\",\r\n\t\t\"artifact-type\": "
225 + "\"Testconfig_template\"\r\n\t},\r\n\t{\r\n\t\t\"artifact-name\": \"TESTv_parameter_definitions.json\",\r\n\t\t\"artifact-type\": \"Testparameter_definitions\"\r\n\t},\r\n\t{\r\n\t\t\"artifact-name\": "
226 + "\"PD_JunitTESTv_parameter_yang.json\",\r\n\t\t\"artifact-type\": \"PD_definations\"\r\n\t}]\r\n}";
227 JSONObject content=new JSONObject(contentStr);
228 MockDBService dbService = MockDBService.initialise();
229 SvcLogicContext context = new SvcLogicContext();
230 artifactHandlerNode.processArtifactList(content,dbService,context, null);
234 public void testProcessActionLists() throws Exception {
235 String contentStr = "{\r\n\t\"action\": \"HealthCheck\",\r\n\t\"action-level\": \"vm\",\r\n\t\"scope\":"
236 + " {\r\n\t\t\"vnf-type\": \"vDBE-I\",\r\n\t\t\"vnfc-type\": null\r\n\t},\r\n\t\"template\": "
237 + "\"N\",\r\n\t\"device-protocol\": \"REST\",\r\n\t\"vnfc-function-code-list\": [\"SSC\", \"MMSC\"]\r\n}";
238 JSONObject content = new JSONObject(contentStr);
239 JSONArray vmActionVnfcFunctionCodesList = new JSONArray();
240 JSONArray vnfActionList = new JSONArray();
241 JSONArray vfModuleActionList = new JSONArray();
242 JSONArray vnfcActionList = new JSONArray();
243 String[] actionLevels = { "vnf", "vm", "vf-module", "vnfc" };
244 for (String actionLevel : actionLevels) {
245 artifactHandlerNode.processActionLists(content, actionLevel, vnfcActionList, vfModuleActionList,
246 vnfActionList, vmActionVnfcFunctionCodesList);
251 public void testIsCapabilityArtifactNeeded() throws Exception {
252 String scopeObjStr1= "{\"vnf-type\":\"someVnf\",\"vnfc-type\":\"somVnfc\"}";
253 String scopeObjStr2= "{\"vnf-type\":\"someVnf\",\"vnfc-type\":\"\"}";
254 JSONObject scope1 = new JSONObject(scopeObjStr1);
255 JSONObject scope2 = new JSONObject(scopeObjStr2);
256 SvcLogicContext context = new SvcLogicContext();
257 artifactHandlerNode.setVnfcTypeInformation(scope1, context);
258 assertFalse(artifactHandlerNode.isCapabilityArtifactNeeded(context));
259 artifactHandlerNode.setVnfcTypeInformation(scope2, context);
260 assertTrue(artifactHandlerNode.isCapabilityArtifactNeeded(context));
264 public void testProcessArtifactListsWithMultipleTemplates() throws Exception {
265 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\": "
266 + "\"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\": "
267 + "\"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\": "
268 + "\"Cfg-ez\",\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\":"
269 + " \"pair\",\r\n\t\t\t\t\"vnfc-type\": \"vCfg-0405-ez\"\r\n\t\t\t}]\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"template-id\": "
270 + "\"TID-0405-EZ\",\r\n\t\t\t\"vm-instance\": 2,\r\n\t\t\t\"vnfc\": [{\r\n\t\t\t\t\"vnfc-instance\": \"1\",\r\n\t\t\t\t\"vnfc-function-code\": "
271 + "\"Cfg-ez\",\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\":"
272 + " \"pair\",\r\n\t\t\t\t\"vnfc-type\": \"vCfg-0405-ez\"\r\n\t\t\t}]\r\n\t\t}],\r\n\t\t\"device-protocol\": \"ANSIBLE\",\r\n\t\t\"user-name\": \"root\","
273 + "\r\n\t\t\"port-number\": \"22\",\r\n\t\t\"artifact-list\": [{\r\n\t\t\t\"artifact-name\": \"template_ConfigScaleOut_vCfgSO-0405_0.0.1V_TID-0405-EZ.json\","
274 + "\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_vCfgSO-0405_0.0.1V_TID-0405-EZ.yaml\","
275 + "\r\n\t\t\t\"artifact-type\": \"parameter_definitions\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"artifact-name\": "
276 + "\"template_ConfigScaleOut_vCfgSO-0405_0.0.1V_TID-0405-EZ-2.json\",\r\n\t\t\t\"artifact-type\": \"config_template\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"artifact-name\": "
277 + "\"pd_ConfigScaleOut_vCfgSO-0405_0.0.1V_TID-0405-EZ-2.yaml\",\r\n\t\t\t\"artifact-type\": \"parameter_definitions\"\r\n\t\t}],\r\n\t\t\"template-id-list\":"
278 + " [\"TID-0405-EZ\",\r\n\t\t\"TID-0405-EZ-2\"],\r\n\t\t\"scopeType\": \"vnf-type\"\r\n\t}";
279 JSONObject content = new JSONObject(contentStr);
280 MockDBService dbService = MockDBService.initialise();
281 SvcLogicContext context = new SvcLogicContext();
282 context.setAttribute("vnf-type", "someVnf");
283 context.setAttribute("action", "ConfigScaleOut");
284 artifactHandlerNode.processArtifactList(content, dbService, context, null);
288 public void testProcessArtifactListsWithVnfcTypeList() throws Exception {
289 String contentStr = "{\r\n\t\"action\": \"Configure\",\r\n\t\"action-level\": \"vnf\",\r\n\t\"scope\": {\r\n\t\t\"vnf-type\": "
290 + "\"newtypeofvnf\",\r\n\t\t\"vnfc-type-list\": [\"vnfctype1\",\"vnfctype2\"]\r\n\t},\r\n\t\"template\": \"Y\",\r\n\t\"vm\":"
291 + " [{\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\": "
292 + "\"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\": "
293 + "\"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},"
294 + "\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\": "
295 + "\"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\": "
296 + "\"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},"
297 + "\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\": "
298 + "\"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\": "
299 + "\"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],"
300 + "\r\n\t\"device-protocol\": \"NETCONF-XML\",\r\n\t\"user-name\": \"netconf\",\r\n\t\"port-number\": \"20\",\r\n\t\"artifact-list\": "
301 + "[{\r\n\t\t\t\"artifact-name\": \"template_ConfigScaleOut_newtypeofvnf_0.0.1V_vnfctype1.xml\",\r\n\t\t\t\"artifact-type\": "
302 + "\"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\","
303 + "\r\n\t\t\t\"artifact-type\": \"parameter_definitions\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"artifact-name\": "
304 + "\"template_ConfigScaleOut_newtypeofvnf_0.0.1V_vnfctype2.xml\",\r\n\t\t\t\"artifact-type\": "
305 + "\"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\","
306 + "\r\n\t\t\t\"artifact-type\": \"parameter_definitions\"\r\n\t\t}\r\n\t],\r\n\t\"scopeType\": \"vnf-type\"\r\n}";
307 JSONObject content = new JSONObject(contentStr);
308 MockDBService dbService = MockDBService.initialise();
309 SvcLogicContext context = new SvcLogicContext();
310 context.setAttribute("vnf-type", "someVnf");
311 context.setAttribute("action", "Configure");
312 JSONObject scope = (JSONObject)content.get("scope");
313 JSONArray vnfcTypeList = artifactHandlerNode.setVnfcTypeInformation(scope, context);
314 artifactHandlerNode.processArtifactList(content, dbService, context, vnfcTypeList);
315 JSONArray vnfcLists = scope.getJSONArray("vnfc-type-list");
316 assertEquals(vnfcLists.toString(), "[\"vnfctype1\",\"vnfctype2\"]");
317 assertEquals(context.getAttribute("vnfc-type"),"vnfctype2");
318 assertNotNull (vnfcTypeList);