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 org.apache.commons.lang3.tuple.Pair;
24 import org.junit.Rule;
25 import org.junit.rules.TestName;
26 import org.openecomp.sdc.be.dao.api.ActionStatus;
27 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
28 import org.openecomp.sdc.be.model.*;
29 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
30 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
31 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
32 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
33 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
34 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
35 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
38 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
39 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
40 import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
41 import org.openecomp.sdc.ci.tests.utils.rest.*;
42 import org.openecomp.sdc.ci.tests.utils.validation.ArtifactValidationUtils;
43 import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
44 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
45 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
46 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory;
48 import org.testng.annotations.BeforeMethod;
49 import org.testng.annotations.DataProvider;
50 import org.testng.annotations.Test;
53 import java.io.IOException;
54 import java.util.ArrayList;
55 import java.util.Arrays;
56 import java.util.List;
58 import java.util.Map.Entry;
60 import static org.testng.AssertJUnit.*;
62 public class CrudArt extends ComponentBaseTest {
64 private static Logger logger = LoggerFactory.getLogger(CrudArt.class.getName());
65 private static final User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
67 private static final String HEAT_NET_LABEL = "heatnet";
68 private static final String HEAT_LABEL = "heat";
70 protected String testResourcesPath;
71 protected String testResourcesInstancesPath;
73 protected static final String dcaeInventoryToscaFile = "toscaSampleArtifact.yml";
74 protected static final String dcaeInventoryJsonFile = "jsonSampleArtifact.json";
75 protected static final String dcaeInventoryPolicyFile = "emfSampleArtifact.emf";
76 protected static final String dcaeInventoryDocFile = "docSampleArtifact.doc";
77 protected static final String dcaeInventoryBlueprintFile = "bluePrintSampleArtifact.xml";
78 protected static final String dcaeInventoryEventFile = "eventSampleArtifact.xml";
80 protected static final String heatSuccessFile = "asc_heat 0 2.yaml";
81 protected static final String heatNetSuccessFile = "asc_heat_net 0 2.yaml";
82 protected static final String yangFile = "addYangXmlArtifactToResource.xml";
83 protected static final String jsonFile = "jsonArtifact.json";
84 protected static final String invalidJsonFile = "invalidJson.json";
85 protected static final String invalidYangFile = "invalidYangXml.xml";
86 protected static final String otherFile = "other.txt";
87 protected static final String muranoFile = "asc_heat 0 2.zip";
88 protected static final String heatSuccessMiniFile = "heat_mini.yaml";
89 protected static final String heatInvalidFormat = "heatInvalidFormat.yaml";
90 protected static final String yamlInvalidFormat = "invalidYamlFormat.yaml";
91 protected static final String heatEnvfile = "heatEnvfile.env";
93 protected ServiceReqDetails serviceDetails;
94 protected ResourceReqDetails vfResourceDetails;
95 protected ResourceReqDetails cpResourceDetails;
96 protected ResourceReqDetails vfcResourceDetails;
97 protected ResourceReqDetails vlResourceDetails;
100 public static TestName name = new TestName();
103 super(name, CrudArt.class.getName());
107 private static final Object[][] getDepArtByType() throws IOException, Exception {
108 return new Object[][] { { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType()) },
109 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()) },
110 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()) },
111 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()) },
112 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()) } };
116 private static final Object[][] getServiceDepArtByType() throws IOException, Exception {
117 return new Object[][] { { ArtifactTypeEnum.OTHER.getType() }, { ArtifactTypeEnum.YANG_XML.getType() }, };
121 public void init() throws Exception {
122 // Set files working directory
123 String sourceDir = config.getResourceConfigDir();
124 String workDir = "HeatDeploymentArtifacts";
125 testResourcesPath = sourceDir + File.separator + workDir;
126 String workDirResourceInstanceArtifacts = "ResourceInstanceArtifacts";
127 testResourcesInstancesPath = sourceDir + File.separator + workDirResourceInstanceArtifacts;
129 // Build the components
130 Service serviceObj = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
131 serviceDetails = new ServiceReqDetails(serviceObj);
133 Resource vfcResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
134 vfcResourceDetails = new ResourceReqDetails(vfcResourceObj);
136 Resource vfResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
137 vfResourceDetails = new ResourceReqDetails(vfResourceObj);
139 Resource cpResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.CP, UserRoleEnum.DESIGNER, true).left().value();
140 cpResourceDetails = new ResourceReqDetails(cpResourceObj);
142 Resource vlResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VL, UserRoleEnum.DESIGNER, true).left().value();
143 vlResourceDetails = new ResourceReqDetails(vlResourceObj);
146 // ---------------------------------Resource
147 // success--------------------------------
149 public void addHeatArtifactToResourceAndCertify() throws Exception {
151 String fileName = heatSuccessFile;
152 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
153 logger.debug("listFileName: {}",listFileName.toString());
155 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
156 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
157 heatArtifactDetails.setPayload(payload);
159 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
160 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
161 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
163 // certified resource
164 RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
165 int status = changeResourceState.getErrorCode();
166 assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
168 Resource resourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(changeResourceState.getResponse());
169 Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
170 boolean flag = false;
171 if (artifactsMap != null) {
172 for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
173 if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
174 assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
179 assertTrue("expected artifact not found", flag == true);
184 // ---------------------------------Resource
185 // success--------------------------------
187 public void addDcaeInventoryToscaArtifactToResourceInstanceAndCertify() throws Exception {
188 String artifactFileName = dcaeInventoryToscaFile;
189 String artifactName = dcaeInventoryToscaFile;
190 String artifactLabel = "dcae inv tosca label";
191 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
192 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
193 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
197 public void addDcaeInventoryJsonArtifactToResourceInstanceAndCertify() throws Exception {
198 String artifactFileName = dcaeInventoryJsonFile;
199 String artifactName = dcaeInventoryJsonFile;
200 String artifactLabel = "dcae inv json label";
201 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_JSON;
202 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
203 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
207 public void addDcaeInventoryPolicyArtifactToResourceInstanceAndCertify() throws Exception {
208 String artifactFileName = dcaeInventoryPolicyFile;
209 String artifactName = dcaeInventoryPolicyFile;
210 String artifactLabel = "dcae inv policy label";
211 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_POLICY;
212 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
213 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
217 public void addDcaeInventoryDocArtifactToResourceInstanceAndCertify() throws Exception {
218 String artifactFileName = dcaeInventoryDocFile;
219 String artifactName = dcaeInventoryDocFile;
220 String artifactLabel = "dcae inv doc label";
221 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_DOC;
222 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
223 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
227 public void addDcaeInventoryBluePrintArtifactToResourceInstanceAndCertify() throws Exception {
228 String artifactFileName = dcaeInventoryBlueprintFile;
229 String artifactName = dcaeInventoryBlueprintFile;
230 String artifactLabel = "dcae inv blueprint label";
231 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT;
232 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
233 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
237 public void addDcaeInventoryEventArtifactToResourceInstanceAndCertify() throws Exception {
238 String artifactFileName = dcaeInventoryEventFile;
239 String artifactName = dcaeInventoryEventFile;
240 String artifactLabel = "dcae inv event label";
241 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_EVENT;
242 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
243 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
246 private RestResponse addArtifactToResourceInstanceAndCertify(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
249 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
250 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
253 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
254 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
256 // Add VF instance to service
257 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
258 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
259 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
261 // Get the VF instance
262 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
263 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
264 ComponentInstance VfInstance = service.getComponentInstances().get(0);
266 // Create the artifact
267 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstance(artifactFileName, artifactName, artifactLabel, artifactType, VfInstance, serviceDetails);
268 logger.debug("addInformationalArtifactToResource response: {}",addArtifactToResourceInstanceResponse.getResponseMessage());
269 return addArtifactToResourceInstanceResponse;
273 public void updateArtifactDescriptionToResourceInstance() throws Exception {
274 String artifactFileName = dcaeInventoryToscaFile;
275 String artifactName = dcaeInventoryToscaFile;
276 String artifactLabel = "dcae inv tosca label";
277 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
278 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
279 logger.debug("addInformationalArtifactToResource response: {}" ,addArtifactToResourceInstanceResponse.getResponseMessage());
280 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
282 // Get the artifact from VF instance and change his description.
283 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
284 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
285 ComponentInstance vfInstance = service.getComponentInstances().get(0);
286 Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
287 ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
288 artifactDefinition.setDescription("My new description");
290 // Update the artifact
291 RestResponse updateDeploymentArtifactToRI = ArtifactRestUtils.updateArtifactToResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
292 logger.debug("addInformationalArtifactToResource response: {}",updateDeploymentArtifactToRI.getResponseMessage());
293 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateDeploymentArtifactToRI.getErrorCode(), updateDeploymentArtifactToRI.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
297 public void deleteArtifactToResourceInstance() throws Exception {
298 String artifactFileName = dcaeInventoryToscaFile;
299 String artifactName = dcaeInventoryToscaFile;
300 String artifactLabel = "dcae inv tosca label";
301 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
302 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
303 logger.debug("addInformationalArtifactToResource response: {}",addArtifactToResourceInstanceResponse.getResponseMessage());
304 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
306 // Get the artifact from VF instance and change his description.
307 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
308 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
309 ComponentInstance vfInstance = service.getComponentInstances().get(0);
310 Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
311 ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
313 // Delete the artifact
314 RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteArtifactFromResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
315 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
319 public void addHeatArtifactToResource() throws Exception {
321 String fileName = heatSuccessFile;
322 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
323 logger.debug("listFileName: {}",listFileName.toString());
325 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
326 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
327 heatArtifactDetails.setPayload(payload);
329 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
330 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
331 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
336 public void addHeatAndHeatNetArtifactsToResource() throws Exception {
338 String fileName = heatSuccessFile;
339 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
342 logger.debug("listFileName: {}",listFileName.toString());
343 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
344 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
345 heatArtifactDetails.setPayload(payload);
347 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
348 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
349 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
352 String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
353 ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
354 heatNetArtifactDetails.setPayload(payloadNet);
355 heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
357 RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
358 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource1.getResponseMessage());
359 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource1.getErrorCode(), addInformationalArtifactToResource1.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
361 RestResponse resourceGetResponse = ResourceRestUtils.getResource(vfResourceDetails, sdncDesignerDetails1);
362 Resource resourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
363 Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
365 ArtifactDefinition artifactDefinition = deploymentArtifacts.get(HEAT_LABEL);
366 assertNotNull(artifactDefinition);
367 String heatEsId = artifactDefinition.getEsId();
368 assertNotNull(heatEsId);
370 ArtifactDefinition artifactDefinitionNet = deploymentArtifacts.get(HEAT_NET_LABEL);
371 assertNotNull(artifactDefinitionNet);
372 String heatNetEsId = artifactDefinitionNet.getEsId();
373 assertNotNull(heatNetEsId);
374 assertFalse(heatEsId.equalsIgnoreCase(heatNetEsId));
378 public void addDeleteAddHeatArtifactToResource() throws Exception {
380 String fileName = heatSuccessFile;
381 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
382 logger.debug("listFileName: {}",listFileName.toString());
384 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
385 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
386 heatArtifactDetails.setPayload(payload);
388 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
389 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
390 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
392 RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteInformationalArtifactFromResource(vfResourceDetails.getUniqueId(), heatArtifactDetails, sdncDesignerDetails1);
393 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
395 addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
396 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
397 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
401 public void addYangXmlArtifactToResource() throws Exception {
403 String fileName = yangFile;
404 String artifactName = "asc_heat 0 2.XML";
405 String artifactLabel = "Label";
406 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
408 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
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);
411 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
412 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
413 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
417 public void addOtherTypeDeploymentArtifactToResource() throws Exception {
419 String fileName = otherFile;
420 String artifactName = "other.txt";
421 String artifactLabel = "Label";
422 ArtifactTypeEnum artifactType = ArtifactTypeEnum.OTHER;
424 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
425 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
426 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
427 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
428 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
429 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
433 public void addYangXmlArtifactSameName() throws Exception {
435 String fileName = yangFile;
436 String artifactName = "asc_heat_0_2.XML";
437 String artifactLabel = "Label";
438 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
440 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
441 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
442 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
443 // Changing label but not name
444 artifactLabel = "Label1";
445 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
446 assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
447 BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, new String[] { "Resource", vfResourceDetails.getName(), artifactName });
449 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
450 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
451 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
455 public void addInvalidYangXmlFormat() throws Exception {
457 String fileName = invalidYangFile;
458 String artifactName = "asc_heat_0_2.XML";
459 String artifactLabel = "Label";
460 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
462 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
463 assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
464 BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.INVALID_XML, new String[] { "YANG_XML" });
469 public void addSeveralYangXmlArtifacts() throws Exception {
471 // Adding 4 artifacts
472 String fileName = yangFile;
473 String artifactName = "asc_heat_0_2.XML";
474 String artifactLabel = "Label";
475 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
477 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
478 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
479 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
480 // Changing label and name
481 artifactLabel = "Label1";
482 artifactName = "asc_heat_0_3.XML";
483 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
484 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
486 // Changing label and name
487 artifactLabel = "Label2";
488 artifactName = "asc_heat_0_4.XML";
489 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
491 // Changing label and name
492 artifactLabel = "Label3";
493 artifactName = "asc_heat_0_5.XML";
494 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
495 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
497 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
498 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
499 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 4);
502 @Test(dataProvider = "getDepArtByType")
503 public void updateHeatArtifactToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
505 String fileName = heatSuccessFile;
506 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
507 logger.debug("listFileName: {}",listFileName.toString());
509 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
510 heatTypeArtifactDetails.setPayload(payload);
512 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
513 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
514 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
517 heatTypeArtifactDetails.setArtifactName("UPDATE.yaml");
518 heatTypeArtifactDetails.setPayloadData(null);
519 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
520 logger.debug("addInformationalArtifactToResource response: {}",updateInformationalArtifactToResource.getResponseMessage());
521 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
525 @Test(dataProvider = "getDepArtByType")
526 public void updateHeatArtifactTimeOutToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
528 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
529 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
530 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
532 Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
533 int actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
534 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
537 heatTypeArtifactDetails.setTimeout(35);
538 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
539 logger.debug("addInformationalArtifactToResource response: {}",updateInformationalArtifactToResource.getResponseMessage());
540 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
542 resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
543 actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
544 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
547 @Test(dataProvider = "getDepArtByType")
548 public void updateHeatArtifactDescriptionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
550 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
551 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
552 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
554 Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
555 String actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
556 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
559 heatTypeArtifactDetails.setDescription("the best description was ever");
560 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
561 logger.debug("addInformationalArtifactToResource response: {}",updateInformationalArtifactToResource.getResponseMessage());
562 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
564 resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
565 actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
566 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
569 private Resource getResourceByResDetails(ResourceReqDetails resDetails, User userDetails) throws IOException {
570 RestResponse response = ResourceRestUtils.getResource(resDetails, userDetails);
571 assertTrue("response code on get resource not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + response.getErrorCode(), response.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
572 Resource resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
576 // ---------------------------------Service
577 // success--------------------------------
579 public void addAllTypesDepArtifactToService() throws Exception, Exception {
581 // String fileName = heatSuccessFile;
582 // List<String> listFileName =
583 // FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
584 // logger.debug("listFileName: {}",listFileName.toString());
586 // String payload = FileUtils.loadPayloadFile(listFileName, fileName,
588 ArtifactReqDetails otherArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
589 // otherArtifactDetails.setPayload(payload);
591 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(otherArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
592 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
593 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
595 ArtifactReqDetails yangXmlArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
597 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(yangXmlArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
598 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
599 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
603 @Test(enabled = false)
604 public void addMuranoPkgArtifactToService() throws Exception, Exception {
606 String fileName = muranoFile;
607 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
608 logger.debug("listFileName: {}" ,listFileName.toString());
610 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
611 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MURANO_PKG.getType());
612 heatArtifactDetails.setPayload(payload);
613 heatArtifactDetails.setArtifactName("asc_heat 0 2.zip");
614 heatArtifactDetails.setArtifactLabel("Label");
616 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
617 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
618 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
622 @Test(dataProvider = "getServiceDepArtByType")
623 public void addHeatArtifactToServiceAndCertify(String artType) throws Exception, Exception {
625 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
627 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
628 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
629 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
632 RestResponse changeServiceState = LifecycleRestUtils.certifyService(serviceDetails);
633 int status = changeServiceState.getErrorCode();
634 assertEquals("certify service request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
636 Service resourceJavaObject = ResponseParser.convertServiceResponseToJavaObject(changeServiceState.getResponse());
637 Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
638 boolean flag = false;
639 if (artifactsMap != null) {
640 for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
641 if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
642 assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
647 assertTrue("expected artifact not found", flag == true);
652 @Test(enabled = false, dataProvider = "getServiceDepArtByType")
653 public void updateHeatArtifactToService(String artType) throws Exception, Exception {
655 String fileName = heatSuccessFile;
656 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
657 logger.debug("listFileName: {}",listFileName.toString());
659 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
660 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
662 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
663 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToService.getResponseMessage());
664 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
667 heatArtifactDetails.setPayloadData(payload);
668 RestResponse updateInformationalArtifactToService = ArtifactRestUtils.updateInformationalArtifactOfServiceByMethod(heatArtifactDetails, serviceDetails.getUniqueId(), sdncDesignerDetails1, "POST");
669 logger.debug("updateInformationalArtifactToService response: {}",updateInformationalArtifactToService.getResponseMessage());
670 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToService.getErrorCode(), updateInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
674 // --------------------------------------Resource Negative
675 // Tests-------------------------------------
677 // TODO Andrey the method of DEPLOYMENT artifact is update and not add
678 @Test(dataProvider = "getServiceDepArtByType")
679 public void addTheSameAdditionalHeatArtifactToResource(String artType) throws Exception, Exception {
681 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
683 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
684 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
686 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
688 // add the same artifact one more time
689 artifactDetails.setArtifactLabel("the second artifact");
690 addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
692 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
693 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
695 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), artifactDetails.getArtifactName());
696 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
701 public void addHeatArtifactTwiceSameNameToResource() throws Exception, Exception {
703 String filename1 = heatSuccessFile;
704 // String filename2 = heatSuccessMiniFile;
705 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
706 logger.debug("listFileName: {}",listFileName.toString());
708 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
710 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
711 heatArtifactDetails.setPayload(payload);
713 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
715 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
717 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
720 String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
721 ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
722 heatNetArtifactDetails.setPayload(payloadNet);
723 heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
724 heatNetArtifactDetails.setArtifactName(heatArtifactDetails.getArtifactName());
726 RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
727 logger.debug("addInformationalArtifactToResource response: {}" ,addInformationalArtifactToResource1.getResponseMessage());
729 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
730 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource1.getErrorCode());
732 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatNetArtifactDetails.getArtifactName());
733 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource1.getResponse());
737 @Test(dataProvider = "getDepArtByType")
738 public void addHeatArtifactTwiceToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
740 String filename1 = heatSuccessFile;
741 String filename2 = heatSuccessMiniFile;
742 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
743 logger.debug("listFileName: {}",listFileName.toString());
745 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
746 heatTypeArtifactDetails.setPayload(payload);
748 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
749 logger.debug("addInformationalArtifactToResource response: {}" ,addInformationalArtifactToResource.getResponseMessage());
750 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
752 // add the second artifact
753 payload = FileUtils.loadPayloadFile(listFileName, heatSuccessMiniFile, true);
754 heatTypeArtifactDetails.setPayload(payload);
755 heatTypeArtifactDetails.setArtifactName(filename2);
756 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
758 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
759 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
760 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
762 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
763 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
767 @Test(dataProvider = "getDepArtByType")
768 public void addHeatArtifactInvalidHeatFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
770 String fileName = heatInvalidFormat;
771 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
772 logger.debug("listFileName: {}",listFileName.toString());
774 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
775 heatTypeArtifactDetails.setPayload(payload);
777 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
778 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
780 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
781 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
783 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
784 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToResource.getResponse());
788 @Test(dataProvider = "getDepArtByType")
789 public void addHeatArtifactInvalidYamlFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
791 String fileName = yamlInvalidFormat;
792 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
793 logger.debug("listFileName: {}",listFileName.toString());
795 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
796 heatTypeArtifactDetails.setPayload(payload);
798 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
799 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
801 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
802 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
804 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
805 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToResource.getResponse());
809 @Test(dataProvider = "getDepArtByType")
810 public void addHeatArtifactInvalidFileExtensionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
812 String fileName = yangFile;
813 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
814 logger.debug("listFileName: {}",listFileName.toString());
816 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
818 heatTypeArtifactDetails.setPayload(payload);
819 heatTypeArtifactDetails.setArtifactName(fileName);
821 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
822 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
824 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
825 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
827 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
828 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToResource.getResponse());
832 @Test(dataProvider = "getDepArtByType")
833 public void addHeatArtifactToResourceCertifyAndAddAdditionalHeatArtifact(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
835 String fileName = heatSuccessFile;
836 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
837 logger.debug("listFileName: {}",listFileName.toString());
839 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
840 heatTypeArtifactDetails.setPayload(payload);
842 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
844 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
845 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
847 // certified resource
848 RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
849 int status = changeResourceState.getErrorCode();
850 assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
852 // add second HEAT artifact to the certified resource
853 changeResourceState = LifecycleRestUtils.changeResourceState(vfResourceDetails, sdncDesignerDetails1, LifeCycleStatesEnum.CHECKOUT);
854 assertTrue("expected code response on change resource state to CHECKOUT BaseRestUtils.STATUS_CODE_SUCCESS, but was " + changeResourceState.getErrorCode(), changeResourceState.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
856 // ArtifactReqDetails heatArtifactDetails1 =
857 // ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
858 heatTypeArtifactDetails.setPayload(payload);
859 heatTypeArtifactDetails.setArtifactName(fileName);
860 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
862 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
864 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
865 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
867 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
868 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
872 // -----------------Service Negative
873 // Tests--------------------------------------------------------
876 @Test(enabled = false)
877 public void addHeatArtifactTwiceToService() throws Exception, Exception {
879 String fileName1 = heatSuccessFile;
880 String fileName2 = heatSuccessMiniFile;
881 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
882 logger.debug("listFileName: {}",listFileName.toString());
884 String payload = FileUtils.loadPayloadFile(listFileName, fileName1, true);
885 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
886 heatArtifactDetails.setPayload(payload);
888 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
889 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
890 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
892 // add the second artifact
893 payload = FileUtils.loadPayloadFile(listFileName, fileName2, true);
895 ArtifactReqDetails heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
896 heatArtifactDetails1.setPayload(payload);
897 heatArtifactDetails1.setArtifactName(fileName2);
898 heatArtifactDetails1.setArtifactLabel("the second artifact");
900 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails1, sdncDesignerDetails1, serviceDetails.getUniqueId());
901 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
902 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
904 List<String> variables = Arrays.asList("Service", serviceDetails.getName(), ArtifactTypeEnum.OTHER.getType(), ArtifactTypeEnum.OTHER.getType());
905 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToService.getResponse());
909 // TODO Andrey Obsolete
910 @Test(enabled = false)
911 public void addHeatArtifactInvalidHeatFormatToService() throws Exception, Exception {
913 String fileName = heatInvalidFormat;
914 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
915 logger.debug("listFileName: {}",listFileName.toString());
917 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
919 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
920 heatArtifactDetails.setPayload(payload);
922 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
923 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
925 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
926 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
928 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
929 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToService.getResponse());
933 // TODO Andrey Obsolete
934 @Test(enabled = false)
935 public void addHeatArtifactInvalidYamlFormatToService() throws Exception, Exception {
937 String fileName = yamlInvalidFormat;
938 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
939 logger.debug("listFileName: {}",listFileName.toString());
941 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
943 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
944 heatArtifactDetails.setPayload(payload);
946 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
947 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
949 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
950 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
952 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
953 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToService.getResponse());
958 public void addHeatArtifactInvalidFileExtensionToService() throws Exception, Exception {
960 String fileName = muranoFile;
961 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
962 logger.debug("listFileName: {}",listFileName.toString());
964 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
966 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
967 heatArtifactDetails.setPayload(payload);
968 heatArtifactDetails.setArtifactName(fileName);
970 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
971 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
973 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
974 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
976 List<String> variables = Arrays.asList(ArtifactTypeEnum.YANG_XML.getType());
977 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToService.getResponse());
981 @Test(dataProvider = "getDepArtByType")
982 public void addHeatEnvArtifactToResourceNotSupportedType(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
984 String fileName = heatEnvfile;
985 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
986 logger.debug("listFileName: {}",listFileName.toString());
988 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
990 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_ENV.getType());
991 heatArtifactDetails.setPayload(payload);
992 heatArtifactDetails.setArtifactName("asc_heat 0 2.env");
993 heatArtifactDetails.setArtifactLabel(heatTypeArtifactDetails.getArtifactLabel());
995 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
996 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
997 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
999 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT_ENV.getType());
1000 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToResource.getResponse());
1005 public void addHeatArtifactToServiceNotSupportDeploymentArt() throws Exception, Exception {
1007 String fileName = heatSuccessFile;
1008 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
1009 logger.debug("listFileName: {}",listFileName.toString());
1011 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
1013 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
1014 heatArtifactDetails.setPayload(payload);
1016 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1017 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
1018 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
1020 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
1021 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToService.getResponse());
1025 protected RestResponse addArtifactToResourceInstance(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ComponentInstance componentInstance, ServiceReqDetails serviceDetails) throws Exception {
1026 ArtifactReqDetails dcaeArtifactDetails = buildArtifactReqDetailsObject(testResourcesInstancesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1027 RestResponse addArtifactToResourceInstance = ArtifactRestUtils.addArtifactToResourceInstance(dcaeArtifactDetails, sdncDesignerDetails1, componentInstance.getUniqueId(), serviceDetails.getUniqueId());
1028 return addArtifactToResourceInstance;
1031 protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
1032 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1033 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
1034 return addInformationalArtifactToResource;
1037 protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ResourceReqDetails resource) throws Exception {
1038 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1039 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, resource.getUniqueId());
1040 return addInformationalArtifactToResource;
1043 // US672293 - Support new artifact type : BEVF_LICENSE , VENDOR_LICENSE
1045 public void addNewArtifactsToVFResource() throws Exception {
1047 String fileName = yangFile;
1048 String artifactName = "artifact1.xml";
1049 String artifactLabel = "Label1";
1050 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1052 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1053 logger.debug("addInformationalArtifactToResource response:{}",addInformationalArtifactToResource.getResponseMessage());
1054 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1055 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1056 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1057 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1058 artifactName = "artifact2.xml";
1059 artifactLabel = "Label2";
1060 artifactType = ArtifactTypeEnum.VF_LICENSE;
1062 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1063 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1064 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1065 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1066 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1067 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1069 artifactName = "artifact3.xml";
1070 artifactLabel = "Label3";
1071 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1072 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1073 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1074 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1075 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1076 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1077 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1079 artifactName = "artifact4.xml";
1080 artifactLabel = "Label4";
1081 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1083 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1084 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1085 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1086 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1087 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1088 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1090 artifactName = "artifact5.xml";
1091 artifactLabel = "Label5";
1092 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1094 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1095 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1096 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1097 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1098 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1099 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1101 artifactName = "artifact6.xml";
1102 artifactLabel = "Label6";
1103 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1105 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1106 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1107 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1108 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1109 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1110 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1112 fileName = jsonFile;
1113 artifactName = "artifact7.json";
1114 artifactLabel = "Label7";
1115 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1117 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1118 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1119 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1120 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1121 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1122 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 2);
1124 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1125 fileName = jsonFile;
1126 artifactName = "artifact8.json";
1127 artifactLabel = "Label8";
1128 artifactType = ArtifactTypeEnum.SNMP_POLL;
1130 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1131 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1132 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1133 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1134 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1135 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1137 fileName = jsonFile;
1138 artifactName = "artifact9.json";
1139 artifactLabel = "Label9";
1140 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1142 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1143 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1144 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1145 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1146 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1147 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1149 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1150 fileName = jsonFile;
1151 artifactName = "artifact8.json";
1152 artifactLabel = "Label8";
1153 artifactType = ArtifactTypeEnum.SNMP_POLL;
1155 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1156 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1157 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1158 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1159 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1160 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1162 fileName = jsonFile;
1163 artifactName = "artifact9.json";
1164 artifactLabel = "Label9";
1165 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1167 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1168 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1169 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1170 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1171 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1172 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1176 public void addNewArtifactsToVFCResource() throws Exception {
1178 String fileName = yangFile;
1179 String artifactName = "artifact1.xml";
1180 String artifactLabel = "Label1";
1181 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1183 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1184 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1185 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1186 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1187 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1188 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1190 artifactName = "artifact2.xml";
1191 artifactLabel = "Label2";
1192 artifactType = ArtifactTypeEnum.VF_LICENSE;
1194 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1195 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1196 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1197 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1198 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1199 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1201 artifactName = "artifact3.xml";
1202 artifactLabel = "Label3";
1203 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1205 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1206 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1207 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1208 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1209 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1210 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1212 artifactName = "artifact4.xml";
1213 artifactLabel = "Label4";
1214 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1216 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1217 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1218 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1219 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1220 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1221 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1223 artifactName = "artifac5.xml";
1224 artifactLabel = "Label5";
1225 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1227 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1228 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1229 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1230 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1231 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1232 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1236 public void addNewArtifactsToVfc() throws Exception {
1237 String fileName = yangFile;
1238 String artifactName = "artifact2.xml";
1239 String artifactLabel = "Label2";
1240 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1241 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1242 logger.debug("addInformationalArtifactToResource response: {}",addDeploymentArtifactToResource.getResponseMessage());
1243 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1244 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1245 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1246 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1247 artifactName = "artifact3.xml";
1248 artifactLabel = "Label3";
1249 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1250 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1251 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1252 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1253 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1254 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1255 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1259 public void addNewArtifactsToCp() throws Exception {
1260 String fileName = yangFile;
1261 String artifactName = "artifact2.xml";
1262 String artifactLabel = "Label2";
1263 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1264 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1265 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1266 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1267 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1268 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1269 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1270 artifactName = "artifact3.xml";
1271 artifactLabel = "Label3";
1272 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1273 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1274 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1275 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1276 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1277 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1278 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1282 public void addNewArtifactsToVl() throws Exception {
1283 String fileName = yangFile;
1284 String artifactName = "artifact2.xml";
1285 String artifactLabel = "Label2";
1286 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1287 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1288 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1289 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1290 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1291 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1292 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1293 artifactName = "artifact3.xml";
1294 artifactLabel = "Label3";
1295 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1296 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1297 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1298 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1299 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1300 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1301 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1305 public void addVfInstanceWithNewArtifactsToService() throws Exception {
1306 String fileName = yangFile;
1307 String artifactName = "artifact2.xml";
1308 String artifactLabel = "Label2";
1309 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1310 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1311 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1312 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1313 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1314 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1315 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1316 artifactName = "artifact3.xml";
1317 artifactLabel = "Label3";
1318 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1319 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1320 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1321 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1322 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1323 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1324 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1326 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1327 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1328 // Add VF instance to service
1329 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1330 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1331 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1332 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1333 // and VENDOR_LICENSE
1334 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1335 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1336 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1337 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VENDOR_LICENSE, 1);
1338 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VF_LICENSE, 1);
1342 public void addNotSupportedArtifactsTypeToService01() throws Exception, Exception {
1343 // Artifact type : VF_LICENSE
1344 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VF_LICENSE.getType());
1345 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1346 assertTrue("response code eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1347 ArrayList<String> variables = new ArrayList<>();
1348 variables.add("VF_LICENSE");
1349 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1353 public void addNotSupportedArtifactsTypeToService02() throws Exception, Exception {
1354 // Artifact type : VENDOR_LICENSE
1355 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VENDOR_LICENSE.getType());
1356 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1357 assertTrue("response code eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1358 ArrayList<String> variables = new ArrayList<>();
1359 variables.add("VENDOR_LICENSE");
1360 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1364 public void addInvalidFileForArtifactTypeVendorLicenseToResource() throws Exception {
1365 String fileName = yangFile;
1366 String NonXmlFile = heatSuccessFile;
1367 String artifactName = "artifact2.xml";
1368 String artifactLabel = "Label2";
1369 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1370 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1371 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1372 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1373 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1374 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1375 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1376 // Artifact type VENDOR_LICENSE must be XML file
1377 artifactName = "artifact3.xml";
1378 artifactLabel = "Label3";
1379 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1380 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1381 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1382 assertTrue("response code 400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1383 ArrayList<String> variables = new ArrayList<>();
1384 variables.add("VENDOR_LICENSE");
1385 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1386 // get resource and verify that file not exist within
1387 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1388 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1389 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1393 public void addInvalidFileForArtifactTypeVfLicenseToResource() throws Exception {
1394 String fileName = yangFile;
1395 String NonXmlFile = heatSuccessFile;
1396 String artifactName = "artifact2.xml";
1397 String artifactLabel = "Label2";
1398 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1399 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1400 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1401 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1402 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1403 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1404 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1405 // Artifact type VF_LICENSE must be XML file
1406 artifactName = "artifact3.xml";
1407 artifactLabel = "Label3";
1408 artifactType = ArtifactTypeEnum.VF_LICENSE;
1409 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1410 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1411 assertTrue("response code 400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1412 ArrayList<String> variables = new ArrayList<>();
1413 variables.add("VF_LICENSE");
1414 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1415 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1416 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1417 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1421 public void addVendorLicenseArtifactAlreadyExistsInResource() throws Exception {
1422 String fileName = yangFile;
1423 String artifactName = "artifact2.xml";
1424 String artifactLabel = "Label2";
1425 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1426 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1427 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1428 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1429 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1430 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1431 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1432 // Add same file again to resource
1433 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1434 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1435 assertTrue("response code is not 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1436 ArrayList<String> variables = new ArrayList<>();
1437 variables.add(artifactLabel.toLowerCase());
1438 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactToResource.getResponse());
1439 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1440 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1441 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1447 public void addVnfCatalogArtifactsToService() throws Exception, Exception {
1449 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VNF_CATALOG.getType());
1450 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1451 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1452 // get service and verify the Artifacts :VNF_CATALOG
1453 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1454 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1455 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1459 public void addModelInventoryProfileArtifactsToService() throws Exception, Exception {
1461 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType());
1462 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1463 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1464 // get service and verify the Artifacts :VNF_CATALOG
1465 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1466 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1467 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1471 public void addModelQuerySpecArtifactsToService() throws Exception, Exception {
1473 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1474 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1475 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1476 // get service and verify the Artifacts :VNF_CATALOG
1477 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1478 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1479 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1483 public void addVfInstanceWithNewArtifactsToService02() throws Exception {
1485 String fileName = yangFile;
1486 String artifactName = "artifact1.xml";
1487 String artifactLabel = "Label1";
1488 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1489 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1490 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1491 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1492 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1493 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1494 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1496 fileName = yangFile;
1497 artifactName = "artifact2.xml";
1498 artifactLabel = "Label2";
1499 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1500 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1501 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1502 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1503 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1504 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1505 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1507 artifactName = "artifact4.xml";
1508 artifactLabel = "Label4";
1509 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1511 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1512 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1513 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1514 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1515 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1516 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1518 artifactName = "artifac5.xml";
1519 artifactLabel = "Label5";
1520 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1522 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1523 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1524 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1525 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1526 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1527 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1529 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1530 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1532 // Add VF instance to service
1533 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1534 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1535 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1537 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1538 // and VENDOR_LICENSE
1539 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1540 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1541 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1542 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1543 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1544 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1545 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.APPC_CONFIG, 1);
1549 public void addAppcConfigArtifactToVfc() throws Exception {
1550 String fileName = jsonFile;
1551 String artifactName = "artifact7.json";
1552 String artifactLabel = "Label7";
1553 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1554 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1555 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1556 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1557 ArrayList<String> variables = new ArrayList<>();
1558 variables.add(artifactName);
1559 variables.add("[VF]");
1560 variables.add("VFC (Virtual Function Component)");
1561 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1562 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1563 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1564 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1568 public void addAppcConfigArtifactToCp() throws Exception {
1569 String fileName = jsonFile;
1570 String artifactName = "artifact7.json";
1571 String artifactLabel = "Label7";
1572 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1573 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1574 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1575 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1576 ArrayList<String> variables = new ArrayList<>();
1577 variables.add(artifactName);
1578 variables.add("[VF]");
1579 variables.add("CP (Connection Point)");
1580 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1581 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1582 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1583 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1587 public void addAppcConfigArtifactToVl() throws Exception {
1588 String fileName = jsonFile;
1589 String artifactName = "artifact7.json";
1590 String artifactLabel = "Label7";
1591 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1592 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1593 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1594 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1595 ArrayList<String> variables = new ArrayList<>();
1596 variables.add(artifactName);
1597 variables.add("[VF]");
1598 variables.add("VL (Virtual Link)");
1599 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1600 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1601 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1602 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1606 public void addAppcConfigArtifactsToService() throws Exception, Exception {
1607 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.APPC_CONFIG.getType());
1608 RestResponse addDeploymentArtifactToResource = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1609 assertTrue("response code 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1610 ArrayList<String> variables = new ArrayList<>();
1611 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1612 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToResource.getResponse());
1616 public void addAppcConfigInvalidJsonToVFResourceFailed() throws Exception {
1618 String fileName = invalidJsonFile;
1619 String artifactName = "invalidJson.json";
1620 String artifactLabel = "Label7";
1621 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1623 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1624 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1625 assertTrue("response code is 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1627 ArrayList<String> variables = new ArrayList<>();
1628 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1629 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_JSON.name(), variables, addInformationalArtifactToResource.getResponse());
1631 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1632 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1633 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1638 public void addNewArtifactsToCp02() throws Exception {
1640 String fileName = yangFile;
1641 String artifactName = "artifact1.xml";
1642 String artifactLabel = "Label1";
1643 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1645 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1646 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1647 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1648 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1649 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1650 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1652 artifactName = "artifact4.xml";
1653 artifactLabel = "Label4";
1654 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1656 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1657 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1658 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1659 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1660 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1661 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1663 artifactName = "artifac5.xml";
1664 artifactLabel = "Label5";
1665 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1667 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1668 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1669 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1670 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1671 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1672 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1676 public void addNewArtifactsToVl02() throws Exception {
1678 String fileName = yangFile;
1679 String artifactName = "artifact1.xml";
1680 String artifactLabel = "Label1";
1681 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1683 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1684 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1685 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1686 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1687 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1688 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1690 artifactName = "artifact4.xml";
1691 artifactLabel = "Label4";
1692 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1694 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1695 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1696 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1697 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1698 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1699 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1701 artifactName = "artifac5.xml";
1702 artifactLabel = "Label5";
1703 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1705 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1706 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1707 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1708 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1709 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1710 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1714 public void addNewArtifactsToVfc02() throws Exception {
1716 String fileName = yangFile;
1717 String artifactName = "artifact1.xml";
1718 String artifactLabel = "Label1";
1719 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1721 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1722 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1723 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1724 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1725 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1726 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1728 artifactName = "artifact4.xml";
1729 artifactLabel = "Label4";
1730 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1732 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1733 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1734 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1735 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1736 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1737 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1739 artifactName = "artifac5.xml";
1740 artifactLabel = "Label5";
1741 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1743 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1744 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1745 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1746 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1747 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1748 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1752 public void addNewArtifactAlreadyExistsInService() throws Exception {
1753 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1754 RestResponse addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1755 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1756 // get service and verify the Artifacts :VNF_CATALOG
1757 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1758 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1759 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1760 // Add same file again to resource
1761 addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1762 assertTrue("response code is 400, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1763 ArrayList<String> variables = new ArrayList<>();
1764 variables.add(artDetails.getArtifactLabel().toLowerCase());
1765 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactoService.getResponse());
1766 // get service and verify the Artifacts :VNF_CATALOG is still exist and
1767 // has one occurrences
1768 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1769 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1770 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1773 private ArtifactReqDetails buildArtifactReqDetailsObject(String filesPath, String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws IOException, Exception {
1774 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(filesPath);
1775 logger.debug("listFileName: {}", listFileName.toString());
1777 String payload = FileUtils.loadPayloadFile(listFileName, artifactFileName, true);
1779 ArtifactReqDetails dcaeArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artifactType.getType());
1780 dcaeArtifactDetails.setPayload(payload);
1781 dcaeArtifactDetails.setArtifactName(artifactName);
1782 dcaeArtifactDetails.setArtifactLabel(artifactLabel);
1783 return dcaeArtifactDetails;