2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.artifacts;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
25 import static org.testng.AssertJUnit.assertNotNull;
26 import static org.testng.AssertJUnit.assertTrue;
29 import java.io.IOException;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.List;
34 import java.util.Map.Entry;
36 import org.apache.commons.lang3.tuple.Pair;
37 import org.junit.Rule;
38 import org.junit.rules.TestName;
39 import org.openecomp.sdc.be.dao.api.ActionStatus;
40 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
41 import org.openecomp.sdc.be.model.ArtifactDefinition;
42 import org.openecomp.sdc.be.model.Component;
43 import org.openecomp.sdc.be.model.ComponentInstance;
44 import org.openecomp.sdc.be.model.Resource;
45 import org.openecomp.sdc.be.model.Service;
46 import org.openecomp.sdc.be.model.User;
47 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
48 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
49 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
50 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
53 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
54 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
55 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
56 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
57 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
58 import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
59 import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
60 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
61 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
63 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
64 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
65 import org.openecomp.sdc.ci.tests.utils.validation.ArtifactValidationUtils;
66 import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
67 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
68 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory;
71 import org.testng.annotations.BeforeMethod;
72 import org.testng.annotations.DataProvider;
73 import org.testng.annotations.Test;
75 public class CrudArt extends ComponentBaseTest {
77 private static Logger logger = LoggerFactory.getLogger(CrudArt.class.getName());
78 private static final User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
80 private static final String HEAT_NET_LABEL = "heatnet";
81 private static final String HEAT_LABEL = "heat";
83 protected String testResourcesPath;
84 protected String testResourcesInstancesPath;
86 protected static final String dcaeInventoryToscaFile = "toscaSampleArtifact.yml";
87 protected static final String dcaeInventoryJsonFile = "jsonSampleArtifact.json";
88 protected static final String dcaeInventoryPolicyFile = "emfSampleArtifact.emf";
89 protected static final String dcaeInventoryDocFile = "docSampleArtifact.doc";
90 protected static final String dcaeInventoryBlueprintFile = "bluePrintSampleArtifact.xml";
91 protected static final String dcaeInventoryEventFile = "eventSampleArtifact.xml";
93 protected static final String heatSuccessFile = "asc_heat 0 2.yaml";
94 protected static final String heatNetSuccessFile = "asc_heat_net 0 2.yaml";
95 protected static final String yangFile = "addYangXmlArtifactToResource.xml";
96 protected static final String jsonFile = "jsonArtifact.json";
97 protected static final String invalidJsonFile = "invalidJson.json";
98 protected static final String invalidYangFile = "invalidYangXml.xml";
99 protected static final String otherFile = "other.txt";
100 protected static final String muranoFile = "asc_heat 0 2.zip";
101 protected static final String heatSuccessMiniFile = "heat_mini.yaml";
102 protected static final String heatInvalidFormat = "heatInvalidFormat.yaml";
103 protected static final String yamlInvalidFormat = "invalidYamlFormat.yaml";
104 protected static final String heatEnvfile = "heatEnvfile.env";
106 protected ServiceReqDetails serviceDetails;
107 protected ResourceReqDetails vfResourceDetails;
108 protected ResourceReqDetails cpResourceDetails;
109 protected ResourceReqDetails vfcResourceDetails;
110 protected ResourceReqDetails vlResourceDetails;
113 public static TestName name = new TestName();
116 super(name, CrudArt.class.getName());
120 private static final Object[][] getDepArtByType() throws IOException, Exception {
121 return new Object[][] { { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType()) },
122 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()) },
123 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()) },
124 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()) },
125 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()) } };
129 private static final Object[][] getServiceDepArtByType() throws IOException, Exception {
130 return new Object[][] { { ArtifactTypeEnum.OTHER.getType() }, { ArtifactTypeEnum.YANG_XML.getType() }, };
134 public void init() throws Exception {
135 // Set files working directory
136 String sourceDir = config.getResourceConfigDir();
137 String workDir = "HeatDeploymentArtifacts";
138 testResourcesPath = sourceDir + File.separator + workDir;
139 String workDirResourceInstanceArtifacts = "ResourceInstanceArtifacts";
140 testResourcesInstancesPath = sourceDir + File.separator + workDirResourceInstanceArtifacts;
142 // Build the components
143 Service serviceObj = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
144 serviceDetails = new ServiceReqDetails(serviceObj);
146 Resource vfcResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
147 vfcResourceDetails = new ResourceReqDetails(vfcResourceObj);
149 Resource vfResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
150 vfResourceDetails = new ResourceReqDetails(vfResourceObj);
152 Resource cpResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.CP, UserRoleEnum.DESIGNER, true).left().value();
153 cpResourceDetails = new ResourceReqDetails(cpResourceObj);
155 Resource vlResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VL, UserRoleEnum.DESIGNER, true).left().value();
156 vlResourceDetails = new ResourceReqDetails(vlResourceObj);
159 // ---------------------------------Resource
160 // success--------------------------------
162 public void addHeatArtifactToResourceAndCertify() throws Exception {
164 String fileName = heatSuccessFile;
165 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
166 logger.debug("listFileName: {}", listFileName.toString());
168 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
169 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
170 heatArtifactDetails.setPayload(payload);
172 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
173 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
174 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
176 // certified resource
177 RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
178 int status = changeResourceState.getErrorCode();
179 assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
181 Resource resourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(changeResourceState.getResponse());
182 Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
183 boolean flag = false;
184 if (artifactsMap != null) {
185 for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
186 if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
187 assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
192 assertTrue("expected artifact not found", flag == true);
197 // ---------------------------------Resource
198 // success--------------------------------
200 public void addDcaeInventoryToscaArtifactToResourceInstanceAndCertify() throws Exception {
201 String artifactFileName = dcaeInventoryToscaFile;
202 String artifactName = dcaeInventoryToscaFile;
203 String artifactLabel = "dcae inv tosca label";
204 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
205 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
206 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
210 public void addDcaeInventoryJsonArtifactToResourceInstanceAndCertify() throws Exception {
211 String artifactFileName = dcaeInventoryJsonFile;
212 String artifactName = dcaeInventoryJsonFile;
213 String artifactLabel = "dcae inv json label";
214 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_JSON;
215 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
216 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
220 public void addDcaeInventoryPolicyArtifactToResourceInstanceAndCertify() throws Exception {
221 String artifactFileName = dcaeInventoryPolicyFile;
222 String artifactName = dcaeInventoryPolicyFile;
223 String artifactLabel = "dcae inv policy label";
224 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_POLICY;
225 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
226 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
230 public void addDcaeInventoryDocArtifactToResourceInstanceAndCertify() throws Exception {
231 String artifactFileName = dcaeInventoryDocFile;
232 String artifactName = dcaeInventoryDocFile;
233 String artifactLabel = "dcae inv doc label";
234 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_DOC;
235 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
236 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
240 public void addDcaeInventoryBluePrintArtifactToResourceInstanceAndCertify() throws Exception {
241 String artifactFileName = dcaeInventoryBlueprintFile;
242 String artifactName = dcaeInventoryBlueprintFile;
243 String artifactLabel = "dcae inv blueprint label";
244 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT;
245 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
246 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
250 public void addDcaeInventoryEventArtifactToResourceInstanceAndCertify() throws Exception {
251 String artifactFileName = dcaeInventoryEventFile;
252 String artifactName = dcaeInventoryEventFile;
253 String artifactLabel = "dcae inv event label";
254 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_EVENT;
255 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
256 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
259 private RestResponse addArtifactToResourceInstanceAndCertify(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
262 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
263 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
266 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
267 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
269 // Add VF instance to service
270 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
271 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
272 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
274 // Get the VF instance
275 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
276 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
277 ComponentInstance VfInstance = service.getComponentInstances().get(0);
279 // Create the artifact
280 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstance(artifactFileName, artifactName, artifactLabel, artifactType, VfInstance, serviceDetails);
281 logger.debug("addInformationalArtifactToResource response: {}", addArtifactToResourceInstanceResponse.getResponseMessage());
282 return addArtifactToResourceInstanceResponse;
286 public void updateArtifactDescriptionToResourceInstance() throws Exception {
287 String artifactFileName = dcaeInventoryToscaFile;
288 String artifactName = dcaeInventoryToscaFile;
289 String artifactLabel = "dcae inv tosca label";
290 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
291 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
292 logger.debug("addInformationalArtifactToResource response: {}", addArtifactToResourceInstanceResponse.getResponseMessage());
293 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
295 // Get the artifact from VF instance and change his description.
296 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
297 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
298 ComponentInstance vfInstance = service.getComponentInstances().get(0);
299 Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
300 ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
301 artifactDefinition.setDescription("My new description");
303 // Update the artifact
304 RestResponse updateDeploymentArtifactToRI = ArtifactRestUtils.updateArtifactToResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
305 logger.debug("addInformationalArtifactToResource response: {}", updateDeploymentArtifactToRI.getResponseMessage());
306 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateDeploymentArtifactToRI.getErrorCode(), updateDeploymentArtifactToRI.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
310 public void deleteArtifactToResourceInstance() throws Exception {
311 String artifactFileName = dcaeInventoryToscaFile;
312 String artifactName = dcaeInventoryToscaFile;
313 String artifactLabel = "dcae inv tosca label";
314 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
315 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
316 logger.debug("addInformationalArtifactToResource response: {}", addArtifactToResourceInstanceResponse.getResponseMessage());
317 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
319 // Get the artifact from VF instance and change his description.
320 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
321 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
322 ComponentInstance vfInstance = service.getComponentInstances().get(0);
323 Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
324 ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
326 // Delete the artifact
327 RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteArtifactFromResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
328 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
332 public void addHeatArtifactToResource() throws Exception {
334 String fileName = heatSuccessFile;
335 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
336 logger.debug("listFileName: {}", listFileName);
338 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
339 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
340 heatArtifactDetails.setPayload(payload);
342 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
343 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
344 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
349 public void addHeatAndHeatNetArtifactsToResource() throws Exception {
351 String fileName = heatSuccessFile;
352 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
355 logger.debug("listFileName: {}", listFileName);
356 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
357 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
358 heatArtifactDetails.setPayload(payload);
360 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
361 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
362 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
365 String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
366 ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
367 heatNetArtifactDetails.setPayload(payloadNet);
368 heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
370 RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
371 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource1.getResponseMessage());
372 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource1.getErrorCode(), addInformationalArtifactToResource1.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
374 RestResponse resourceGetResponse = ResourceRestUtils.getResource(vfResourceDetails, sdncDesignerDetails1);
375 Resource resourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
376 Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
378 ArtifactDefinition artifactDefinition = deploymentArtifacts.get(HEAT_LABEL);
379 assertNotNull(artifactDefinition);
380 String heatEsId = artifactDefinition.getEsId();
381 assertNotNull(heatEsId);
383 ArtifactDefinition artifactDefinitionNet = deploymentArtifacts.get(HEAT_NET_LABEL);
384 assertNotNull(artifactDefinitionNet);
385 String heatNetEsId = artifactDefinitionNet.getEsId();
386 assertNotNull(heatNetEsId);
387 assertFalse(heatEsId.equalsIgnoreCase(heatNetEsId));
391 public void addDeleteAddHeatArtifactToResource() throws Exception {
393 String fileName = heatSuccessFile;
394 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
395 logger.debug("listFileName: {}", listFileName.toString());
397 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
398 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
399 heatArtifactDetails.setPayload(payload);
401 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
402 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
403 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
405 RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteInformationalArtifactFromResource(vfResourceDetails.getUniqueId(), heatArtifactDetails, sdncDesignerDetails1);
406 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
408 addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
409 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
410 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
414 public void addYangXmlArtifactToResource() throws Exception {
416 String fileName = yangFile;
417 String artifactName = "asc_heat 0 2.XML";
418 String artifactLabel = "Label";
419 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
421 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
422 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
423 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
424 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
425 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
426 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
430 public void addOtherTypeDeploymentArtifactToResource() throws Exception {
432 String fileName = otherFile;
433 String artifactName = "other.txt";
434 String artifactLabel = "Label";
435 ArtifactTypeEnum artifactType = ArtifactTypeEnum.OTHER;
437 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
438 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
439 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
440 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
441 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
442 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
446 public void addYangXmlArtifactSameName() throws Exception {
448 String fileName = yangFile;
449 String artifactName = "asc_heat_0_2.XML";
450 String artifactLabel = "Label";
451 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
453 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
454 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
455 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
456 // Changing label but not name
457 artifactLabel = "Label1";
458 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
459 assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
460 BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, new String[] { "Resource", vfResourceDetails.getName(), artifactName });
462 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
463 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
464 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
468 public void addInvalidYangXmlFormat() throws Exception {
470 String fileName = invalidYangFile;
471 String artifactName = "asc_heat_0_2.XML";
472 String artifactLabel = "Label";
473 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
475 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
476 assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
477 BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.INVALID_XML, new String[] { "YANG_XML" });
482 public void addSeveralYangXmlArtifacts() throws Exception {
484 // Adding 4 artifacts
485 String fileName = yangFile;
486 String artifactName = "asc_heat_0_2.XML";
487 String artifactLabel = "Label";
488 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
490 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
491 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
492 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
493 // Changing label and name
494 artifactLabel = "Label1";
495 artifactName = "asc_heat_0_3.XML";
496 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
497 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
499 // Changing label and name
500 artifactLabel = "Label2";
501 artifactName = "asc_heat_0_4.XML";
502 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
504 // Changing label and name
505 artifactLabel = "Label3";
506 artifactName = "asc_heat_0_5.XML";
507 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
508 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
510 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
511 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
512 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 4);
515 @Test(dataProvider = "getDepArtByType")
516 public void updateHeatArtifactToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
518 String fileName = heatSuccessFile;
519 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
520 logger.debug("listFileName: {}", listFileName.toString());
522 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
523 heatTypeArtifactDetails.setPayload(payload);
525 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
526 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
527 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
530 heatTypeArtifactDetails.setArtifactName("UPDATE.yaml");
531 heatTypeArtifactDetails.setPayloadData(null);
532 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
533 logger.debug("addInformationalArtifactToResource response: {}", updateInformationalArtifactToResource.getResponseMessage());
534 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
538 @Test(dataProvider = "getDepArtByType")
539 public void updateHeatArtifactTimeOutToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
541 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
542 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
543 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
545 Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
546 int actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
547 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
550 heatTypeArtifactDetails.setTimeout(35);
551 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
552 logger.debug("addInformationalArtifactToResource response: {}", updateInformationalArtifactToResource.getResponseMessage());
553 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
555 resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
556 actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
557 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
560 @Test(dataProvider = "getDepArtByType")
561 public void updateHeatArtifactDescriptionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
563 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
564 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
565 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
567 Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
568 String actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
569 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
572 heatTypeArtifactDetails.setDescription("the best description was ever");
573 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
574 logger.debug("addInformationalArtifactToResource response: {}", updateInformationalArtifactToResource.getResponseMessage());
575 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
577 resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
578 actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
579 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
582 private Resource getResourceByResDetails(ResourceReqDetails resDetails, User userDetails) throws IOException {
583 RestResponse response = ResourceRestUtils.getResource(resDetails, userDetails);
584 assertTrue("response code on get resource not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + response.getErrorCode(), response.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
585 Resource resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
589 // ---------------------------------Service
590 // success--------------------------------
592 public void addAllTypesDepArtifactToService() throws Exception {
593 ArtifactReqDetails otherArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
595 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(otherArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
596 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
597 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
599 ArtifactReqDetails yangXmlArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
601 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(yangXmlArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
602 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
603 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
607 @Test(enabled = false)
608 public void addMuranoPkgArtifactToService() throws Exception, Exception {
610 String fileName = muranoFile;
611 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
612 logger.debug("listFileName: {}", listFileName);
614 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
615 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MURANO_PKG.getType());
616 heatArtifactDetails.setPayload(payload);
617 heatArtifactDetails.setArtifactName("asc_heat 0 2.zip");
618 heatArtifactDetails.setArtifactLabel("Label");
620 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
621 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
622 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
626 @Test(dataProvider = "getServiceDepArtByType")
627 public void addHeatArtifactToServiceAndCertify(String artType) throws Exception, Exception {
629 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
631 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
632 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
633 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
636 RestResponse changeServiceState = LifecycleRestUtils.certifyService(serviceDetails);
637 int status = changeServiceState.getErrorCode();
638 assertEquals("certify service request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
640 Service resourceJavaObject = ResponseParser.convertServiceResponseToJavaObject(changeServiceState.getResponse());
641 Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
642 boolean flag = false;
643 if (artifactsMap != null) {
644 for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
645 if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
646 assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
651 assertTrue("expected artifact not found", flag == true);
656 @Test(enabled = false, dataProvider = "getServiceDepArtByType")
657 public void updateHeatArtifactToService(String artType) throws Exception, Exception {
659 String fileName = heatSuccessFile;
660 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
661 logger.debug("listFileName: {}", listFileName.toString());
663 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
664 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
666 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
667 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToService.getResponseMessage());
668 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
671 heatArtifactDetails.setPayloadData(payload);
672 RestResponse updateInformationalArtifactToService = ArtifactRestUtils.updateInformationalArtifactOfServiceByMethod(heatArtifactDetails, serviceDetails.getUniqueId(), sdncDesignerDetails1, "POST");
673 logger.debug("updateInformationalArtifactToService response: {}", updateInformationalArtifactToService.getResponseMessage());
674 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToService.getErrorCode(), updateInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
678 // --------------------------------------Resource Negative
679 // Tests-------------------------------------
681 // TODO Andrey the method of DEPLOYMENT artifact is update and not add
682 @Test(dataProvider = "getServiceDepArtByType")
683 public void addTheSameAdditionalHeatArtifactToResource(String artType) throws Exception, Exception {
685 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
687 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
688 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
690 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
692 // add the same artifact one more time
693 artifactDetails.setArtifactLabel("the second artifact");
694 addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
696 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
697 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
699 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), artifactDetails.getArtifactName());
700 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
705 public void addHeatArtifactTwiceSameNameToResource() throws Exception, Exception {
707 String filename1 = heatSuccessFile;
708 // String filename2 = heatSuccessMiniFile;
709 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
710 logger.debug("listFileName: {}", listFileName);
712 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
714 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
715 heatArtifactDetails.setPayload(payload);
717 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
719 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
721 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
724 String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
725 ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
726 heatNetArtifactDetails.setPayload(payloadNet);
727 heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
728 heatNetArtifactDetails.setArtifactName(heatArtifactDetails.getArtifactName());
730 RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
731 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource1.getResponseMessage());
733 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
734 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource1.getErrorCode());
736 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatNetArtifactDetails.getArtifactName());
737 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource1.getResponse());
741 @Test(dataProvider = "getDepArtByType")
742 public void addHeatArtifactTwiceToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
744 String filename1 = heatSuccessFile;
745 String filename2 = heatSuccessMiniFile;
746 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
747 logger.debug("listFileName: {}", listFileName);
749 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
750 heatTypeArtifactDetails.setPayload(payload);
752 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
753 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
754 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
756 // add the second artifact
757 payload = FileUtils.loadPayloadFile(listFileName, heatSuccessMiniFile, true);
758 heatTypeArtifactDetails.setPayload(payload);
759 heatTypeArtifactDetails.setArtifactName(filename2);
760 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
762 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
763 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
764 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
766 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
767 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
771 @Test(dataProvider = "getDepArtByType")
772 public void addHeatArtifactInvalidHeatFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
774 String fileName = heatInvalidFormat;
775 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
776 logger.debug("listFileName: {}", listFileName);
778 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
779 heatTypeArtifactDetails.setPayload(payload);
781 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
782 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
784 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
785 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
787 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
788 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToResource.getResponse());
792 @Test(dataProvider = "getDepArtByType")
793 public void addHeatArtifactInvalidYamlFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
795 String fileName = yamlInvalidFormat;
796 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
797 logger.debug("listFileName: {}", listFileName);
799 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
800 heatTypeArtifactDetails.setPayload(payload);
802 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
803 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
805 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
806 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
808 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
809 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToResource.getResponse());
813 @Test(dataProvider = "getDepArtByType")
814 public void addHeatArtifactInvalidFileExtensionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
816 String fileName = yangFile;
817 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
818 logger.debug("listFileName: {}", listFileName);
820 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
822 heatTypeArtifactDetails.setPayload(payload);
823 heatTypeArtifactDetails.setArtifactName(fileName);
825 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
826 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
828 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
829 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
831 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
832 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToResource.getResponse());
836 @Test(dataProvider = "getDepArtByType")
837 public void addHeatArtifactToResourceCertifyAndAddAdditionalHeatArtifact(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
839 String fileName = heatSuccessFile;
840 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
841 logger.debug("listFileName: {}", listFileName);
843 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
844 heatTypeArtifactDetails.setPayload(payload);
846 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
848 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
849 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
851 // certified resource
852 RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
853 int status = changeResourceState.getErrorCode();
854 assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
856 // add second HEAT artifact to the certified resource
857 changeResourceState = LifecycleRestUtils.changeResourceState(vfResourceDetails, sdncDesignerDetails1, LifeCycleStatesEnum.CHECKOUT);
858 assertTrue("expected code response on change resource state to CHECKOUT BaseRestUtils.STATUS_CODE_SUCCESS, but was " + changeResourceState.getErrorCode(), changeResourceState.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
860 // ArtifactReqDetails heatArtifactDetails1 =
861 // ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
862 heatTypeArtifactDetails.setPayload(payload);
863 heatTypeArtifactDetails.setArtifactName(fileName);
864 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
866 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
868 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
869 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
871 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
872 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
876 // -----------------Service Negative
877 // Tests--------------------------------------------------------
880 @Test(enabled = false)
881 public void addHeatArtifactTwiceToService() throws Exception, Exception {
883 String fileName1 = heatSuccessFile;
884 String fileName2 = heatSuccessMiniFile;
885 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
886 logger.debug("listFileName: {}", listFileName);
888 String payload = FileUtils.loadPayloadFile(listFileName, fileName1, true);
889 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
890 heatArtifactDetails.setPayload(payload);
892 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
893 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
894 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
896 // add the second artifact
897 payload = FileUtils.loadPayloadFile(listFileName, fileName2, true);
899 ArtifactReqDetails heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
900 heatArtifactDetails1.setPayload(payload);
901 heatArtifactDetails1.setArtifactName(fileName2);
902 heatArtifactDetails1.setArtifactLabel("the second artifact");
904 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails1, sdncDesignerDetails1, serviceDetails.getUniqueId());
905 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
906 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
908 List<String> variables = Arrays.asList("Service", serviceDetails.getName(), ArtifactTypeEnum.OTHER.getType(), ArtifactTypeEnum.OTHER.getType());
909 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToService.getResponse());
913 // TODO Andrey Obsolete
914 @Test(enabled = false)
915 public void addHeatArtifactInvalidHeatFormatToService() throws Exception, Exception {
917 String fileName = heatInvalidFormat;
918 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
919 logger.debug("listFileName: {}", listFileName);
921 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
923 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
924 heatArtifactDetails.setPayload(payload);
926 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
927 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
929 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
930 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
932 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
933 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToService.getResponse());
937 @Test(enabled = false)
938 public void addHeatArtifactInvalidYamlFormatToService() throws Exception, Exception {
940 String fileName = yamlInvalidFormat;
941 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
942 logger.debug("listFileName: {}", listFileName);
944 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
946 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
947 heatArtifactDetails.setPayload(payload);
949 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
950 logger.debug("addInformationalArtifactToService response: {} ", addInformationalArtifactToService.getResponseMessage());
952 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
953 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
955 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
956 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToService.getResponse());
961 public void addHeatArtifactInvalidFileExtensionToService() throws Exception, Exception {
963 String fileName = muranoFile;
964 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
965 logger.debug("listFileName: {}", listFileName);
967 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
969 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
970 heatArtifactDetails.setPayload(payload);
971 heatArtifactDetails.setArtifactName(fileName);
973 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
974 logger.debug("addInformationalArtifactToService response: {} ", addInformationalArtifactToService.getResponseMessage());
976 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
977 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
979 List<String> variables = Arrays.asList(ArtifactTypeEnum.YANG_XML.getType());
980 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToService.getResponse());
984 @Test(dataProvider = "getDepArtByType")
985 public void addHeatEnvArtifactToResourceNotSupportedType(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
987 String fileName = heatEnvfile;
988 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
989 logger.debug("listFileName: {}", listFileName.toString());
991 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
993 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_ENV.getType());
994 heatArtifactDetails.setPayload(payload);
995 heatArtifactDetails.setArtifactName("asc_heat 0 2.env");
996 heatArtifactDetails.setArtifactLabel(heatTypeArtifactDetails.getArtifactLabel());
998 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
999 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
1000 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
1002 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT_ENV.getType());
1003 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToResource.getResponse());
1008 public void addHeatArtifactToServiceNotSupportDeploymentArt() throws Exception, Exception {
1010 String fileName = heatSuccessFile;
1011 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
1012 logger.debug("listFileName: {}", listFileName);
1014 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
1016 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
1017 heatArtifactDetails.setPayload(payload);
1019 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1020 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
1021 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
1023 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
1024 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToService.getResponse());
1028 protected RestResponse addArtifactToResourceInstance(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ComponentInstance componentInstance, ServiceReqDetails serviceDetails) throws Exception {
1029 ArtifactReqDetails dcaeArtifactDetails = buildArtifactReqDetailsObject(testResourcesInstancesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1030 RestResponse addArtifactToResourceInstance = ArtifactRestUtils.addArtifactToResourceInstance(dcaeArtifactDetails, sdncDesignerDetails1, componentInstance.getUniqueId(), serviceDetails.getUniqueId());
1031 return addArtifactToResourceInstance;
1034 protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
1035 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1036 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
1037 return addInformationalArtifactToResource;
1040 protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ResourceReqDetails resource) throws Exception {
1041 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1042 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, resource.getUniqueId());
1043 return addInformationalArtifactToResource;
1046 // US672293 - Support new artifact type : BEVF_LICENSE , VENDOR_LICENSE
1048 public void addNewArtifactsToVFResource() throws Exception {
1050 String fileName = yangFile;
1051 String artifactName = "artifact1.xml";
1052 String artifactLabel = "Label1";
1053 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1055 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1056 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1057 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1058 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1059 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1060 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1061 artifactName = "artifact2.xml";
1062 artifactLabel = "Label2";
1063 artifactType = ArtifactTypeEnum.VF_LICENSE;
1065 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1066 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1067 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1068 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1069 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1070 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1072 artifactName = "artifact3.xml";
1073 artifactLabel = "Label3";
1074 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1075 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1076 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1077 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1078 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1079 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1080 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1082 artifactName = "artifact4.xml";
1083 artifactLabel = "Label4";
1084 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1086 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1087 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1088 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1089 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1090 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1091 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1093 artifactName = "artifact5.xml";
1094 artifactLabel = "Label5";
1095 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1097 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1098 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1099 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1100 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1101 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1102 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1104 artifactName = "artifact6.xml";
1105 artifactLabel = "Label6";
1106 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1108 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1109 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1110 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1111 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1112 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1113 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1115 fileName = jsonFile;
1116 artifactName = "artifact7.json";
1117 artifactLabel = "Label7";
1118 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1120 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1121 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1122 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1123 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1124 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1125 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 2);
1127 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1128 fileName = jsonFile;
1129 artifactName = "artifact8.json";
1130 artifactLabel = "Label8";
1131 artifactType = ArtifactTypeEnum.SNMP_POLL;
1133 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1134 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1135 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1136 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1137 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1138 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1140 fileName = jsonFile;
1141 artifactName = "artifact9.json";
1142 artifactLabel = "Label9";
1143 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1145 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1146 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1147 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1148 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1149 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1150 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1152 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1153 fileName = jsonFile;
1154 artifactName = "artifact8.json";
1155 artifactLabel = "Label8";
1156 artifactType = ArtifactTypeEnum.SNMP_POLL;
1158 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1159 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1160 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1161 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1162 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1163 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1165 fileName = jsonFile;
1166 artifactName = "artifact9.json";
1167 artifactLabel = "Label9";
1168 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1170 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1171 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1172 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1173 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1174 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1175 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1179 public void addNewArtifactsToVFCResource() throws Exception {
1181 String fileName = yangFile;
1182 String artifactName = "artifact1.xml";
1183 String artifactLabel = "Label1";
1184 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1186 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1187 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1188 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1189 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1190 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1191 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1193 artifactName = "artifact2.xml";
1194 artifactLabel = "Label2";
1195 artifactType = ArtifactTypeEnum.VF_LICENSE;
1197 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1198 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1199 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1200 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1201 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1202 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1204 artifactName = "artifact3.xml";
1205 artifactLabel = "Label3";
1206 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1208 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1209 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1210 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1211 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1212 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1213 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1215 artifactName = "artifact4.xml";
1216 artifactLabel = "Label4";
1217 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1219 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1220 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1221 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1222 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1223 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1224 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1226 artifactName = "artifac5.xml";
1227 artifactLabel = "Label5";
1228 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1230 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1231 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1232 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1233 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1234 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1235 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1239 public void addNewArtifactsToVfc() throws Exception {
1240 String fileName = yangFile;
1241 String artifactName = "artifact2.xml";
1242 String artifactLabel = "Label2";
1243 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1244 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1245 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1246 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1247 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1248 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1249 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1250 artifactName = "artifact3.xml";
1251 artifactLabel = "Label3";
1252 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1253 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1254 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1255 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1256 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1257 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1258 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1262 public void addNewArtifactsToCp() throws Exception {
1263 String fileName = yangFile;
1264 String artifactName = "artifact2.xml";
1265 String artifactLabel = "Label2";
1266 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1267 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1268 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1269 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1270 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1271 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1272 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1273 artifactName = "artifact3.xml";
1274 artifactLabel = "Label3";
1275 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1276 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1277 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1278 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1279 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1280 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1281 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1285 public void addNewArtifactsToVl() throws Exception {
1286 String fileName = yangFile;
1287 String artifactName = "artifact2.xml";
1288 String artifactLabel = "Label2";
1289 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1290 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1291 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1292 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1293 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1294 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1295 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1296 artifactName = "artifact3.xml";
1297 artifactLabel = "Label3";
1298 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1299 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1300 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1301 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1302 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1303 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1304 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1308 public void addVfInstanceWithNewArtifactsToService() throws Exception {
1309 String fileName = yangFile;
1310 String artifactName = "artifact2.xml";
1311 String artifactLabel = "Label2";
1312 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1313 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1314 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1315 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1316 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1317 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1318 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1319 artifactName = "artifact3.xml";
1320 artifactLabel = "Label3";
1321 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1322 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1323 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1324 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1325 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1326 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1327 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1329 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1330 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1331 // Add VF instance to service
1332 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1333 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1334 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1335 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1336 // and VENDOR_LICENSE
1337 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1338 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1339 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1340 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VENDOR_LICENSE, 1);
1341 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VF_LICENSE, 1);
1345 public void addNotSupportedArtifactsTypeToService01() throws Exception, Exception {
1346 // Artifact type : VF_LICENSE
1347 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VF_LICENSE.getType());
1348 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1349 assertTrue("response code eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1350 ArrayList<String> variables = new ArrayList<>();
1351 variables.add("VF_LICENSE");
1352 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1356 public void addNotSupportedArtifactsTypeToService02() throws Exception, Exception {
1357 // Artifact type : VENDOR_LICENSE
1358 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VENDOR_LICENSE.getType());
1359 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1360 assertTrue("response code eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1361 ArrayList<String> variables = new ArrayList<>();
1362 variables.add("VENDOR_LICENSE");
1363 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1367 public void addInvalidFileForArtifactTypeVendorLicenseToResource() throws Exception {
1368 String fileName = yangFile;
1369 String NonXmlFile = heatSuccessFile;
1370 String artifactName = "artifact2.xml";
1371 String artifactLabel = "Label2";
1372 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1373 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1374 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1375 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1376 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1377 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1378 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1379 // Artifact type VENDOR_LICENSE must be XML file
1380 artifactName = "artifact3.xml";
1381 artifactLabel = "Label3";
1382 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1383 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1384 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1385 assertTrue("response code 400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1386 ArrayList<String> variables = new ArrayList<>();
1387 variables.add("VENDOR_LICENSE");
1388 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1389 // get resource and verify that file not exist within
1390 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1391 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1392 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1396 public void addInvalidFileForArtifactTypeVfLicenseToResource() throws Exception {
1397 String fileName = yangFile;
1398 String NonXmlFile = heatSuccessFile;
1399 String artifactName = "artifact2.xml";
1400 String artifactLabel = "Label2";
1401 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1402 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1403 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1404 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1405 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1406 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1407 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1408 // Artifact type VF_LICENSE must be XML file
1409 artifactName = "artifact3.xml";
1410 artifactLabel = "Label3";
1411 artifactType = ArtifactTypeEnum.VF_LICENSE;
1412 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1413 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1414 assertTrue("response code 400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1415 ArrayList<String> variables = new ArrayList<>();
1416 variables.add("VF_LICENSE");
1417 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1418 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1419 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1420 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1424 public void addVendorLicenseArtifactAlreadyExistsInResource() throws Exception {
1425 String fileName = yangFile;
1426 String artifactName = "artifact2.xml";
1427 String artifactLabel = "Label2";
1428 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1429 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1430 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1431 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1432 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1433 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1434 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1435 // Add same file again to resource
1436 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1437 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1438 assertTrue("response code is not 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1439 ArrayList<String> variables = new ArrayList<>();
1440 variables.add(artifactLabel.toLowerCase());
1441 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactToResource.getResponse());
1442 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1443 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1444 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1450 public void addVnfCatalogArtifactsToService() throws Exception, Exception {
1452 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VNF_CATALOG.getType());
1453 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1454 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1455 // get service and verify the Artifacts :VNF_CATALOG
1456 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1457 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1458 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1462 public void addModelInventoryProfileArtifactsToService() throws Exception, Exception {
1464 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType());
1465 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1466 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1467 // get service and verify the Artifacts :VNF_CATALOG
1468 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1469 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1470 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1474 public void addModelQuerySpecArtifactsToService() throws Exception, Exception {
1476 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1477 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1478 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1479 // get service and verify the Artifacts :VNF_CATALOG
1480 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1481 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1482 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1486 public void addVfInstanceWithNewArtifactsToService02() throws Exception {
1488 String fileName = yangFile;
1489 String artifactName = "artifact1.xml";
1490 String artifactLabel = "Label1";
1491 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1492 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1493 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1494 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1495 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1496 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1497 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1499 fileName = yangFile;
1500 artifactName = "artifact2.xml";
1501 artifactLabel = "Label2";
1502 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1503 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1504 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1505 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1506 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1507 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1508 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1510 artifactName = "artifact4.xml";
1511 artifactLabel = "Label4";
1512 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1514 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1515 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1516 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1517 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1518 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1519 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1521 artifactName = "artifac5.xml";
1522 artifactLabel = "Label5";
1523 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1525 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1526 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1527 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1528 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1529 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1530 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1532 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1533 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1535 // Add VF instance to service
1536 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1537 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1538 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1540 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1541 // and VENDOR_LICENSE
1542 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1543 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1544 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1545 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1546 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1547 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1548 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.APPC_CONFIG, 1);
1552 public void addAppcConfigArtifactToVfc() throws Exception {
1553 String fileName = jsonFile;
1554 String artifactName = "artifact7.json";
1555 String artifactLabel = "Label7";
1556 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1557 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1558 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1559 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1560 ArrayList<String> variables = new ArrayList<>();
1561 variables.add(artifactName);
1562 variables.add("[VF]");
1563 variables.add("VFC (Virtual Function Component)");
1564 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1565 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1566 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1567 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1571 public void addAppcConfigArtifactToCp() throws Exception {
1572 String fileName = jsonFile;
1573 String artifactName = "artifact7.json";
1574 String artifactLabel = "Label7";
1575 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1576 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1577 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1578 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1579 ArrayList<String> variables = new ArrayList<>();
1580 variables.add(artifactName);
1581 variables.add("[VF]");
1582 variables.add("CP (Connection Point)");
1583 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1584 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1585 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1586 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1590 public void addAppcConfigArtifactToVl() throws Exception {
1591 String fileName = jsonFile;
1592 String artifactName = "artifact7.json";
1593 String artifactLabel = "Label7";
1594 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1595 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1596 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1597 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1598 ArrayList<String> variables = new ArrayList<>();
1599 variables.add(artifactName);
1600 variables.add("[VF]");
1601 variables.add("VL (Virtual Link)");
1602 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1603 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1604 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1605 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1609 public void addAppcConfigArtifactsToService() throws Exception, Exception {
1610 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.APPC_CONFIG.getType());
1611 RestResponse addDeploymentArtifactToResource = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1612 assertTrue("response code 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1613 ArrayList<String> variables = new ArrayList<>();
1614 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1615 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToResource.getResponse());
1619 public void addAppcConfigInvalidJsonToVFResourceFailed() throws Exception {
1621 String fileName = invalidJsonFile;
1622 String artifactName = "invalidJson.json";
1623 String artifactLabel = "Label7";
1624 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1626 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1627 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1628 assertTrue("response code is 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1630 ArrayList<String> variables = new ArrayList<>();
1631 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1632 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_JSON.name(), variables, addInformationalArtifactToResource.getResponse());
1634 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1635 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1636 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1641 public void addNewArtifactsToCp02() throws Exception {
1643 String fileName = yangFile;
1644 String artifactName = "artifact1.xml";
1645 String artifactLabel = "Label1";
1646 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1648 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1649 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1650 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1651 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1652 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1653 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1655 artifactName = "artifact4.xml";
1656 artifactLabel = "Label4";
1657 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1659 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1660 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1661 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1662 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1663 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1664 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1666 artifactName = "artifac5.xml";
1667 artifactLabel = "Label5";
1668 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1670 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1671 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1672 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1673 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1674 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1675 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1679 public void addNewArtifactsToVl02() throws Exception {
1681 String fileName = yangFile;
1682 String artifactName = "artifact1.xml";
1683 String artifactLabel = "Label1";
1684 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1686 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1687 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1688 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1689 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1690 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1691 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1693 artifactName = "artifact4.xml";
1694 artifactLabel = "Label4";
1695 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1697 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1698 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1699 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1700 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1701 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1702 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1704 artifactName = "artifac5.xml";
1705 artifactLabel = "Label5";
1706 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1708 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1709 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1710 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1711 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1712 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1713 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1717 public void addNewArtifactsToVfc02() throws Exception {
1719 String fileName = yangFile;
1720 String artifactName = "artifact1.xml";
1721 String artifactLabel = "Label1";
1722 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1724 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1725 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1726 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1727 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1728 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1729 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1731 artifactName = "artifact4.xml";
1732 artifactLabel = "Label4";
1733 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1735 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1736 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1737 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1738 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1739 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1740 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1742 artifactName = "artifac5.xml";
1743 artifactLabel = "Label5";
1744 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1746 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1747 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1748 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1749 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1750 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1751 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1755 public void addNewArtifactAlreadyExistsInService() throws Exception {
1756 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1757 RestResponse addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1758 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1759 // get service and verify the Artifacts :VNF_CATALOG
1760 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1761 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1762 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1763 // Add same file again to resource
1764 addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1765 assertTrue("response code is 400, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1766 ArrayList<String> variables = new ArrayList<>();
1767 variables.add(artDetails.getArtifactLabel().toLowerCase());
1768 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactoService.getResponse());
1769 // get service and verify the Artifacts :VNF_CATALOG is still exist and
1770 // has one occurrences
1771 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1772 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1773 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1776 private ArtifactReqDetails buildArtifactReqDetailsObject(String filesPath, String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws IOException, Exception {
1777 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(filesPath);
1778 logger.debug("listFileName: {}", listFileName);
1780 String payload = FileUtils.loadPayloadFile(listFileName, artifactFileName, true);
1782 ArtifactReqDetails dcaeArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artifactType.getType());
1783 dcaeArtifactDetails.setPayload(payload);
1784 dcaeArtifactDetails.setArtifactName(artifactName);
1785 dcaeArtifactDetails.setArtifactLabel(artifactLabel);
1786 return dcaeArtifactDetails;