Fix for radio buttons
[sdc.git] / asdc-tests / src / main / java / org / openecomp / sdc / ci / tests / execute / artifacts / CrudArt.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.execute.artifacts;
22
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
25 import static org.testng.AssertJUnit.assertNotNull;
26 import static org.testng.AssertJUnit.assertTrue;
27
28 import java.io.File;
29 import java.io.IOException;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.List;
33 import java.util.Map;
34 import java.util.Map.Entry;
35
36 import org.apache.commons.lang3.tuple.Pair;
37 import org.junit.Rule;
38 import org.junit.rules.TestName;
39 import org.openecomp.sdc.be.dao.api.ActionStatus;
40 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
41 import org.openecomp.sdc.be.model.ArtifactDefinition;
42 import org.openecomp.sdc.be.model.Component;
43 import org.openecomp.sdc.be.model.ComponentInstance;
44 import org.openecomp.sdc.be.model.Resource;
45 import org.openecomp.sdc.be.model.Service;
46 import org.openecomp.sdc.be.model.User;
47 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
48 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
49 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
50 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
53 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
54 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
55 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
56 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
57 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
58 import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
59 import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
60 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
61 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
63 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
64 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
65 import org.openecomp.sdc.ci.tests.utils.validation.ArtifactValidationUtils;
66 import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
67 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
68 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory;
71 import org.testng.annotations.BeforeMethod;
72 import org.testng.annotations.DataProvider;
73 import org.testng.annotations.Test;
74
75 public class CrudArt extends ComponentBaseTest {
76
77         private static Logger logger = LoggerFactory.getLogger(CrudArt.class.getName());
78         private static final User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
79
80         private static final String HEAT_NET_LABEL = "heatnet";
81         private static final String HEAT_LABEL = "heat";
82
83         protected String testResourcesPath;
84         protected String testResourcesInstancesPath;
85
86         protected static final String dcaeInventoryToscaFile = "toscaSampleArtifact.yml";
87         protected static final String dcaeInventoryJsonFile = "jsonSampleArtifact.json";
88         protected static final String dcaeInventoryPolicyFile = "emfSampleArtifact.emf";
89         protected static final String dcaeInventoryDocFile = "docSampleArtifact.doc";
90         protected static final String dcaeInventoryBlueprintFile = "bluePrintSampleArtifact.xml";
91         protected static final String dcaeInventoryEventFile = "eventSampleArtifact.xml";
92
93         protected static final String heatSuccessFile = "asc_heat 0 2.yaml";
94         protected static final String heatNetSuccessFile = "asc_heat_net 0 2.yaml";
95         protected static final String yangFile = "addYangXmlArtifactToResource.xml";
96         protected static final String jsonFile = "jsonArtifact.json";
97         protected static final String invalidJsonFile = "invalidJson.json";
98         protected static final String invalidYangFile = "invalidYangXml.xml";
99         protected static final String otherFile = "other.txt";
100         protected static final String muranoFile = "asc_heat 0 2.zip";
101         protected static final String heatSuccessMiniFile = "heat_mini.yaml";
102         protected static final String heatInvalidFormat = "heatInvalidFormat.yaml";
103         protected static final String yamlInvalidFormat = "invalidYamlFormat.yaml";
104         protected static final String heatEnvfile = "heatEnvfile.env";
105
106         protected ServiceReqDetails serviceDetails;
107         protected ResourceReqDetails vfResourceDetails;
108         protected ResourceReqDetails cpResourceDetails;
109         protected ResourceReqDetails vfcResourceDetails;
110         protected ResourceReqDetails vlResourceDetails;
111
112         @Rule
113         public static TestName name = new TestName();
114
115         public CrudArt() {
116                 super(name, CrudArt.class.getName());
117         }
118
119         @DataProvider
120         private static final Object[][] getDepArtByType() throws IOException, Exception {
121                 return new Object[][] { { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType()) },
122                                 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()) },
123                                 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()) },
124                                 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()) },
125                                 { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()) } };
126         }
127
128         @DataProvider
129         private static final Object[][] getServiceDepArtByType() throws IOException, Exception {
130                 return new Object[][] { { ArtifactTypeEnum.OTHER.getType() }, { ArtifactTypeEnum.YANG_XML.getType() }, };
131         }
132
133         @BeforeMethod
134         public void init() throws Exception {
135                 // Set files working directory
136                 String sourceDir = config.getResourceConfigDir();
137                 String workDir = "HeatDeploymentArtifacts";
138                 testResourcesPath = sourceDir + File.separator + workDir;
139                 String workDirResourceInstanceArtifacts = "ResourceInstanceArtifacts";
140                 testResourcesInstancesPath = sourceDir + File.separator + workDirResourceInstanceArtifacts;
141
142                 // Build the components
143                 Service serviceObj = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
144                 serviceDetails = new ServiceReqDetails(serviceObj);
145
146                 Resource vfcResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
147                 vfcResourceDetails = new ResourceReqDetails(vfcResourceObj);
148
149                 Resource vfResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
150                 vfResourceDetails = new ResourceReqDetails(vfResourceObj);
151
152                 Resource cpResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.CP, UserRoleEnum.DESIGNER, true).left().value();
153                 cpResourceDetails = new ResourceReqDetails(cpResourceObj);
154
155                 Resource vlResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VL, UserRoleEnum.DESIGNER, true).left().value();
156                 vlResourceDetails = new ResourceReqDetails(vlResourceObj);
157         }
158
159         // ---------------------------------Resource
160         // success--------------------------------
161         @Test
162         public void addHeatArtifactToResourceAndCertify() throws Exception {
163
164                 String fileName = heatSuccessFile;
165                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
166                 logger.debug("listFileName: {}", listFileName.toString());
167
168                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
169                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
170                 heatArtifactDetails.setPayload(payload);
171
172                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
173                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
174                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
175
176                 // certified resource
177                 RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
178                 int status = changeResourceState.getErrorCode();
179                 assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
180
181                 Resource resourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(changeResourceState.getResponse());
182                 Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
183                 boolean flag = false;
184                 if (artifactsMap != null) {
185                         for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
186                                 if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
187                                         assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
188                                         flag = true;
189                                         break;
190                                 }
191                         }
192                         assertTrue("expected artifact not found", flag == true);
193                 }
194
195         }
196
197         // ---------------------------------Resource
198         // success--------------------------------
199         @Test
200         public void addDcaeInventoryToscaArtifactToResourceInstanceAndCertify() throws Exception {
201                 String artifactFileName = dcaeInventoryToscaFile;
202                 String artifactName = dcaeInventoryToscaFile;
203                 String artifactLabel = "dcae inv tosca label";
204                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
205                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
206                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
207         }
208
209         @Test
210         public void addDcaeInventoryJsonArtifactToResourceInstanceAndCertify() throws Exception {
211                 String artifactFileName = dcaeInventoryJsonFile;
212                 String artifactName = dcaeInventoryJsonFile;
213                 String artifactLabel = "dcae inv json label";
214                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_JSON;
215                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
216                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
217         }
218
219         @Test
220         public void addDcaeInventoryPolicyArtifactToResourceInstanceAndCertify() throws Exception {
221                 String artifactFileName = dcaeInventoryPolicyFile;
222                 String artifactName = dcaeInventoryPolicyFile;
223                 String artifactLabel = "dcae inv policy label";
224                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_POLICY;
225                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
226                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
227         }
228
229         @Test
230         public void addDcaeInventoryDocArtifactToResourceInstanceAndCertify() throws Exception {
231                 String artifactFileName = dcaeInventoryDocFile;
232                 String artifactName = dcaeInventoryDocFile;
233                 String artifactLabel = "dcae inv doc label";
234                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_DOC;
235                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
236                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
237         }
238
239         @Test
240         public void addDcaeInventoryBluePrintArtifactToResourceInstanceAndCertify() throws Exception {
241                 String artifactFileName = dcaeInventoryBlueprintFile;
242                 String artifactName = dcaeInventoryBlueprintFile;
243                 String artifactLabel = "dcae inv blueprint label";
244                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT;
245                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
246                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
247         }
248
249         @Test
250         public void addDcaeInventoryEventArtifactToResourceInstanceAndCertify() throws Exception {
251                 String artifactFileName = dcaeInventoryEventFile;
252                 String artifactName = dcaeInventoryEventFile;
253                 String artifactLabel = "dcae inv event label";
254                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_EVENT;
255                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
256                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
257         }
258
259         private RestResponse addArtifactToResourceInstanceAndCertify(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
260
261                 // Get the resource
262                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
263                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
264
265                 // Certify VF
266                 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
267                 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
268
269                 // Add VF instance to service
270                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
271                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
272                 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
273
274                 // Get the VF instance
275                 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
276                 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
277                 ComponentInstance VfInstance = service.getComponentInstances().get(0);
278
279                 // Create the artifact
280                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstance(artifactFileName, artifactName, artifactLabel, artifactType, VfInstance, serviceDetails);
281                 logger.debug("addInformationalArtifactToResource response: {}", addArtifactToResourceInstanceResponse.getResponseMessage());
282                 return addArtifactToResourceInstanceResponse;
283         }
284
285         @Test
286         public void updateArtifactDescriptionToResourceInstance() throws Exception {
287                 String artifactFileName = dcaeInventoryToscaFile;
288                 String artifactName = dcaeInventoryToscaFile;
289                 String artifactLabel = "dcae inv tosca label";
290                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
291                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
292                 logger.debug("addInformationalArtifactToResource response: {}", addArtifactToResourceInstanceResponse.getResponseMessage());
293                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
294
295                 // Get the artifact from VF instance and change his description.
296                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
297                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
298                 ComponentInstance vfInstance = service.getComponentInstances().get(0);
299                 Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
300                 ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
301                 artifactDefinition.setDescription("My new description");
302
303                 // Update the artifact
304                 RestResponse updateDeploymentArtifactToRI = ArtifactRestUtils.updateArtifactToResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
305                 logger.debug("addInformationalArtifactToResource response: {}", updateDeploymentArtifactToRI.getResponseMessage());
306                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateDeploymentArtifactToRI.getErrorCode(), updateDeploymentArtifactToRI.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
307         }
308
309         @Test
310         public void deleteArtifactToResourceInstance() throws Exception {
311                 String artifactFileName = dcaeInventoryToscaFile;
312                 String artifactName = dcaeInventoryToscaFile;
313                 String artifactLabel = "dcae inv tosca label";
314                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
315                 RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
316                 logger.debug("addInformationalArtifactToResource response:  {}", addArtifactToResourceInstanceResponse.getResponseMessage());
317                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
318
319                 // Get the artifact from VF instance and change his description.
320                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
321                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
322                 ComponentInstance vfInstance = service.getComponentInstances().get(0);
323                 Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
324                 ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
325
326                 // Delete the artifact
327                 RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteArtifactFromResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
328                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
329         }
330
331         @Test
332         public void addHeatArtifactToResource() throws Exception {
333
334                 String fileName = heatSuccessFile;
335                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
336                 logger.debug("listFileName: {}", listFileName);
337
338                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
339                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
340                 heatArtifactDetails.setPayload(payload);
341
342                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
343                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
344                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
345
346         }
347
348         @Test
349         public void addHeatAndHeatNetArtifactsToResource() throws Exception {
350
351                 String fileName = heatSuccessFile;
352                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
353
354                 // Add HEAT
355                 logger.debug("listFileName: {}", listFileName);
356                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
357                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
358                 heatArtifactDetails.setPayload(payload);
359
360                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
361                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
362                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
363
364                 // Add HEAT_NET
365                 String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
366                 ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
367                 heatNetArtifactDetails.setPayload(payloadNet);
368                 heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
369
370                 RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
371                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource1.getResponseMessage());
372                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource1.getErrorCode(), addInformationalArtifactToResource1.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
373
374                 RestResponse resourceGetResponse = ResourceRestUtils.getResource(vfResourceDetails, sdncDesignerDetails1);
375                 Resource resourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
376                 Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
377
378                 ArtifactDefinition artifactDefinition = deploymentArtifacts.get(HEAT_LABEL);
379                 assertNotNull(artifactDefinition);
380                 String heatEsId = artifactDefinition.getEsId();
381                 assertNotNull(heatEsId);
382
383                 ArtifactDefinition artifactDefinitionNet = deploymentArtifacts.get(HEAT_NET_LABEL);
384                 assertNotNull(artifactDefinitionNet);
385                 String heatNetEsId = artifactDefinitionNet.getEsId();
386                 assertNotNull(heatNetEsId);
387                 assertFalse(heatEsId.equalsIgnoreCase(heatNetEsId));
388         }
389
390         @Test
391         public void addDeleteAddHeatArtifactToResource() throws Exception {
392
393                 String fileName = heatSuccessFile;
394                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
395                 logger.debug("listFileName: {}", listFileName.toString());
396
397                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
398                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
399                 heatArtifactDetails.setPayload(payload);
400
401                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
402                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
403                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
404
405                 RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteInformationalArtifactFromResource(vfResourceDetails.getUniqueId(), heatArtifactDetails, sdncDesignerDetails1);
406                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
407
408                 addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
409                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
410                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
411         }
412
413         @Test
414         public void addYangXmlArtifactToResource() throws Exception {
415
416                 String fileName = yangFile;
417                 String artifactName = "asc_heat 0 2.XML";
418                 String artifactLabel = "Label";
419                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
420
421                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
422                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
423                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
424                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
425                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
426                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
427         }
428
429         @Test
430         public void addOtherTypeDeploymentArtifactToResource() throws Exception {
431
432                 String fileName = otherFile;
433                 String artifactName = "other.txt";
434                 String artifactLabel = "Label";
435                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.OTHER;
436
437                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
438                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
439                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
440                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
441                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
442                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
443         }
444
445         @Test
446         public void addYangXmlArtifactSameName() throws Exception {
447
448                 String fileName = yangFile;
449                 String artifactName = "asc_heat_0_2.XML";
450                 String artifactLabel = "Label";
451                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
452
453                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
454                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
455                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
456                 // Changing label but not name
457                 artifactLabel = "Label1";
458                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
459                 assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
460                 BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, new String[] { "Resource", vfResourceDetails.getName(), artifactName });
461
462                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
463                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
464                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
465         }
466
467         @Test
468         public void addInvalidYangXmlFormat() throws Exception {
469
470                 String fileName = invalidYangFile;
471                 String artifactName = "asc_heat_0_2.XML";
472                 String artifactLabel = "Label";
473                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
474
475                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
476                 assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
477                 BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.INVALID_XML, new String[] { "YANG_XML" });
478
479         }
480
481         @Test
482         public void addSeveralYangXmlArtifacts() throws Exception {
483
484                 // Adding 4 artifacts
485                 String fileName = yangFile;
486                 String artifactName = "asc_heat_0_2.XML";
487                 String artifactLabel = "Label";
488                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
489
490                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
491                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
492                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
493                 // Changing label and name
494                 artifactLabel = "Label1";
495                 artifactName = "asc_heat_0_3.XML";
496                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
497                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
498
499                 // Changing label and name
500                 artifactLabel = "Label2";
501                 artifactName = "asc_heat_0_4.XML";
502                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
503
504                 // Changing label and name
505                 artifactLabel = "Label3";
506                 artifactName = "asc_heat_0_5.XML";
507                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
508                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
509
510                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
511                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
512                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 4);
513         }
514
515         @Test(dataProvider = "getDepArtByType")
516         public void updateHeatArtifactToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
517
518                 String fileName = heatSuccessFile;
519                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
520                 logger.debug("listFileName: {}", listFileName.toString());
521
522                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
523                 heatTypeArtifactDetails.setPayload(payload);
524
525                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
526                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
527                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
528
529                 // update
530                 heatTypeArtifactDetails.setArtifactName("UPDATE.yaml");
531                 heatTypeArtifactDetails.setPayloadData(null);
532                 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
533                 logger.debug("addInformationalArtifactToResource response: {}", updateInformationalArtifactToResource.getResponseMessage());
534                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
535
536         }
537
538         @Test(dataProvider = "getDepArtByType")
539         public void updateHeatArtifactTimeOutToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
540
541                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
542                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
543                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
544
545                 Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
546                 int actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
547                 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
548
549                 // update
550                 heatTypeArtifactDetails.setTimeout(35);
551                 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
552                 logger.debug("addInformationalArtifactToResource response: {}", updateInformationalArtifactToResource.getResponseMessage());
553                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
554
555                 resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
556                 actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
557                 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
558         }
559
560         @Test(dataProvider = "getDepArtByType")
561         public void updateHeatArtifactDescriptionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
562
563                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
564                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
565                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
566
567                 Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
568                 String actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
569                 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
570
571                 // update
572                 heatTypeArtifactDetails.setDescription("the best description was ever");
573                 RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
574                 logger.debug("addInformationalArtifactToResource response: {}", updateInformationalArtifactToResource.getResponseMessage());
575                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
576
577                 resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
578                 actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
579                 assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
580         }
581
582         private Resource getResourceByResDetails(ResourceReqDetails resDetails, User userDetails) throws IOException {
583                 RestResponse response = ResourceRestUtils.getResource(resDetails, userDetails);
584                 assertTrue("response code on get resource not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + response.getErrorCode(), response.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
585                 Resource resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
586                 return resource;
587         }
588
589         // ---------------------------------Service
590         // success--------------------------------
591         @Test()
592         public void addAllTypesDepArtifactToService() throws Exception {
593                 ArtifactReqDetails otherArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
594
595                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(otherArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
596                 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
597                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
598
599                 ArtifactReqDetails yangXmlArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
600
601                 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(yangXmlArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
602                 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
603                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
604
605         }
606
607         @Test(enabled = false)
608         public void addMuranoPkgArtifactToService() throws Exception, Exception {
609
610                 String fileName = muranoFile;
611                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
612                 logger.debug("listFileName: {}", listFileName);
613
614                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
615                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MURANO_PKG.getType());
616                 heatArtifactDetails.setPayload(payload);
617                 heatArtifactDetails.setArtifactName("asc_heat 0 2.zip");
618                 heatArtifactDetails.setArtifactLabel("Label");
619
620                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
621                 logger.debug("addInformationalArtifactToService response:  {}", addInformationalArtifactToService.getResponseMessage());
622                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
623
624         }
625
626         @Test(dataProvider = "getServiceDepArtByType")
627         public void addHeatArtifactToServiceAndCertify(String artType) throws Exception, Exception {
628
629                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
630
631                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
632                 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
633                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
634
635                 // certified service
636                 RestResponse changeServiceState = LifecycleRestUtils.certifyService(serviceDetails);
637                 int status = changeServiceState.getErrorCode();
638                 assertEquals("certify service request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
639
640                 Service resourceJavaObject = ResponseParser.convertServiceResponseToJavaObject(changeServiceState.getResponse());
641                 Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
642                 boolean flag = false;
643                 if (artifactsMap != null) {
644                         for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
645                                 if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
646                                         assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
647                                         flag = true;
648                                         break;
649                                 }
650                         }
651                         assertTrue("expected artifact not found", flag == true);
652                 }
653
654         }
655
656         @Test(enabled = false, dataProvider = "getServiceDepArtByType")
657         public void updateHeatArtifactToService(String artType) throws Exception, Exception {
658
659                 String fileName = heatSuccessFile;
660                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
661                 logger.debug("listFileName: {}", listFileName.toString());
662
663                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
664                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
665
666                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
667                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToService.getResponseMessage());
668                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
669
670                 // update
671                 heatArtifactDetails.setPayloadData(payload);
672                 RestResponse updateInformationalArtifactToService = ArtifactRestUtils.updateInformationalArtifactOfServiceByMethod(heatArtifactDetails, serviceDetails.getUniqueId(), sdncDesignerDetails1, "POST");
673                 logger.debug("updateInformationalArtifactToService response:  {}", updateInformationalArtifactToService.getResponseMessage());
674                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToService.getErrorCode(), updateInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
675
676         }
677
678         // --------------------------------------Resource Negative
679         // Tests-------------------------------------
680
681         // TODO Andrey the method of DEPLOYMENT artifact is update and not add
682         @Test(dataProvider = "getServiceDepArtByType")
683         public void addTheSameAdditionalHeatArtifactToResource(String artType) throws Exception, Exception {
684
685                 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
686
687                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
688                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
689
690                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
691
692                 // add the same artifact one more time
693                 artifactDetails.setArtifactLabel("the second artifact");
694                 addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
695
696                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
697                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
698
699                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), artifactDetails.getArtifactName());
700                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
701
702         }
703
704         @Test
705         public void addHeatArtifactTwiceSameNameToResource() throws Exception, Exception {
706
707                 String filename1 = heatSuccessFile;
708                 // String filename2 = heatSuccessMiniFile;
709                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
710                 logger.debug("listFileName: {}", listFileName);
711
712                 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
713
714                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
715                 heatArtifactDetails.setPayload(payload);
716
717                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
718
719                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
720
721                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
722
723                 // Add HEAT_NET
724                 String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
725                 ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
726                 heatNetArtifactDetails.setPayload(payloadNet);
727                 heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
728                 heatNetArtifactDetails.setArtifactName(heatArtifactDetails.getArtifactName());
729
730                 RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
731                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource1.getResponseMessage());
732
733                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
734                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource1.getErrorCode());
735
736                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatNetArtifactDetails.getArtifactName());
737                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource1.getResponse());
738
739         }
740
741         @Test(dataProvider = "getDepArtByType")
742         public void addHeatArtifactTwiceToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
743
744                 String filename1 = heatSuccessFile;
745                 String filename2 = heatSuccessMiniFile;
746                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
747                 logger.debug("listFileName: {}", listFileName);
748
749                 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
750                 heatTypeArtifactDetails.setPayload(payload);
751
752                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
753                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
754                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
755
756                 // add the second artifact
757                 payload = FileUtils.loadPayloadFile(listFileName, heatSuccessMiniFile, true);
758                 heatTypeArtifactDetails.setPayload(payload);
759                 heatTypeArtifactDetails.setArtifactName(filename2);
760                 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
761
762                 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
763                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
764                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
765
766                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
767                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
768
769         }
770
771         @Test(dataProvider = "getDepArtByType")
772         public void addHeatArtifactInvalidHeatFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
773
774                 String fileName = heatInvalidFormat;
775                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
776                 logger.debug("listFileName: {}", listFileName);
777
778                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
779                 heatTypeArtifactDetails.setPayload(payload);
780
781                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
782                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
783
784                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
785                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
786
787                 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
788                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToResource.getResponse());
789
790         }
791
792         @Test(dataProvider = "getDepArtByType")
793         public void addHeatArtifactInvalidYamlFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
794
795                 String fileName = yamlInvalidFormat;
796                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
797                 logger.debug("listFileName: {}", listFileName);
798
799                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
800                 heatTypeArtifactDetails.setPayload(payload);
801
802                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
803                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
804
805                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
806                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
807
808                 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
809                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToResource.getResponse());
810
811         }
812
813         @Test(dataProvider = "getDepArtByType")
814         public void addHeatArtifactInvalidFileExtensionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
815
816                 String fileName = yangFile;
817                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
818                 logger.debug("listFileName: {}", listFileName);
819
820                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
821
822                 heatTypeArtifactDetails.setPayload(payload);
823                 heatTypeArtifactDetails.setArtifactName(fileName);
824
825                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
826                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
827
828                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
829                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
830
831                 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
832                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToResource.getResponse());
833
834         }
835
836         @Test(dataProvider = "getDepArtByType")
837         public void addHeatArtifactToResourceCertifyAndAddAdditionalHeatArtifact(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
838
839                 String fileName = heatSuccessFile;
840                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
841                 logger.debug("listFileName: {}", listFileName);
842
843                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
844                 heatTypeArtifactDetails.setPayload(payload);
845
846                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
847
848                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
849                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
850
851                 // certified resource
852                 RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
853                 int status = changeResourceState.getErrorCode();
854                 assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
855
856                 // add second HEAT artifact to the certified resource
857                 changeResourceState = LifecycleRestUtils.changeResourceState(vfResourceDetails, sdncDesignerDetails1, LifeCycleStatesEnum.CHECKOUT);
858                 assertTrue("expected code response on change resource state to CHECKOUT BaseRestUtils.STATUS_CODE_SUCCESS, but was " + changeResourceState.getErrorCode(), changeResourceState.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
859
860                 // ArtifactReqDetails heatArtifactDetails1 =
861                 // ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
862                 heatTypeArtifactDetails.setPayload(payload);
863                 heatTypeArtifactDetails.setArtifactName(fileName);
864                 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
865
866                 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
867
868                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
869                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
870
871                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
872                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
873
874         }
875
876         // -----------------Service Negative
877         // Tests--------------------------------------------------------
878
879         // Absolute
880         @Test(enabled = false)
881         public void addHeatArtifactTwiceToService() throws Exception, Exception {
882
883                 String fileName1 = heatSuccessFile;
884                 String fileName2 = heatSuccessMiniFile;
885                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
886                 logger.debug("listFileName: {}", listFileName);
887
888                 String payload = FileUtils.loadPayloadFile(listFileName, fileName1, true);
889                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
890                 heatArtifactDetails.setPayload(payload);
891
892                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
893                 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
894                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
895
896                 // add the second artifact
897                 payload = FileUtils.loadPayloadFile(listFileName, fileName2, true);
898
899                 ArtifactReqDetails heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
900                 heatArtifactDetails1.setPayload(payload);
901                 heatArtifactDetails1.setArtifactName(fileName2);
902                 heatArtifactDetails1.setArtifactLabel("the second artifact");
903
904                 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails1, sdncDesignerDetails1, serviceDetails.getUniqueId());
905                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
906                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
907
908                 List<String> variables = Arrays.asList("Service", serviceDetails.getName(), ArtifactTypeEnum.OTHER.getType(), ArtifactTypeEnum.OTHER.getType());
909                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToService.getResponse());
910
911         }
912
913         // TODO Andrey Obsolete
914         @Test(enabled = false)
915         public void addHeatArtifactInvalidHeatFormatToService() throws Exception, Exception {
916
917                 String fileName = heatInvalidFormat;
918                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
919                 logger.debug("listFileName: {}", listFileName);
920
921                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
922
923                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
924                 heatArtifactDetails.setPayload(payload);
925
926                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
927                 logger.debug("addInformationalArtifactToService response: {}", addInformationalArtifactToService.getResponseMessage());
928
929                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
930                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
931
932                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
933                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToService.getResponse());
934
935         }
936
937         @Test(enabled = false)
938         public void addHeatArtifactInvalidYamlFormatToService() throws Exception, Exception {
939
940                 String fileName = yamlInvalidFormat;
941                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
942                 logger.debug("listFileName: {}", listFileName);
943
944                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
945
946                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
947                 heatArtifactDetails.setPayload(payload);
948
949                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
950                 logger.debug("addInformationalArtifactToService response: {} ", addInformationalArtifactToService.getResponseMessage());
951
952                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
953                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
954
955                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
956                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToService.getResponse());
957
958         }
959
960         @Test
961         public void addHeatArtifactInvalidFileExtensionToService() throws Exception, Exception {
962
963                 String fileName = muranoFile;
964                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
965                 logger.debug("listFileName: {}", listFileName);
966
967                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
968
969                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
970                 heatArtifactDetails.setPayload(payload);
971                 heatArtifactDetails.setArtifactName(fileName);
972
973                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
974                 logger.debug("addInformationalArtifactToService response: {} ", addInformationalArtifactToService.getResponseMessage());
975
976                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
977                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
978
979                 List<String> variables = Arrays.asList(ArtifactTypeEnum.YANG_XML.getType());
980                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToService.getResponse());
981
982         }
983
984         @Test(dataProvider = "getDepArtByType")
985         public void addHeatEnvArtifactToResourceNotSupportedType(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
986
987                 String fileName = heatEnvfile;
988                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
989                 logger.debug("listFileName: {}", listFileName.toString());
990
991                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
992
993                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_ENV.getType());
994                 heatArtifactDetails.setPayload(payload);
995                 heatArtifactDetails.setArtifactName("asc_heat 0 2.env");
996                 heatArtifactDetails.setArtifactLabel(heatTypeArtifactDetails.getArtifactLabel());
997
998                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
999                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
1000                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
1001
1002                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT_ENV.getType());
1003                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToResource.getResponse());
1004         }
1005
1006         // TODO Andrey
1007         @Test
1008         public void addHeatArtifactToServiceNotSupportDeploymentArt() throws Exception, Exception {
1009
1010                 String fileName = heatSuccessFile;
1011                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
1012                 logger.debug("listFileName: {}", listFileName);
1013
1014                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
1015
1016                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
1017                 heatArtifactDetails.setPayload(payload);
1018
1019                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1020                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
1021                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
1022
1023                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
1024                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToService.getResponse());
1025
1026         }
1027
1028         protected RestResponse addArtifactToResourceInstance(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ComponentInstance componentInstance, ServiceReqDetails serviceDetails) throws Exception {
1029                 ArtifactReqDetails dcaeArtifactDetails = buildArtifactReqDetailsObject(testResourcesInstancesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1030                 RestResponse addArtifactToResourceInstance = ArtifactRestUtils.addArtifactToResourceInstance(dcaeArtifactDetails, sdncDesignerDetails1, componentInstance.getUniqueId(), serviceDetails.getUniqueId());
1031                 return addArtifactToResourceInstance;
1032         }
1033
1034         protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
1035                 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1036                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
1037                 return addInformationalArtifactToResource;
1038         }
1039
1040         protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ResourceReqDetails resource) throws Exception {
1041                 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1042                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, resource.getUniqueId());
1043                 return addInformationalArtifactToResource;
1044         }
1045
1046         // US672293 - Support new artifact type : BEVF_LICENSE , VENDOR_LICENSE
1047         @Test
1048         public void addNewArtifactsToVFResource() throws Exception {
1049
1050                 String fileName = yangFile;
1051                 String artifactName = "artifact1.xml";
1052                 String artifactLabel = "Label1";
1053                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1054
1055                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1056                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1057                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1058                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1059                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1060                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1061                 artifactName = "artifact2.xml";
1062                 artifactLabel = "Label2";
1063                 artifactType = ArtifactTypeEnum.VF_LICENSE;
1064
1065                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1066                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1067                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1068                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1069                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1070                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1071
1072                 artifactName = "artifact3.xml";
1073                 artifactLabel = "Label3";
1074                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1075                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1076                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1077                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1078                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1079                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1080                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1081
1082                 artifactName = "artifact4.xml";
1083                 artifactLabel = "Label4";
1084                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1085
1086                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1087                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1088                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1089                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1090                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1091                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1092
1093                 artifactName = "artifact5.xml";
1094                 artifactLabel = "Label5";
1095                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1096
1097                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1098                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1099                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1100                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1101                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1102                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1103
1104                 artifactName = "artifact6.xml";
1105                 artifactLabel = "Label6";
1106                 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1107
1108                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1109                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1110                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1111                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1112                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1113                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1114
1115                 fileName = jsonFile;
1116                 artifactName = "artifact7.json";
1117                 artifactLabel = "Label7";
1118                 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1119
1120                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1121                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1122                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1123                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1124                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1125                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 2);
1126                 
1127                 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1128                 fileName = jsonFile;
1129                 artifactName = "artifact8.json";
1130                 artifactLabel = "Label8";
1131                 artifactType = ArtifactTypeEnum.SNMP_POLL;
1132
1133                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1134                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1135                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1136                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1137                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1138                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1139                 
1140                 fileName = jsonFile;
1141                 artifactName = "artifact9.json";
1142                 artifactLabel = "Label9";
1143                 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1144
1145                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1146                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1147                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1148                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1149                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1150                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1151
1152                 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1153                 fileName = jsonFile;
1154                 artifactName = "artifact8.json";
1155                 artifactLabel = "Label8";
1156                 artifactType = ArtifactTypeEnum.SNMP_POLL;
1157
1158                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1159                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1160                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1161                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1162                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1163                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1164                 
1165                 fileName = jsonFile;
1166                 artifactName = "artifact9.json";
1167                 artifactLabel = "Label9";
1168                 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1169
1170                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1171                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1172                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1173                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1174                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1175                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1176         }
1177
1178         @Test
1179         public void addNewArtifactsToVFCResource() throws Exception {
1180
1181                 String fileName = yangFile;
1182                 String artifactName = "artifact1.xml";
1183                 String artifactLabel = "Label1";
1184                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1185
1186                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1187                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1188                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1189                 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1190                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1191                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1192
1193                 artifactName = "artifact2.xml";
1194                 artifactLabel = "Label2";
1195                 artifactType = ArtifactTypeEnum.VF_LICENSE;
1196
1197                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1198                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1199                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1200                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1201                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1202                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1203
1204                 artifactName = "artifact3.xml";
1205                 artifactLabel = "Label3";
1206                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1207
1208                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1209                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1210                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1211                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1212                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1213                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1214
1215                 artifactName = "artifact4.xml";
1216                 artifactLabel = "Label4";
1217                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1218
1219                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1220                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1221                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1222                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1223                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1224                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1225
1226                 artifactName = "artifac5.xml";
1227                 artifactLabel = "Label5";
1228                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1229
1230                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1231                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1232                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1233                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1234                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1235                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1236         }
1237
1238         @Test
1239         public void addNewArtifactsToVfc() throws Exception {
1240                 String fileName = yangFile;
1241                 String artifactName = "artifact2.xml";
1242                 String artifactLabel = "Label2";
1243                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1244                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1245                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1246                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1247                 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1248                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1249                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1250                 artifactName = "artifact3.xml";
1251                 artifactLabel = "Label3";
1252                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1253                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1254                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1255                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1256                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1257                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1258                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1259         }
1260
1261         @Test
1262         public void addNewArtifactsToCp() throws Exception {
1263                 String fileName = yangFile;
1264                 String artifactName = "artifact2.xml";
1265                 String artifactLabel = "Label2";
1266                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1267                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1268                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1269                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1270                 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1271                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1272                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1273                 artifactName = "artifact3.xml";
1274                 artifactLabel = "Label3";
1275                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1276                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1277                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1278                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1279                 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1280                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1281                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1282         }
1283
1284         @Test
1285         public void addNewArtifactsToVl() throws Exception {
1286                 String fileName = yangFile;
1287                 String artifactName = "artifact2.xml";
1288                 String artifactLabel = "Label2";
1289                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1290                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1291                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1292                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1293                 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1294                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1295                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1296                 artifactName = "artifact3.xml";
1297                 artifactLabel = "Label3";
1298                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1299                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1300                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1301                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1302                 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1303                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1304                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1305         }
1306
1307         @Test
1308         public void addVfInstanceWithNewArtifactsToService() throws Exception {
1309                 String fileName = yangFile;
1310                 String artifactName = "artifact2.xml";
1311                 String artifactLabel = "Label2";
1312                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1313                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1314                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1315                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1316                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1317                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1318                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1319                 artifactName = "artifact3.xml";
1320                 artifactLabel = "Label3";
1321                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1322                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1323                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1324                 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1325                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1326                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1327                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1328                 // Certify VF
1329                 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1330                 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1331                 // Add VF instance to service
1332                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1333                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1334                 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1335                 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1336                 // and VENDOR_LICENSE
1337                 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1338                 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1339                 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1340                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VENDOR_LICENSE, 1);
1341                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VF_LICENSE, 1);
1342         }
1343
1344         @Test
1345         public void addNotSupportedArtifactsTypeToService01() throws Exception, Exception {
1346                 // Artifact type : VF_LICENSE
1347                 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VF_LICENSE.getType());
1348                 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1349                 assertTrue("response code  eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1350                 ArrayList<String> variables = new ArrayList<>();
1351                 variables.add("VF_LICENSE");
1352                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1353         }
1354
1355         @Test
1356         public void addNotSupportedArtifactsTypeToService02() throws Exception, Exception {
1357                 // Artifact type : VENDOR_LICENSE
1358                 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VENDOR_LICENSE.getType());
1359                 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1360                 assertTrue("response code  eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1361                 ArrayList<String> variables = new ArrayList<>();
1362                 variables.add("VENDOR_LICENSE");
1363                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1364         }
1365
1366         @Test
1367         public void addInvalidFileForArtifactTypeVendorLicenseToResource() throws Exception {
1368                 String fileName = yangFile;
1369                 String NonXmlFile = heatSuccessFile;
1370                 String artifactName = "artifact2.xml";
1371                 String artifactLabel = "Label2";
1372                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1373                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1374                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1375                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1376                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1377                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1378                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1379                 // Artifact type VENDOR_LICENSE must be XML file
1380                 artifactName = "artifact3.xml";
1381                 artifactLabel = "Label3";
1382                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1383                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1384                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1385                 assertTrue("response code  400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1386                 ArrayList<String> variables = new ArrayList<>();
1387                 variables.add("VENDOR_LICENSE");
1388                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1389                 // get resource and verify that file not exist within
1390                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1391                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1392                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1393         }
1394
1395         @Test
1396         public void addInvalidFileForArtifactTypeVfLicenseToResource() throws Exception {
1397                 String fileName = yangFile;
1398                 String NonXmlFile = heatSuccessFile;
1399                 String artifactName = "artifact2.xml";
1400                 String artifactLabel = "Label2";
1401                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1402                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1403                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1404                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1405                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1406                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1407                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1408                 // Artifact type VF_LICENSE must be XML file
1409                 artifactName = "artifact3.xml";
1410                 artifactLabel = "Label3";
1411                 artifactType = ArtifactTypeEnum.VF_LICENSE;
1412                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1413                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1414                 assertTrue("response code  400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1415                 ArrayList<String> variables = new ArrayList<>();
1416                 variables.add("VF_LICENSE");
1417                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1418                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1419                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1420                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1421         }
1422
1423         @Test
1424         public void addVendorLicenseArtifactAlreadyExistsInResource() throws Exception {
1425                 String fileName = yangFile;
1426                 String artifactName = "artifact2.xml";
1427                 String artifactLabel = "Label2";
1428                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1429                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1430                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1431                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1432                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1433                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1434                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1435                 // Add same file again to resource
1436                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1437                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1438                 assertTrue("response code is not 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1439                 ArrayList<String> variables = new ArrayList<>();
1440                 variables.add(artifactLabel.toLowerCase());
1441                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactToResource.getResponse());
1442                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1443                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1444                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1445         }
1446
1447         // US672294
1448
1449         @Test()
1450         public void addVnfCatalogArtifactsToService() throws Exception, Exception {
1451
1452                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VNF_CATALOG.getType());
1453                 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1454                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1455                 // get service and verify the Artifacts :VNF_CATALOG
1456                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1457                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1458                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1459         }
1460
1461         @Test()
1462         public void addModelInventoryProfileArtifactsToService() throws Exception, Exception {
1463
1464                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType());
1465                 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1466                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1467                 // get service and verify the Artifacts :VNF_CATALOG
1468                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1469                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1470                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1471         }
1472
1473         @Test()
1474         public void addModelQuerySpecArtifactsToService() throws Exception, Exception {
1475
1476                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1477                 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1478                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1479                 // get service and verify the Artifacts :VNF_CATALOG
1480                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1481                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1482                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1483         }
1484
1485         @Test
1486         public void addVfInstanceWithNewArtifactsToService02() throws Exception {
1487
1488                 String fileName = yangFile;
1489                 String artifactName = "artifact1.xml";
1490                 String artifactLabel = "Label1";
1491                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1492                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1493                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1494                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1495                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1496                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1497                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1498
1499                 fileName = yangFile;
1500                 artifactName = "artifact2.xml";
1501                 artifactLabel = "Label2";
1502                 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1503                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1504                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1505                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1506                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1507                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1508                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1509
1510                 artifactName = "artifact4.xml";
1511                 artifactLabel = "Label4";
1512                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1513
1514                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1515                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1516                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1517                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1518                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1519                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1520
1521                 artifactName = "artifac5.xml";
1522                 artifactLabel = "Label5";
1523                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1524
1525                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1526                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1527                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1528                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1529                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1530                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1531                 // Certify VF
1532                 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1533                 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1534
1535                 // Add VF instance to service
1536                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1537                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1538                 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1539
1540                 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1541                 // and VENDOR_LICENSE
1542                 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1543                 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1544                 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1545                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1546                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1547                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1548                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.APPC_CONFIG, 1);
1549         }
1550
1551         @Test
1552         public void addAppcConfigArtifactToVfc() throws Exception {
1553                 String fileName = jsonFile;
1554                 String artifactName = "artifact7.json";
1555                 String artifactLabel = "Label7";
1556                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1557                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1558                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1559                 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1560                 ArrayList<String> variables = new ArrayList<>();
1561                 variables.add(artifactName);
1562                 variables.add("[VF]");
1563                 variables.add("VFC (Virtual Function Component)");
1564                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1565                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1566                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1567                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1568         }
1569
1570         @Test
1571         public void addAppcConfigArtifactToCp() throws Exception {
1572                 String fileName = jsonFile;
1573                 String artifactName = "artifact7.json";
1574                 String artifactLabel = "Label7";
1575                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1576                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1577                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1578                 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1579                 ArrayList<String> variables = new ArrayList<>();
1580                 variables.add(artifactName);
1581                 variables.add("[VF]");
1582                 variables.add("CP (Connection Point)");
1583                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1584                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1585                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1586                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1587         }
1588
1589         @Test
1590         public void addAppcConfigArtifactToVl() throws Exception {
1591                 String fileName = jsonFile;
1592                 String artifactName = "artifact7.json";
1593                 String artifactLabel = "Label7";
1594                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1595                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1596                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1597                 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1598                 ArrayList<String> variables = new ArrayList<>();
1599                 variables.add(artifactName);
1600                 variables.add("[VF]");
1601                 variables.add("VL (Virtual Link)");
1602                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1603                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1604                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1605                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1606         }
1607
1608         @Test()
1609         public void addAppcConfigArtifactsToService() throws Exception, Exception {
1610                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.APPC_CONFIG.getType());
1611                 RestResponse addDeploymentArtifactToResource = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1612                 assertTrue("response code 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1613                 ArrayList<String> variables = new ArrayList<>();
1614                 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1615                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToResource.getResponse());
1616         }
1617
1618         @Test
1619         public void addAppcConfigInvalidJsonToVFResourceFailed() throws Exception {
1620
1621                 String fileName = invalidJsonFile;
1622                 String artifactName = "invalidJson.json";
1623                 String artifactLabel = "Label7";
1624                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1625
1626                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1627                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1628                 assertTrue("response code is 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1629
1630                 ArrayList<String> variables = new ArrayList<>();
1631                 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1632                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_JSON.name(), variables, addInformationalArtifactToResource.getResponse());
1633
1634                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1635                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1636                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1637
1638         }
1639
1640         @Test
1641         public void addNewArtifactsToCp02() throws Exception {
1642
1643                 String fileName = yangFile;
1644                 String artifactName = "artifact1.xml";
1645                 String artifactLabel = "Label1";
1646                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1647
1648                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1649                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1650                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1651                 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1652                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1653                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1654
1655                 artifactName = "artifact4.xml";
1656                 artifactLabel = "Label4";
1657                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1658
1659                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1660                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1661                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1662                 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1663                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1664                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1665
1666                 artifactName = "artifac5.xml";
1667                 artifactLabel = "Label5";
1668                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1669
1670                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1671                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1672                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1673                 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1674                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1675                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1676         }
1677
1678         @Test
1679         public void addNewArtifactsToVl02() throws Exception {
1680
1681                 String fileName = yangFile;
1682                 String artifactName = "artifact1.xml";
1683                 String artifactLabel = "Label1";
1684                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1685
1686                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1687                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1688                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1689                 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1690                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1691                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1692
1693                 artifactName = "artifact4.xml";
1694                 artifactLabel = "Label4";
1695                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1696
1697                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1698                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1699                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1700                 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1701                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1702                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1703
1704                 artifactName = "artifac5.xml";
1705                 artifactLabel = "Label5";
1706                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1707
1708                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1709                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1710                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1711                 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1712                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1713                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1714         }
1715
1716         @Test
1717         public void addNewArtifactsToVfc02() throws Exception {
1718
1719                 String fileName = yangFile;
1720                 String artifactName = "artifact1.xml";
1721                 String artifactLabel = "Label1";
1722                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1723
1724                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1725                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1726                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1727                 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1728                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1729                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1730
1731                 artifactName = "artifact4.xml";
1732                 artifactLabel = "Label4";
1733                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1734
1735                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1736                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1737                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1738                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1739                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1740                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1741
1742                 artifactName = "artifac5.xml";
1743                 artifactLabel = "Label5";
1744                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1745
1746                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1747                 logger.debug("addInformationalArtifactToResource response:  {}", addInformationalArtifactToResource.getResponseMessage());
1748                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1749                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1750                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1751                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1752         }
1753
1754         @Test
1755         public void addNewArtifactAlreadyExistsInService() throws Exception {
1756                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1757                 RestResponse addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1758                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1759                 // get service and verify the Artifacts :VNF_CATALOG
1760                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1761                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1762                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1763                 // Add same file again to resource
1764                 addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1765                 assertTrue("response code is 400, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1766                 ArrayList<String> variables = new ArrayList<>();
1767                 variables.add(artDetails.getArtifactLabel().toLowerCase());
1768                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactoService.getResponse());
1769                 // get service and verify the Artifacts :VNF_CATALOG is still exist and
1770                 // has one occurrences
1771                 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1772                 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1773                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1774         }
1775
1776         private ArtifactReqDetails buildArtifactReqDetailsObject(String filesPath, String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws IOException, Exception {
1777                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(filesPath);
1778                 logger.debug("listFileName: {}", listFileName);
1779
1780                 String payload = FileUtils.loadPayloadFile(listFileName, artifactFileName, true);
1781
1782                 ArtifactReqDetails dcaeArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artifactType.getType());
1783                 dcaeArtifactDetails.setPayload(payload);
1784                 dcaeArtifactDetails.setArtifactName(artifactName);
1785                 dcaeArtifactDetails.setArtifactLabel(artifactLabel);
1786                 return dcaeArtifactDetails;
1787         }
1788
1789 }