[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / 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.toString());
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.toString());
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, Exception {
593
594                 // String fileName = heatSuccessFile;
595                 // List<String> listFileName =
596                 // FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
597                 // logger.debug("listFileName: {}",listFileName.toString());
598
599                 // String payload = FileUtils.loadPayloadFile(listFileName, fileName,
600                 // true);
601                 ArtifactReqDetails otherArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
602                 // otherArtifactDetails.setPayload(payload);
603
604                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(otherArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
605                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
606                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
607
608                 ArtifactReqDetails yangXmlArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
609
610                 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(yangXmlArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
611                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
612                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
613
614         }
615
616         @Test(enabled = false)
617         public void addMuranoPkgArtifactToService() throws Exception, Exception {
618
619                 String fileName = muranoFile;
620                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
621                 logger.debug("listFileName: {}" ,listFileName.toString());
622
623                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
624                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MURANO_PKG.getType());
625                 heatArtifactDetails.setPayload(payload);
626                 heatArtifactDetails.setArtifactName("asc_heat 0 2.zip");
627                 heatArtifactDetails.setArtifactLabel("Label");
628
629                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
630                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
631                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
632
633         }
634
635         @Test(dataProvider = "getServiceDepArtByType")
636         public void addHeatArtifactToServiceAndCertify(String artType) throws Exception, Exception {
637
638                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
639
640                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
641                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
642                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
643
644                 // certified service
645                 RestResponse changeServiceState = LifecycleRestUtils.certifyService(serviceDetails);
646                 int status = changeServiceState.getErrorCode();
647                 assertEquals("certify service request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
648
649                 Service resourceJavaObject = ResponseParser.convertServiceResponseToJavaObject(changeServiceState.getResponse());
650                 Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
651                 boolean flag = false;
652                 if (artifactsMap != null) {
653                         for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
654                                 if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
655                                         assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
656                                         flag = true;
657                                         break;
658                                 }
659                         }
660                         assertTrue("expected artifact not found", flag == true);
661                 }
662
663         }
664
665         @Test(enabled = false, dataProvider = "getServiceDepArtByType")
666         public void updateHeatArtifactToService(String artType) throws Exception, Exception {
667
668                 String fileName = heatSuccessFile;
669                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
670                 logger.debug("listFileName: {}",listFileName.toString());
671
672                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
673                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
674
675                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
676                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToService.getResponseMessage());
677                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
678
679                 // update
680                 heatArtifactDetails.setPayloadData(payload);
681                 RestResponse updateInformationalArtifactToService = ArtifactRestUtils.updateInformationalArtifactOfServiceByMethod(heatArtifactDetails, serviceDetails.getUniqueId(), sdncDesignerDetails1, "POST");
682                 logger.debug("updateInformationalArtifactToService response: {}",updateInformationalArtifactToService.getResponseMessage());
683                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToService.getErrorCode(), updateInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
684
685         }
686
687         // --------------------------------------Resource Negative
688         // Tests-------------------------------------
689
690         // TODO Andrey the method of DEPLOYMENT artifact is update and not add
691         @Test(dataProvider = "getServiceDepArtByType")
692         public void addTheSameAdditionalHeatArtifactToResource(String artType) throws Exception, Exception {
693
694                 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
695
696                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
697                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
698
699                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
700
701                 // add the same artifact one more time
702                 artifactDetails.setArtifactLabel("the second artifact");
703                 addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
704
705                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
706                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
707
708                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), artifactDetails.getArtifactName());
709                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
710
711         }
712
713         @Test
714         public void addHeatArtifactTwiceSameNameToResource() throws Exception, Exception {
715
716                 String filename1 = heatSuccessFile;
717                 // String filename2 = heatSuccessMiniFile;
718                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
719                 logger.debug("listFileName: {}",listFileName.toString());
720
721                 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
722
723                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
724                 heatArtifactDetails.setPayload(payload);
725
726                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
727
728                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
729
730                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
731
732                 // Add HEAT_NET
733                 String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
734                 ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
735                 heatNetArtifactDetails.setPayload(payloadNet);
736                 heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
737                 heatNetArtifactDetails.setArtifactName(heatArtifactDetails.getArtifactName());
738
739                 RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
740                 logger.debug("addInformationalArtifactToResource response: {}" ,addInformationalArtifactToResource1.getResponseMessage());
741
742                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
743                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource1.getErrorCode());
744
745                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatNetArtifactDetails.getArtifactName());
746                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource1.getResponse());
747
748         }
749
750         @Test(dataProvider = "getDepArtByType")
751         public void addHeatArtifactTwiceToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
752
753                 String filename1 = heatSuccessFile;
754                 String filename2 = heatSuccessMiniFile;
755                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
756                 logger.debug("listFileName: {}",listFileName.toString());
757
758                 String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
759                 heatTypeArtifactDetails.setPayload(payload);
760
761                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
762                 logger.debug("addInformationalArtifactToResource response: {}" ,addInformationalArtifactToResource.getResponseMessage());
763                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
764
765                 // add the second artifact
766                 payload = FileUtils.loadPayloadFile(listFileName, heatSuccessMiniFile, true);
767                 heatTypeArtifactDetails.setPayload(payload);
768                 heatTypeArtifactDetails.setArtifactName(filename2);
769                 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
770
771                 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
772                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
773                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
774
775                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
776                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
777
778         }
779
780         @Test(dataProvider = "getDepArtByType")
781         public void addHeatArtifactInvalidHeatFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
782
783                 String fileName = heatInvalidFormat;
784                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
785                 logger.debug("listFileName: {}",listFileName.toString());
786
787                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
788                 heatTypeArtifactDetails.setPayload(payload);
789
790                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
791                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
792
793                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
794                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
795
796                 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
797                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToResource.getResponse());
798
799         }
800
801         @Test(dataProvider = "getDepArtByType")
802         public void addHeatArtifactInvalidYamlFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
803
804                 String fileName = yamlInvalidFormat;
805                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
806                 logger.debug("listFileName: {}",listFileName.toString());
807
808                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
809                 heatTypeArtifactDetails.setPayload(payload);
810
811                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
812                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
813
814                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
815                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
816
817                 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
818                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToResource.getResponse());
819
820         }
821
822         @Test(dataProvider = "getDepArtByType")
823         public void addHeatArtifactInvalidFileExtensionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
824
825                 String fileName = yangFile;
826                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
827                 logger.debug("listFileName: {}",listFileName.toString());
828
829                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
830
831                 heatTypeArtifactDetails.setPayload(payload);
832                 heatTypeArtifactDetails.setArtifactName(fileName);
833
834                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
835                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
836
837                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
838                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
839
840                 List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
841                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToResource.getResponse());
842
843         }
844
845         @Test(dataProvider = "getDepArtByType")
846         public void addHeatArtifactToResourceCertifyAndAddAdditionalHeatArtifact(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
847
848                 String fileName = heatSuccessFile;
849                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
850                 logger.debug("listFileName: {}",listFileName.toString());
851
852                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
853                 heatTypeArtifactDetails.setPayload(payload);
854
855                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
856
857                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
858                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
859
860                 // certified resource
861                 RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
862                 int status = changeResourceState.getErrorCode();
863                 assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
864
865                 // add second HEAT artifact to the certified resource
866                 changeResourceState = LifecycleRestUtils.changeResourceState(vfResourceDetails, sdncDesignerDetails1, LifeCycleStatesEnum.CHECKOUT);
867                 assertTrue("expected code response on change resource state to CHECKOUT BaseRestUtils.STATUS_CODE_SUCCESS, but was " + changeResourceState.getErrorCode(), changeResourceState.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
868
869                 // ArtifactReqDetails heatArtifactDetails1 =
870                 // ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
871                 heatTypeArtifactDetails.setPayload(payload);
872                 heatTypeArtifactDetails.setArtifactName(fileName);
873                 heatTypeArtifactDetails.setArtifactLabel("the second artifact");
874
875                 addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
876
877                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
878                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
879
880                 List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
881                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
882
883         }
884
885         // -----------------Service Negative
886         // Tests--------------------------------------------------------
887
888         // Absolute
889         @Test(enabled = false)
890         public void addHeatArtifactTwiceToService() throws Exception, Exception {
891
892                 String fileName1 = heatSuccessFile;
893                 String fileName2 = heatSuccessMiniFile;
894                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
895                 logger.debug("listFileName: {}",listFileName.toString());
896
897                 String payload = FileUtils.loadPayloadFile(listFileName, fileName1, true);
898                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
899                 heatArtifactDetails.setPayload(payload);
900
901                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
902                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
903                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
904
905                 // add the second artifact
906                 payload = FileUtils.loadPayloadFile(listFileName, fileName2, true);
907
908                 ArtifactReqDetails heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
909                 heatArtifactDetails1.setPayload(payload);
910                 heatArtifactDetails1.setArtifactName(fileName2);
911                 heatArtifactDetails1.setArtifactLabel("the second artifact");
912
913                 addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails1, sdncDesignerDetails1, serviceDetails.getUniqueId());
914                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
915                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
916
917                 List<String> variables = Arrays.asList("Service", serviceDetails.getName(), ArtifactTypeEnum.OTHER.getType(), ArtifactTypeEnum.OTHER.getType());
918                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToService.getResponse());
919
920         }
921
922         // TODO Andrey Obsolete
923         @Test(enabled = false)
924         public void addHeatArtifactInvalidHeatFormatToService() throws Exception, Exception {
925
926                 String fileName = heatInvalidFormat;
927                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
928                 logger.debug("listFileName: {}",listFileName.toString());
929
930                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
931
932                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
933                 heatArtifactDetails.setPayload(payload);
934
935                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
936                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
937
938                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
939                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
940
941                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
942                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToService.getResponse());
943
944         }
945
946         // TODO Andrey Obsolete
947         @Test(enabled = false)
948         public void addHeatArtifactInvalidYamlFormatToService() throws Exception, Exception {
949
950                 String fileName = yamlInvalidFormat;
951                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
952                 logger.debug("listFileName: {}",listFileName.toString());
953
954                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
955
956                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
957                 heatArtifactDetails.setPayload(payload);
958
959                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
960                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
961
962                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
963                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
964
965                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
966                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToService.getResponse());
967
968         }
969
970         @Test
971         public void addHeatArtifactInvalidFileExtensionToService() throws Exception, Exception {
972
973                 String fileName = muranoFile;
974                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
975                 logger.debug("listFileName: {}",listFileName.toString());
976
977                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
978
979                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
980                 heatArtifactDetails.setPayload(payload);
981                 heatArtifactDetails.setArtifactName(fileName);
982
983                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
984                 logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
985
986                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
987                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
988
989                 List<String> variables = Arrays.asList(ArtifactTypeEnum.YANG_XML.getType());
990                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToService.getResponse());
991
992         }
993
994         @Test(dataProvider = "getDepArtByType")
995         public void addHeatEnvArtifactToResourceNotSupportedType(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
996
997                 String fileName = heatEnvfile;
998                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
999                 logger.debug("listFileName: {}",listFileName.toString());
1000
1001                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
1002
1003                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_ENV.getType());
1004                 heatArtifactDetails.setPayload(payload);
1005                 heatArtifactDetails.setArtifactName("asc_heat 0 2.env");
1006                 heatArtifactDetails.setArtifactLabel(heatTypeArtifactDetails.getArtifactLabel());
1007
1008                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
1009                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
1010                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
1011
1012                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT_ENV.getType());
1013                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToResource.getResponse());
1014         }
1015
1016         // TODO Andrey
1017         @Test
1018         public void addHeatArtifactToServiceNotSupportDeploymentArt() throws Exception, Exception {
1019
1020                 String fileName = heatSuccessFile;
1021                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
1022                 logger.debug("listFileName: {}",listFileName.toString());
1023
1024                 String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
1025
1026                 ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
1027                 heatArtifactDetails.setPayload(payload);
1028
1029                 RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1030                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
1031                 assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
1032
1033                 List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
1034                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToService.getResponse());
1035
1036         }
1037
1038         protected RestResponse addArtifactToResourceInstance(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ComponentInstance componentInstance, ServiceReqDetails serviceDetails) throws Exception {
1039                 ArtifactReqDetails dcaeArtifactDetails = buildArtifactReqDetailsObject(testResourcesInstancesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1040                 RestResponse addArtifactToResourceInstance = ArtifactRestUtils.addArtifactToResourceInstance(dcaeArtifactDetails, sdncDesignerDetails1, componentInstance.getUniqueId(), serviceDetails.getUniqueId());
1041                 return addArtifactToResourceInstance;
1042         }
1043
1044         protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
1045                 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1046                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
1047                 return addInformationalArtifactToResource;
1048         }
1049
1050         protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ResourceReqDetails resource) throws Exception {
1051                 ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
1052                 RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, resource.getUniqueId());
1053                 return addInformationalArtifactToResource;
1054         }
1055
1056         // US672293 - Support new artifact type : BEVF_LICENSE , VENDOR_LICENSE
1057         @Test
1058         public void addNewArtifactsToVFResource() throws Exception {
1059
1060                 String fileName = yangFile;
1061                 String artifactName = "artifact1.xml";
1062                 String artifactLabel = "Label1";
1063                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1064
1065                 RestResponse 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                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1069                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1070                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1071                 artifactName = "artifact2.xml";
1072                 artifactLabel = "Label2";
1073                 artifactType = ArtifactTypeEnum.VF_LICENSE;
1074
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 = "artifact3.xml";
1083                 artifactLabel = "Label3";
1084                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1085                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1086                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1087                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1088                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1089                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1090                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1091
1092                 artifactName = "artifact4.xml";
1093                 artifactLabel = "Label4";
1094                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1095
1096                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1097                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1098                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1099                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1100                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1101                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1102
1103                 artifactName = "artifact5.xml";
1104                 artifactLabel = "Label5";
1105                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1106
1107                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1108                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1109                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1110                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1111                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1112                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1113
1114                 artifactName = "artifact6.xml";
1115                 artifactLabel = "Label6";
1116                 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1117
1118                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1119                 logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
1120                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1121                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1122                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1123                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1124
1125                 fileName = jsonFile;
1126                 artifactName = "artifact7.json";
1127                 artifactLabel = "Label7";
1128                 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1129
1130                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1131                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1132                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1133                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1134                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1135                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 2);
1136                 
1137                 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1138                 fileName = jsonFile;
1139                 artifactName = "artifact8.json";
1140                 artifactLabel = "Label8";
1141                 artifactType = ArtifactTypeEnum.SNMP_POLL;
1142
1143                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1144                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1145                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1146                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1147                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1148                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1149                 
1150                 fileName = jsonFile;
1151                 artifactName = "artifact9.json";
1152                 artifactLabel = "Label9";
1153                 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1154
1155                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1156                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1157                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1158                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1159                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1160                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1161
1162                 //MIB artifacts: SNMP_POLL, SNMP_TRAP
1163                 fileName = jsonFile;
1164                 artifactName = "artifact8.json";
1165                 artifactLabel = "Label8";
1166                 artifactType = ArtifactTypeEnum.SNMP_POLL;
1167
1168                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1169                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1170                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1171                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1172                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1173                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1174                 
1175                 fileName = jsonFile;
1176                 artifactName = "artifact9.json";
1177                 artifactLabel = "Label9";
1178                 artifactType = ArtifactTypeEnum.SNMP_TRAP;
1179
1180                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1181                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1182                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1183                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1184                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1185                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1186         }
1187
1188         @Test
1189         public void addNewArtifactsToVFCResource() throws Exception {
1190
1191                 String fileName = yangFile;
1192                 String artifactName = "artifact1.xml";
1193                 String artifactLabel = "Label1";
1194                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1195
1196                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1197                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1198                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1199                 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1200                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1201                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1202
1203                 artifactName = "artifact2.xml";
1204                 artifactLabel = "Label2";
1205                 artifactType = ArtifactTypeEnum.VF_LICENSE;
1206
1207                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1208                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1209                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1210                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1211                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1212                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1213
1214                 artifactName = "artifact3.xml";
1215                 artifactLabel = "Label3";
1216                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1217
1218                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1219                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1220                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1221                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1222                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1223                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1224
1225                 artifactName = "artifact4.xml";
1226                 artifactLabel = "Label4";
1227                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1228
1229                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1230                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1231                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1232                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1233                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1234                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1235
1236                 artifactName = "artifac5.xml";
1237                 artifactLabel = "Label5";
1238                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1239
1240                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1241                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1242                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1243                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1244                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1245                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1246         }
1247
1248         @Test
1249         public void addNewArtifactsToVfc() throws Exception {
1250                 String fileName = yangFile;
1251                 String artifactName = "artifact2.xml";
1252                 String artifactLabel = "Label2";
1253                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1254                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1255                 logger.debug("addInformationalArtifactToResource response: {}",addDeploymentArtifactToResource.getResponseMessage());
1256                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1257                 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1258                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1259                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1260                 artifactName = "artifact3.xml";
1261                 artifactLabel = "Label3";
1262                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1263                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1264                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1265                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1266                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1267                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1268                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1269         }
1270
1271         @Test
1272         public void addNewArtifactsToCp() throws Exception {
1273                 String fileName = yangFile;
1274                 String artifactName = "artifact2.xml";
1275                 String artifactLabel = "Label2";
1276                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1277                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1278                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1279                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1280                 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1281                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1282                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1283                 artifactName = "artifact3.xml";
1284                 artifactLabel = "Label3";
1285                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1286                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1287                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1288                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1289                 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1290                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1291                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1292         }
1293
1294         @Test
1295         public void addNewArtifactsToVl() throws Exception {
1296                 String fileName = yangFile;
1297                 String artifactName = "artifact2.xml";
1298                 String artifactLabel = "Label2";
1299                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1300                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1301                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1302                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1303                 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1304                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1305                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1306                 artifactName = "artifact3.xml";
1307                 artifactLabel = "Label3";
1308                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1309                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1310                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1311                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1312                 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1313                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1314                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1315         }
1316
1317         @Test
1318         public void addVfInstanceWithNewArtifactsToService() throws Exception {
1319                 String fileName = yangFile;
1320                 String artifactName = "artifact2.xml";
1321                 String artifactLabel = "Label2";
1322                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1323                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1324                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1325                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1326                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1327                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1328                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1329                 artifactName = "artifact3.xml";
1330                 artifactLabel = "Label3";
1331                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1332                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1333                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1334                 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1335                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1336                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1337                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1338                 // Certify VF
1339                 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1340                 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1341                 // Add VF instance to service
1342                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1343                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1344                 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1345                 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1346                 // and VENDOR_LICENSE
1347                 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1348                 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1349                 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1350                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VENDOR_LICENSE, 1);
1351                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VF_LICENSE, 1);
1352         }
1353
1354         @Test
1355         public void addNotSupportedArtifactsTypeToService01() throws Exception, Exception {
1356                 // Artifact type : VF_LICENSE
1357                 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VF_LICENSE.getType());
1358                 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1359                 assertTrue("response code  eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1360                 ArrayList<String> variables = new ArrayList<>();
1361                 variables.add("VF_LICENSE");
1362                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1363         }
1364
1365         @Test
1366         public void addNotSupportedArtifactsTypeToService02() throws Exception, Exception {
1367                 // Artifact type : VENDOR_LICENSE
1368                 ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VENDOR_LICENSE.getType());
1369                 RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1370                 assertTrue("response code  eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1371                 ArrayList<String> variables = new ArrayList<>();
1372                 variables.add("VENDOR_LICENSE");
1373                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
1374         }
1375
1376         @Test
1377         public void addInvalidFileForArtifactTypeVendorLicenseToResource() throws Exception {
1378                 String fileName = yangFile;
1379                 String NonXmlFile = heatSuccessFile;
1380                 String artifactName = "artifact2.xml";
1381                 String artifactLabel = "Label2";
1382                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
1383                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1384                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1385                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1386                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1387                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1388                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1389                 // Artifact type VENDOR_LICENSE must be XML file
1390                 artifactName = "artifact3.xml";
1391                 artifactLabel = "Label3";
1392                 artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1393                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1394                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1395                 assertTrue("response code  400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1396                 ArrayList<String> variables = new ArrayList<>();
1397                 variables.add("VENDOR_LICENSE");
1398                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1399                 // get resource and verify that file not exist within
1400                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1401                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1402                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1403         }
1404
1405         @Test
1406         public void addInvalidFileForArtifactTypeVfLicenseToResource() throws Exception {
1407                 String fileName = yangFile;
1408                 String NonXmlFile = heatSuccessFile;
1409                 String artifactName = "artifact2.xml";
1410                 String artifactLabel = "Label2";
1411                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1412                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1413                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1414                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1415                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1416                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1417                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1418                 // Artifact type VF_LICENSE must be XML file
1419                 artifactName = "artifact3.xml";
1420                 artifactLabel = "Label3";
1421                 artifactType = ArtifactTypeEnum.VF_LICENSE;
1422                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
1423                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1424                 assertTrue("response code  400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1425                 ArrayList<String> variables = new ArrayList<>();
1426                 variables.add("VF_LICENSE");
1427                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
1428                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1429                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1430                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1431         }
1432
1433         @Test
1434         public void addVendorLicenseArtifactAlreadyExistsInResource() throws Exception {
1435                 String fileName = yangFile;
1436                 String artifactName = "artifact2.xml";
1437                 String artifactLabel = "Label2";
1438                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
1439                 RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1440                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1441                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1442                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1443                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1444                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1445                 // Add same file again to resource
1446                 addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1447                 logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
1448                 assertTrue("response code is not 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1449                 ArrayList<String> variables = new ArrayList<>();
1450                 variables.add(artifactLabel.toLowerCase());
1451                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactToResource.getResponse());
1452                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1453                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1454                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1455         }
1456
1457         // US672294
1458
1459         @Test()
1460         public void addVnfCatalogArtifactsToService() throws Exception, Exception {
1461
1462                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VNF_CATALOG.getType());
1463                 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1464                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1465                 // get service and verify the Artifacts :VNF_CATALOG
1466                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1467                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1468                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1469         }
1470
1471         @Test()
1472         public void addModelInventoryProfileArtifactsToService() throws Exception, Exception {
1473
1474                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType());
1475                 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1476                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1477                 // get service and verify the Artifacts :VNF_CATALOG
1478                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1479                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1480                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1481         }
1482
1483         @Test()
1484         public void addModelQuerySpecArtifactsToService() throws Exception, Exception {
1485
1486                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1487                 RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1488                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1489                 // get service and verify the Artifacts :VNF_CATALOG
1490                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1491                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1492                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1493         }
1494
1495         @Test
1496         public void addVfInstanceWithNewArtifactsToService02() throws Exception {
1497
1498                 String fileName = yangFile;
1499                 String artifactName = "artifact1.xml";
1500                 String artifactLabel = "Label1";
1501                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1502                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1503                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1504                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1505                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1506                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1507                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1508
1509                 fileName = yangFile;
1510                 artifactName = "artifact2.xml";
1511                 artifactLabel = "Label2";
1512                 artifactType = ArtifactTypeEnum.APPC_CONFIG;
1513                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1514                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1515                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1516                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1517                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1518                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1519
1520                 artifactName = "artifact4.xml";
1521                 artifactLabel = "Label4";
1522                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1523
1524                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1525                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1526                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1527                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1528                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1529                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1530
1531                 artifactName = "artifac5.xml";
1532                 artifactLabel = "Label5";
1533                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1534
1535                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1536                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1537                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1538                 getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1539                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1540                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1541                 // Certify VF
1542                 Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1543                 assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1544
1545                 // Add VF instance to service
1546                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1547                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1548                 AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
1549
1550                 // get service and verify VF instance contain the Artifacts :VF_LICENSE
1551                 // and VENDOR_LICENSE
1552                 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1553                 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1554                 ComponentInstance VfInstance = service.getComponentInstances().get(0);
1555                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
1556                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
1557                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1558                 ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.APPC_CONFIG, 1);
1559         }
1560
1561         @Test
1562         public void addAppcConfigArtifactToVfc() throws Exception {
1563                 String fileName = jsonFile;
1564                 String artifactName = "artifact7.json";
1565                 String artifactLabel = "Label7";
1566                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1567                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1568                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1569                 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1570                 ArrayList<String> variables = new ArrayList<>();
1571                 variables.add(artifactName);
1572                 variables.add("[VF]");
1573                 variables.add("VFC (Virtual Function Component)");
1574                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1575                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1576                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1577                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1578         }
1579
1580         @Test
1581         public void addAppcConfigArtifactToCp() throws Exception {
1582                 String fileName = jsonFile;
1583                 String artifactName = "artifact7.json";
1584                 String artifactLabel = "Label7";
1585                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1586                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1587                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1588                 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1589                 ArrayList<String> variables = new ArrayList<>();
1590                 variables.add(artifactName);
1591                 variables.add("[VF]");
1592                 variables.add("CP (Connection Point)");
1593                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1594                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1595                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1596                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1597         }
1598
1599         @Test
1600         public void addAppcConfigArtifactToVl() throws Exception {
1601                 String fileName = jsonFile;
1602                 String artifactName = "artifact7.json";
1603                 String artifactLabel = "Label7";
1604                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1605                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1606                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1607                 assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1608                 ArrayList<String> variables = new ArrayList<>();
1609                 variables.add(artifactName);
1610                 variables.add("[VF]");
1611                 variables.add("VL (Virtual Link)");
1612                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
1613                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1614                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1615                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1616         }
1617
1618         @Test()
1619         public void addAppcConfigArtifactsToService() throws Exception, Exception {
1620                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.APPC_CONFIG.getType());
1621                 RestResponse addDeploymentArtifactToResource = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1622                 assertTrue("response code 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1623                 ArrayList<String> variables = new ArrayList<>();
1624                 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1625                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToResource.getResponse());
1626         }
1627
1628         @Test
1629         public void addAppcConfigInvalidJsonToVFResourceFailed() throws Exception {
1630
1631                 String fileName = invalidJsonFile;
1632                 String artifactName = "invalidJson.json";
1633                 String artifactLabel = "Label7";
1634                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
1635
1636                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
1637                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1638                 assertTrue("response code is 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1639
1640                 ArrayList<String> variables = new ArrayList<>();
1641                 variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
1642                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_JSON.name(), variables, addInformationalArtifactToResource.getResponse());
1643
1644                 RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
1645                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1646                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
1647
1648         }
1649
1650         @Test
1651         public void addNewArtifactsToCp02() throws Exception {
1652
1653                 String fileName = yangFile;
1654                 String artifactName = "artifact1.xml";
1655                 String artifactLabel = "Label1";
1656                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1657
1658                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1659                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1660                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1661                 RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1662                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1663                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1664
1665                 artifactName = "artifact4.xml";
1666                 artifactLabel = "Label4";
1667                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1668
1669                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1670                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1671                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1672                 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1673                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1674                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1675
1676                 artifactName = "artifac5.xml";
1677                 artifactLabel = "Label5";
1678                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1679
1680                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
1681                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1682                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1683                 getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
1684                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1685                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1686         }
1687
1688         @Test
1689         public void addNewArtifactsToVl02() throws Exception {
1690
1691                 String fileName = yangFile;
1692                 String artifactName = "artifact1.xml";
1693                 String artifactLabel = "Label1";
1694                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1695
1696                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1697                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1698                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1699                 RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1700                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1701                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1702
1703                 artifactName = "artifact4.xml";
1704                 artifactLabel = "Label4";
1705                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1706
1707                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1708                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1709                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1710                 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1711                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1712                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1713
1714                 artifactName = "artifac5.xml";
1715                 artifactLabel = "Label5";
1716                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1717
1718                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
1719                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1720                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1721                 getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
1722                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1723                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1724         }
1725
1726         @Test
1727         public void addNewArtifactsToVfc02() throws Exception {
1728
1729                 String fileName = yangFile;
1730                 String artifactName = "artifact1.xml";
1731                 String artifactLabel = "Label1";
1732                 ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
1733
1734                 RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1735                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1736                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1737                 RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1738                 Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1739                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1740
1741                 artifactName = "artifact4.xml";
1742                 artifactLabel = "Label4";
1743                 artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
1744
1745                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1746                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1747                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1748                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1749                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1750                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1751
1752                 artifactName = "artifac5.xml";
1753                 artifactLabel = "Label5";
1754                 artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
1755
1756                 addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
1757                 logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
1758                 assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1759                 getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
1760                 resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
1761                 ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
1762         }
1763
1764         @Test
1765         public void addNewArtifactAlreadyExistsInService() throws Exception {
1766                 ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
1767                 RestResponse addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1768                 assertTrue("response code is  BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1769                 // get service and verify the Artifacts :VNF_CATALOG
1770                 RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1771                 Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1772                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1773                 // Add same file again to resource
1774                 addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
1775                 assertTrue("response code is 400, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
1776                 ArrayList<String> variables = new ArrayList<>();
1777                 variables.add(artDetails.getArtifactLabel().toLowerCase());
1778                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactoService.getResponse());
1779                 // get service and verify the Artifacts :VNF_CATALOG is still exist and
1780                 // has one occurrences
1781                 getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
1782                 service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
1783                 ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
1784         }
1785
1786         private ArtifactReqDetails buildArtifactReqDetailsObject(String filesPath, String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws IOException, Exception {
1787                 List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(filesPath);
1788                 logger.debug("listFileName: {}", listFileName.toString());
1789
1790                 String payload = FileUtils.loadPayloadFile(listFileName, artifactFileName, true);
1791
1792                 ArtifactReqDetails dcaeArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artifactType.getType());
1793                 dcaeArtifactDetails.setPayload(payload);
1794                 dcaeArtifactDetails.setArtifactName(artifactName);
1795                 dcaeArtifactDetails.setArtifactLabel(artifactLabel);
1796                 return dcaeArtifactDetails;
1797         }
1798
1799 }