re base code
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / resource / UpdateResourceMetadataTest.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.resource;
22
23 import com.google.gson.Gson;
24 import org.json.JSONException;
25 import org.json.JSONObject;
26 import org.junit.rules.TestName;
27 import org.openecomp.sdc.be.dao.api.ActionStatus;
28 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
29 import org.openecomp.sdc.be.model.LifecycleStateEnum;
30 import org.openecomp.sdc.be.model.Resource;
31 import org.openecomp.sdc.be.model.User;
32 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
33 import org.openecomp.sdc.ci.tests.api.Urls;
34 import org.openecomp.sdc.ci.tests.config.Config;
35 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.*;
37 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
38 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
40 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
41 import org.openecomp.sdc.ci.tests.utils.DbUtils;
42 import org.openecomp.sdc.ci.tests.utils.Utils;
43 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
44 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
45 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
46 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
47 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
48 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
49 import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
50 import org.openecomp.sdc.common.util.ValidationUtils;
51 import org.slf4j.Logger;
52 import org.slf4j.LoggerFactory;
53 import org.testng.AssertJUnit;
54 import org.testng.annotations.BeforeMethod;
55 import org.testng.annotations.Test;
56
57 import java.io.FileNotFoundException;
58 import java.util.*;
59
60 import static org.testng.AssertJUnit.*;
61
62 public class UpdateResourceMetadataTest extends ComponentBaseTest {
63     private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
64     protected List<String> Empty_List = new ArrayList<String>();
65     protected String extendedChars;
66
67     protected final String contentTypeHeaderData = "application/json";
68     protected final String acceptHeaderDate = "application/json";
69     protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
70
71     public static TestName name = new TestName();
72     protected User sdncModifierDetails;
73     protected ResourceReqDetails resourceDetails;
74
75     public UpdateResourceMetadataTest() {
76         super(name, UpdateResourceMetadataTest.class.getName());
77
78     }
79
80     public String extendedCharsStringBuilder() throws Exception {
81         char[] extendedCharsArray = new char[128];
82         char ch = 128;
83         for (int i = 0; i < extendedCharsArray.length - 1; i++) {
84             extendedCharsArray[i] = ch;
85             ch++;
86         }
87         extendedChars = new String(extendedCharsArray);
88         return extendedChars;
89
90     }
91
92     @BeforeMethod
93     public void setup() throws Exception {
94         sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
95         resourceDetails = defineResourse();
96
97     }
98
99     // Keep
100     @Test
101     public void UpdateDerivedFromSuccess() throws Exception {
102
103         String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
104         String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
105
106         // Getting both derived from resources for validation
107         /*
108                  * RestResponse resourceByNameAndVersion =
109                  * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
110                  * oldDerivedFromName, "1.0");
111                  * assertEquals("Check response code after get database normative", 200,
112                  * resourceByNameAndVersion.getErrorCode().intValue()); Resource
113                  * databaseNormative =
114                  * resourceUtils.parseResourceResp(resourceByNameAndVersion);
115                  * 
116                  * resourceByNameAndVersion =
117                  * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
118                  * newDerivedFromName, "1.0");
119                  * assertEquals("Check response code after get database normative", 200,
120                  * resourceByNameAndVersion.getErrorCode().intValue()); Resource
121                  * lbNormative =
122                  * resourceUtils.parseResourceResp(resourceByNameAndVersion);
123                  */
124
125         // Derived from set to Database
126         List<String> derivedFrom = new ArrayList<>();
127         derivedFrom.add(oldDerivedFromName);
128         resourceDetails.setDerivedFrom(derivedFrom);
129
130         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
131         AssertJUnit.assertEquals("Check response code after create resource", 201,
132                 restResponse.getErrorCode().intValue());
133         Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
134
135         derivedFrom.clear();
136         derivedFrom.add(newDerivedFromName);
137         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
138                 sdncModifierDetails, currentResource.getUniqueId(), "");
139         AssertJUnit.assertEquals("Check response code after create resource", 200,
140                 updatedRestResponse.getErrorCode().intValue());
141
142     }
143
144     protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
145         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
146
147         updatedResourceDetails.setVersion("mumu");
148         updatedResourceDetails.setIsAbstract(true);
149         updatedResourceDetails.setIsHighestVersion(true);
150         updatedResourceDetails.setCreatorUserId("df4444");
151         updatedResourceDetails.setCreatorFullName("John Doe");
152         updatedResourceDetails.setLastUpdaterUserId("gf5646");
153         updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
154         updatedResourceDetails.setCreationDate(new Long(4444));
155         updatedResourceDetails.setLastUpdateDate(new Long("534535"));
156         updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
157         updatedResourceDetails.setCost("6.1");
158         updatedResourceDetails.setLicenseType("Installation");
159         updatedResourceDetails.setUUID("dfsfsdf");
160         return updatedResourceDetails;
161     }
162
163     public void UpdateResourceNotFoundTest() throws Exception {
164         // init ADMIN user
165         User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
166
167         String resourceName = "cisco4";
168         // update resource
169         String description = "updatedDescription";
170         ArrayList<String> resourceTags = new ArrayList<String>();
171         resourceTags.add("tag2");
172         String category = ServiceCategoriesEnum.MOBILITY.getValue();
173         ArrayList<String> derivedFrom = new ArrayList<String>();
174         derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
175         String vendorName = "newOracle";
176         String vendorRelease = "2.5";
177         String contactId = "jh0003";
178         String icon = "myICON";
179
180         ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags,
181                 category, derivedFrom, vendorName, vendorRelease, contactId, icon);
182         updatedResourceDetails.setUniqueId("dummyId");
183         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
184                 sdncModifierDetails, "0.1");
185
186         // validate response
187         AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
188         AssertJUnit.assertNotNull("check error code exists in response after update resource",
189                 updatedRestResponse.getErrorCode());
190         AssertJUnit.assertEquals("Check response code after update resource", 404,
191                 updatedRestResponse.getErrorCode().intValue());
192         // String resourceId =
193         // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
194         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
195                 updatedRestResponse.getResponse());
196
197         resourceName = "";
198         // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
199         // "0.1");
200         updatedResourceDetails = defineUpdatedResourse(resourceName);
201         updatedResourceDetails.setUniqueId("dummyId");
202         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
203                 "0.1");
204         AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
205         AssertJUnit.assertNotNull("check error code exists in response after update resource",
206                 updatedRestResponse.getErrorCode());
207         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
208                 updatedRestResponse.getResponse());
209
210     }
211
212     public char[] getInValidChars() throws Exception {
213
214         char[] extendedCharsArray = new char[59];
215         char ch = 1;
216         for (int i = 0; i < 44; i++) {
217             extendedCharsArray[i] = ch;
218             ch++;
219         }
220         ch = 58;
221         for (int i = 44; i < 51; i++) {
222             extendedCharsArray[i] = ch;
223             ch++;
224         }
225         ch = 91;
226         for (int i = 51; i < 55; i++) {
227             extendedCharsArray[i] = ch;
228             ch++;
229         }
230         ch = 123;
231         for (int i = 55; i < 59; i++) {
232             extendedCharsArray[i] = ch;
233             ch++;
234         }
235         return extendedCharsArray;
236     }
237
238     public char[] getTagInValidFormatChars() throws Exception {
239         // Tag format is the same as defined for "Resource Name" :
240         // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
241         // ('_'), dash ('-'), dot ('.')
242         char[] notValidCharsArray = new char[30];
243         char ch = 33;
244         for (int i = 0; i < 12; i++) {
245             notValidCharsArray[i] = ch;
246             ch++;
247         }
248         notValidCharsArray[13] = 47;
249         ch = 58;
250         for (int i = 14; i < 21; i++) {
251             notValidCharsArray[i] = ch;
252             ch++;
253         }
254         ch = 91;
255         for (int i = 21; i < 24; i++) {
256             notValidCharsArray[i] = ch;
257             ch++;
258         }
259         notValidCharsArray[24] = 96;
260         ch = 123;
261         for (int i = 25; i < 30; i++) {
262             notValidCharsArray[i] = ch;
263             ch++;
264         }
265         return notValidCharsArray;
266     }
267
268     public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
269         // init ADMIN user
270         User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
271
272         // define and create resource
273         ResourceReqDetails resourceDetails = defineResourse();
274         ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
275         ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
276         ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
277
278         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
279         String resourceId = resourceDetails.getUniqueId();
280         resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
281
282         // build Json Object
283         JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
284
285         List<String> resource = new ArrayList<>();
286         resource.add("Resource");
287
288         // remove Description
289         UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description",
290                 ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
291         // remove Tags
292         UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags",
293                 ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
294         // remove Category
295         UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category",
296                 ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
297         // remove VendorName
298         UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName",
299                 ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
300         // remove VendorRelease
301         UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease",
302                 ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
303         // remove AT&T Contact
304         UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId",
305                 ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
306
307         // get resource with original name. original metadata should be returned
308         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
309         // validate response
310         AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
311         AssertJUnit.assertNotNull("check error code exists in response after get resource",
312                 getRestResponse.getErrorCode());
313         AssertJUnit.assertEquals("Check response code after update resource", 200,
314                 getRestResponse.getErrorCode().intValue());
315
316         // parse updated response to javaObject
317         Resource getResourceRespJavaObject = ResponseParser
318                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
319         // validate that metadata was not changed
320         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
321
322         ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
323         ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
324         ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
325     }
326
327     // End of validation tests
328     // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
329
330     protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
331         String description = "updatedDescription";
332         ArrayList<String> resourceTags = new ArrayList<String>();
333         // Duplicate tags are allowed and should be de-duplicated by server side
334         resourceTags.add(resourceName);
335         resourceTags.add("tag1");
336         resourceTags.add("tag1");
337         resourceTags.add("tag2");
338         resourceTags.add("tag2");
339         String category = ServiceCategoriesEnum.VOIP.getValue();
340         ArrayList<String> derivedFrom = new ArrayList<String>();
341         derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
342         String vendorName = "updatedOracle";
343         String vendorRelease = "3.5";
344         String contactId = "jh0001";
345         String icon = "myUpdatedICON";
346
347         ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
348                 derivedFrom, vendorName, vendorRelease, contactId, icon);
349         resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
350                 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
351
352         return resourceDetails;
353     }
354
355     protected ResourceReqDetails defineResourse() {
356         String resourceName = "cisco4";
357         String description = "description";
358         ArrayList<String> resourceTags = new ArrayList<String>();
359         resourceTags.add(resourceName);
360         ArrayList<String> derivedFrom = new ArrayList<String>();
361         derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
362         String vendorName = "Oracle";
363         String vendorRelease = "1.5";
364         String contactId = "jh0003";
365         String icon = "objectStorage";
366
367         ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null,
368                 derivedFrom, vendorName, vendorRelease, contactId, icon);
369         resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
370                 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
371
372         return resourceDetails;
373     }
374
375     protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails)
376             throws Exception {
377         // clean ES DB
378         DbUtils.cleanAllAudits();
379
380         // create resource
381         RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
382
383         // validate response
384         AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
385         AssertJUnit.assertNotNull("check error code exists in response after create resource",
386                 restResponse.getErrorCode());
387         AssertJUnit.assertEquals("Check response code after create resource", 201,
388                 restResponse.getErrorCode().intValue());
389
390         return restResponse;
391     }
392
393     protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails,
394                                                   String uri) throws Exception {
395         // delete resource
396         Config config;
397         RestResponse ResourceResponse;
398         try {
399             config = Utils.getConfig();
400             Map<String, String> headersMap = new HashMap<String, String>();
401             headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
402             headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
403             headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
404             HttpRequest http = new HttpRequest();
405             String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(),
406                     config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
407
408             if (uri == "GET") {
409                 ResourceResponse = http.httpSendGet(url, headersMap);
410             } else if (uri == "POST") {
411                 Gson gson = new Gson();
412                 String userBodyJson = gson.toJson(updatedResourceDetails);
413                 ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
414             } else if (uri == "DELETE") {
415                 ResourceResponse = http.httpSendDelete(url, headersMap);
416             } else
417                 return null;
418
419             return ResourceResponse;
420         } catch (FileNotFoundException e) {
421             e.printStackTrace();
422         }
423
424         return null;
425
426     }
427
428     protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
429         // json object: resourceName and icon are must
430         JSONObject jObject = new JSONObject();
431
432         List<String> tagsList = Arrays.asList(resourceDetails.getName());
433         List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
434
435         jObject.put("name", resourceDetails.getName());
436         jObject.put("description", "updatedDescription");
437         jObject.put("tags", tagsList);
438         jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
439         jObject.put("derivedFrom", derivedFromList);
440         jObject.put("vendorName", "newOracle");
441         jObject.put("vendorRelease", "1.5");
442         jObject.put("contactId", "jh0003");
443         jObject.put("icon", resourceDetails.getIcon());
444
445         return jObject;
446     }
447
448     protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
449         jObject.remove(removedPropery);
450
451         return jObject;
452     }
453
454     // purpose: function for controlling json body fields and validating
455     // response
456     protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject,
457                                                             String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
458
459         JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
460         // remove description from jsonObject
461         jObject = RemoveFromJsonObject(jObject, removedField);
462         // update with incomplete body.
463         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(),
464                 sdncModifierDetails, resourceId);
465         // validate response
466         AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
467         AssertJUnit.assertNotNull("check error code exists in response after update resource",
468                 updatedRestResponse.getErrorCode());
469         ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
470
471     }
472
473     // purpose: function for validating error response
474     protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails,
475                                      String recievedMessage, List<String> variables) throws Exception {
476         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
477                 sdncModifierDetails, "0.1");
478         // validate response
479         AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
480         AssertJUnit.assertNotNull("check error code exists in response after update resource",
481                 updatedRestResponse.getErrorCode());
482         ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
483
484     }
485
486     protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse)
487             throws Exception {
488         // parse response to javaObject
489         Resource updatedResourceRespJavaObject = ResponseParser
490                 .convertResourceResponseToJavaObject(restResponse.getResponse());
491         AssertJUnit.assertTrue(
492                 !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
493         AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
494         AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
495         AssertJUnit.assertTrue(
496                 !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
497         AssertJUnit.assertTrue(
498                 !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
499         AssertJUnit.assertTrue(
500                 !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
501         AssertJUnit
502                 .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
503         AssertJUnit.assertTrue(
504                 !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
505         AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName()
506                 .equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
507         AssertJUnit.assertTrue(
508                 !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
509         AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
510         AssertJUnit
511                 .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
512         AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
513
514     }
515
516     protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse)
517             throws Exception {
518         // parse response to javaObject
519         Resource updatedResourceRespJavaObject = ResponseParser
520                 .convertResourceResponseToJavaObject(restResponse.getResponse());
521         // validate request vs response
522         ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
523     }
524
525     public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails,
526                                                                              String resourceVersion) {
527
528         ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
529
530         expectedResourceAuditJavaObject.setAction("Checkout");
531         expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
532         expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
533         expectedResourceAuditJavaObject.setStatus("200.0");
534         expectedResourceAuditJavaObject.setDesc("OK");
535         expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
536         expectedResourceAuditJavaObject.setResourceType("Resource");
537         expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
538         expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
539         expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
540         expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
541
542         return expectedResourceAuditJavaObject;
543
544     }
545
546     public enum FieldToValidate {
547         contactId, Tags, VendorName, VendorRelease, Description
548     }
549
550     @Test
551     public void UpdateBy_postTest() throws Exception {
552
553         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
554         String resourceName = resourceDetails.getName();
555
556         // update resource - without changing resourceName
557         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
558
559         RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
560
561         // validate response
562         assertNotNull("check response object is not null after update resource", updatedRestResponse);
563         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
564         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
565                 updatedRestResponse.getResponse());
566
567         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
568                 resourceDetails.getUniqueId());
569         assertNotNull("check response object is not null after update resource", getRestResponse);
570         parseResponseAndValidate(resourceDetails, getRestResponse);
571
572     }
573
574     @Test
575     public void UpdateBy_getTest() throws Exception {
576
577         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
578         String resourceName = resourceDetails.getName();
579
580         // update resource - without changing resourceName
581         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
582         RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
583
584         // validate response
585         assertNotNull("check response object is not null after update resource", updatedRestResponse);
586         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
587         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
588                 updatedRestResponse.getResponse());
589
590         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
591                 resourceDetails.getUniqueId());
592         assertNotNull("check response object is not null after update resource", getRestResponse);
593         parseResponseAndValidate(resourceDetails, getRestResponse);
594
595     }
596
597     @Test
598     public void UpdateBy_deleteTest() throws Exception {
599
600         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
601         String resourceName = resourceDetails.getName();
602
603         // update resource - without changing resourceName
604         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
605         RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails,
606                 "DELETE");
607
608         // validate response
609         assertNotNull("check response object is not null after update resource", updatedRestResponse);
610         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
611         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
612                 updatedRestResponse.getResponse());
613
614         RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails,
615                 resourceDetails.getUniqueId(), "");
616         assertNotNull("check response object is not null after update resource", getRestResponse);
617         parseResponseAndValidate(resourceDetails, getRestResponse);
618
619     }
620
621     // TODO DE
622     // @Ignore("")
623     @Test
624     public void UpdateWithInvaldJsonBodyTest() throws Exception {
625
626         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
627         resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
628         String resourceId = resourceDetails.getUniqueId();
629
630         // update Descirption value
631         String description = "updatedDescription";
632
633         // send update with incompleted json, only description string
634         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails,
635                 resourceId);
636
637         // validate response
638         assertNotNull("check response object is not null after update resource", updatedRestResponse);
639         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
640         assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
641
642         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
643                 resourceDetails.getUniqueId());
644         assertNotNull("check response object is not null after update resource", getRestResponse);
645         parseResponseAndValidate(resourceDetails, getRestResponse);
646
647     }
648
649     // @Test
650     // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
651     //
652     //
653     // RestResponse restResponse = createResource(sdncModifierDetails,
654     // resourceDetails);
655     // String resourceName = resourceDetails.getName();
656     //
657     // // new user parameters
658     // String userFirstName = "Kot";
659     // String userLastName = "Matroskin";
660     // String role = "ADMIN";
661     // User sdncUserDetails = new User(userFirstName, userLastName,
662     // httpCspUserId, email, role,null);
663     // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
664     // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
665     //
666     // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
667     // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
668     //
669     // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
670     // httpCspUserId, email,role,null);
671     // ResourceReqDetails updatedResourceDetails =
672     // defineUpdatedResourse(resourceName);
673     // RestResponse updatedRestResponse =
674     // ResourceRestUtils.updateResource(updatedResourceDetails,
675     // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
676     //
677     // // validate response
678     // assertNotNull("check response object is not null after update resource",
679     // updatedRestResponse);
680     // assertNotNull("check error code exists in response after update
681     // resource", updatedRestResponse.getErrorCode());
682     // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
683     // Empty_List, updatedRestResponse.getResponse());
684     //
685     // RestResponse getRestResponse =
686     // ResourceRestUtils.getResource(sdncModifierDetails,
687     // resourceDetails.getUniqueId());
688     // assertNotNull("check response object is not null after update resource",
689     // getRestResponse);
690     // parseResponseAndValidate(resourceDetails, getRestResponse);
691     //
692     //
693     // }
694
695     @Test
696     public void UpdateResourceNameSensitiveTest() throws Exception {
697         User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
698         String resourceBaseVersion = "0.1";
699         String resourceName = "Ab";
700         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
701         // Delete resources
702         RestResponse response = null;
703         response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
704                 updatedResourceDetails.getName(), "0.1");
705         BaseRestUtils.checkDeleteResponse(response);
706         response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
707                 updatedResourceDetails.getName(), "0.2");
708         BaseRestUtils.checkDeleteResponse(response);
709
710         RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
711         assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
712
713         // check-in Resource
714         logger.debug("Changing resource life cycle ");
715         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails,
716                 sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
717         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
718
719         // String resourceCertifyVersion = "0.1";
720         logger.debug("Changing resource life cycle ");
721         checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails,
722                 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
723         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
724
725         updatedResourceDetails.setName("ABC_-bt.aT");
726         ArrayList<String> resourceTag = new ArrayList<String>();
727         resourceTag.add(0, "ABC_-bt.aT");
728         updatedResourceDetails.setTags(resourceTag);
729         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
730                 sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
731         assertNotNull("check response object is not null after update resource", updatedRestResponse);
732         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
733         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
734         parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
735
736         // Delete resources
737         response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
738                 updatedResourceDetails.getName(), "0.1");
739         BaseRestUtils.checkDeleteResponse(response);
740         response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
741                 updatedResourceDetails.getName(), "0.2");
742         BaseRestUtils.checkDeleteResponse(response);
743
744     }
745
746     @Test
747     public void UpdateIcon_InegativeFlow() throws Exception {
748
749         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
750         String resourceName = resourceDetails.getName();
751
752         List<String> resourceList = new ArrayList<String>();
753         resourceList.add(0, "Resource");
754         // check InValid Characters
755         char[] notValidCharsArray = new char[59];
756         notValidCharsArray = getInValidChars();
757         // update metadata details
758         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
759         RestResponse updatedRestResponse;
760
761         for (int i = 0; i < notValidCharsArray.length; i++) {
762             // change icon of metadata
763             updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
764             // PUT request
765             updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
766                     resourceDetails.getUniqueId(), "");
767             // validate response
768             assertNotNull("check response object is not null after update resource", updatedRestResponse);
769             assertNotNull("check error code exists in response after update resource",
770                     updatedRestResponse.getErrorCode());
771             ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList,
772                     updatedRestResponse.getResponse());
773             assertEquals("Check response code after updating resource icon", 400,
774                     updatedRestResponse.getErrorCode().intValue());
775             assertEquals("Check response code after updating resource icon", "Bad Request",
776                     updatedRestResponse.getResponseMessage().toString());
777
778         }
779
780         // empty icon
781         String updateIcon = "";
782         updatedResourceDetails.setIcon(updateIcon);
783         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
784                 resourceDetails.getUniqueId(), "");
785         assertNotNull("check response object is not null after update resource", updatedRestResponse);
786         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
787         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList,
788                 updatedRestResponse.getResponse());
789
790         // Icon length more then 25 characters
791         resourceList.add(1, "25");
792         updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
793         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
794                 resourceDetails.getUniqueId(), "");
795         // validate response
796         assertNotNull("check response object is not null after update resource", updatedRestResponse);
797         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
798         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList,
799                 updatedRestResponse.getResponse());
800         assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
801         assertEquals("Check response code after updating resource icon", "Bad Request",
802                 updatedRestResponse.getResponseMessage().toString());
803
804         // get resource with original name. original metadata should be returned
805         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
806                 resourceDetails.getUniqueId());
807         // validate response
808         assertNotNull("check response object is not null after get resource", getRestResponse);
809         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
810         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
811
812         // parse updated response to javaObject
813         Resource getResourceRespJavaObject = ResponseParser
814                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
815         // validate that metadata was not changed
816         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
817
818     }
819
820     @Test
821     public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
822
823         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
824         String resourceBaseVersion = "0.1";
825
826         // create resource
827         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
828         String resourceName = resourceDetails.getName();
829
830         ResourceReqDetails updatedResourceDetails = defineResourse();
831         updatedResourceDetails.setName("updatedResourceName");
832         List<String> tags = updatedResourceDetails.getTags();
833
834         for (Iterator<String> iter = tags.listIterator(); iter.hasNext(); ) {
835             String a = iter.next();
836             if (a.equals("updatedResourceName")) {
837                 iter.remove();
838             }
839         }
840
841         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
842                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
843         // validate response
844         List<String> resourceList = new ArrayList<String>();
845         assertNotNull("check response object is not null after update resource", updatedRestResponse);
846         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
847         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
848                 resourceList, updatedRestResponse.getResponse());
849         assertEquals("Check response code after updating resource icon", 400,
850                 updatedRestResponse.getErrorCode().intValue());
851
852         // get resource with original name. original metadata should be returned
853         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
854                 resourceDetails.getUniqueId());
855         // validate response
856         assertNotNull("check response object is not null after get resource", getRestResponse);
857         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
858         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
859         // parse updated response to javaObject
860         Resource getResourceRespJavaObject = ResponseParser
861                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
862         // validate that metadata was not changed
863         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
864
865     }
866
867     @Test
868     public void UpdateResourceName_negativeFlow() throws Exception {
869         // The validation are done in Tag's validation
870         User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
871
872         RestResponse updatedRestResponse;
873         RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
874         assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
875         String uniqueId = resourceDetails.getUniqueId();
876         String resourceName = resourceDetails.getName();
877         // check InValid Characters
878         char[] notValidCharsArray = new char[59];
879         notValidCharsArray = getInValidChars();
880         ArrayList<String> resource_Name = new ArrayList<String>();
881         List<String> resourceList = new ArrayList<String>();
882
883         ArrayList<String> resourceTags = new ArrayList<String>();
884         resourceList.add(0, "Resource");
885
886         // update metadata details
887         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
888         for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
889             if (i != 1 && i != 46
890                     && /*
891                                                  * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
892                                                  */ i != 31) // space ("") and dot(.)
893             {
894                 // change resourceName parameter
895                 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
896                 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
897                 updatedResourceDetails.setTags(resource_Name);
898                 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
899                         sdncAdminModifierDetails, uniqueId, "");
900                 // validate response
901                 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
902                 // Empty_List, updatedRestResponse.getResponse());
903                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList,
904                         updatedRestResponse.getResponse());
905
906             }
907         }
908
909         // resourceName length more then 50 characters
910         // Duplicate tags are allowed and should be de-duplicated by server side
911         resource_Name.add(resourceName);
912         resource_Name.add("tag1");
913         resource_Name.add("tag1");
914         resource_Name.add("tag2");
915         resource_Name.add("tag2");
916
917         resourceList.add(1, "1024");
918         // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
919         updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
920         // resource_Name.add("123456789012345678901234567890123456789012345678901");
921         updatedResourceDetails.setTags(resource_Name);
922         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
923                 uniqueId, "");
924         // validate response
925         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList,
926                 updatedRestResponse.getResponse());
927
928         // get resource with original name. original metadata should be returned
929         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
930                 resourceDetails.getUniqueId());
931         // validate response
932         assertNotNull("check response object is not null after get resource", getRestResponse);
933         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
934         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
935         // parse updated response to javaObject
936         Resource getResourceRespJavaObject = ResponseParser
937                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
938         // validate that metadata was not changed
939         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
940
941         // delete resource
942         RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails,
943                 updatedResourceDetails.getName(), "0.1");
944         BaseRestUtils.checkDeleteResponse(response);
945     }
946
947     @Test
948     public void UpdateResourceInformation_NotCheckedOut() throws Exception {
949
950         String resourceBaseVersion = "0.1";
951         List<String> resourceList = new ArrayList<String>();
952
953         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
954         String resourceName = resourceDetails.getName();
955
956         // CheckIn Resource
957         logger.debug("Changing resource life cycle ");
958         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
959                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
960         assertNotNull("check response object is not null after checkout resource", checkoutResource);
961         assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
962         assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
963
964         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
965
966         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
967                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
968         assertNotNull("check response object is not null after update resource", updatedRestResponse);
969         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
970         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
971                 updatedRestResponse.getResponse());
972         assertEquals("Check response code after updating resource icon", 409,
973                 updatedRestResponse.getErrorCode().intValue());
974
975         // get resource with original name. original metadata should be returned
976         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
977                 resourceDetails.getUniqueId());
978         // validate response
979         assertNotNull("check response object is not null after get resource", getRestResponse);
980         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
981         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
982
983         // parse updated response to javaObject
984         Resource getResourceRespJavaObject = ResponseParser
985                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
986         // validate that metadata was not changed
987         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
988
989     }
990
991     @Test
992     public void UpdateResourceInformation_resourceVersion_11() throws Exception {
993
994         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
995         String resourceBaseVersion = "0.1";
996
997         // create resource
998         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
999         String resourceName = resourceDetails.getName();
1000
1001         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1002         // restResponse);
1003
1004         // Certify Resource
1005         logger.debug("Changing resource life cycle ");
1006         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1007                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1008         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1009
1010         /*logger.debug("Changing resource life cycle ");
1011         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1012                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1013         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1014
1015         logger.debug("Changing resource life cycle ");
1016         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1017                 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1018         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1019
1020         logger.debug("Changing resource life cycle ");
1021         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1022                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1023         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1024
1025         String resourceCertifyVersion = "1.0";
1026         logger.debug("Changing resource life cycle ");
1027         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1028                 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
1029         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1030
1031         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1032
1033         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1034                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1035         // validate response
1036         List<String> resourceList = new ArrayList<String>();
1037         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1038         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1039         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
1040                 updatedRestResponse.getResponse());
1041         // assertEquals("Check response code after updating resource icon", 409,
1042         // updatedRestResponse.getErrorCode().intValue());
1043
1044         // get resource with original name. original metadata should be returned
1045         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1046                 resourceDetails.getUniqueId());
1047         // validate response
1048         assertNotNull("check response object is not null after get resource", getRestResponse);
1049
1050         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1051
1052         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1053         // parse updated response to javaObject
1054         Resource getResourceRespJavaObject = ResponseParser
1055                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1056         // validate that metadata was not changed
1057         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1058
1059     }
1060
1061     @Test
1062     public void UpdateResourceInformation_resourceVersion_02() throws Exception {
1063
1064         String resourceBaseVersion = "0.1";
1065
1066         // create resource
1067         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1068         String resourceName = resourceDetails.getName();
1069
1070         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1071         // restResponse);
1072
1073         // Certify Resource
1074         logger.debug("Changing resource life cycle ");
1075         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1076                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1077         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1078
1079         // String resourceCertifyVersion = "0.1";
1080         logger.debug("Changing resource life cycle ");
1081         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1082                 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
1083         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1084
1085         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1086
1087         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1088                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1089         // validate response
1090         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1091         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1092         assertEquals("Check response code after updating resource icon", 200,
1093                 updatedRestResponse.getErrorCode().intValue());
1094
1095         // get resource with original name. original metadata should be returned
1096         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1097                 resourceDetails.getUniqueId());
1098         // validate response
1099         assertNotNull("check response object is not null after get resource", getRestResponse);
1100         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1101         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1102
1103         // parse updated response to javaObject
1104         Resource getResourceRespJavaObject = ResponseParser
1105                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1106         // validate that metadata was not changed
1107         ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
1108
1109         // delete resource
1110         RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1111                 updatedResourceDetails.getName(), "0.1");
1112         BaseRestUtils.checkDeleteResponse(response);
1113         response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1114                 updatedResourceDetails.getName(), "0.2");
1115         BaseRestUtils.checkDeleteResponse(response);
1116
1117     }
1118
1119     @Test
1120     public void UpdateResourceIcon_resourceVersion_11() throws Exception {
1121         // Can be changed only if major version is "0".
1122
1123         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1124         String resourceBaseVersion = "0.1";
1125
1126         // create resource
1127         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1128         String resourceName = resourceDetails.getName();
1129
1130         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1131         // restResponse);
1132
1133         // Certify Resource
1134         logger.debug("Changing resource life cycle ");
1135         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1136                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1137         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1138
1139         /*logger.debug("Changing resource life cycle ");
1140         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1141                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1142         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1143
1144         logger.debug("Changing resource life cycle ");
1145         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1146                 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1147         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1148
1149         logger.debug("Changing resource life cycle ");
1150         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1151                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1152         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1153
1154         String resourceCertifyVersion = "1.0";
1155         logger.debug("Changing resource life cycle ");
1156         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1157                 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1158         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1159
1160         // ResourceReqDetails updatedResourceDetails =
1161         // defineUpdatedResourse(resourceName);
1162         ResourceReqDetails updatedResourceDetails = defineResourse();
1163         // updatedResourceDetails.setVendorName("updatedVandorName");
1164         updatedResourceDetails.setIcon("updatedIcon");
1165
1166         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1167                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1168         // validate response
1169         List<String> resourceList = new ArrayList<String>();
1170         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList,
1171                 updatedRestResponse.getResponse());
1172
1173         // get resource with original name. original metadata should be returned
1174         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1175                 resourceDetails.getUniqueId());
1176         // validate response
1177         assertNotNull("check response object is not null after get resource", getRestResponse);
1178         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1179         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1180         // parse updated response to javaObject
1181         Resource getResourceRespJavaObject = ResponseParser
1182                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1183         // validate that metadata was not changed
1184         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1185
1186     }
1187
1188     @Test
1189     public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1190         // Can be changed only if the major resource version is "0".
1191         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1192         String resourceBaseVersion = "0.1";
1193
1194         // create resource
1195         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1196         String resourceName = resourceDetails.getName();
1197
1198         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1199         // restResponse);
1200
1201         // Certify Resource
1202         logger.debug("Changing resource life cycle ");
1203         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1204                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1205         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1206
1207         /*logger.debug("Changing resource life cycle ");
1208         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1209                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1210         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1211
1212         logger.debug("Changing resource life cycle ");
1213         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1214                 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1215         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1216
1217         logger.debug("Changing resource life cycle ");
1218         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1219                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1220         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1221
1222         String resourceCertifyVersion = "1.0";
1223         logger.debug("Changing resource life cycle ");
1224         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1225                 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1226         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1227
1228         // ResourceReqDetails updatedResourceDetails =
1229         // defineUpdatedResourse(resourceName);
1230         ResourceReqDetails updatedResourceDetails = defineResourse();
1231
1232         updatedResourceDetails.setVendorName("updatedVandorName");
1233
1234         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1235                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1236         // validate response
1237         List<String> resourceList = new ArrayList<String>();
1238         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1239         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1240         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(),
1241                 resourceList, updatedRestResponse.getResponse());
1242         assertEquals("Check response code after updating resource icon", 400,
1243                 updatedRestResponse.getErrorCode().intValue());
1244
1245         // get resource with original name. original metadata should be returned
1246         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1247                 resourceDetails.getUniqueId());
1248         // validate response
1249         assertNotNull("check response object is not null after get resource", getRestResponse);
1250         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1251         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1252         // parse updated response to javaObject
1253         Resource getResourceRespJavaObject = ResponseParser
1254                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1255         // validate that metadata was not changed
1256         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1257
1258     }
1259
1260     @Test
1261     public void UpdateResourceName_resourceVersion_11() throws Exception {
1262         // Can be changed only if the major resource version is "0".
1263         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1264         String resourceBaseVersion = "0.1";
1265
1266         // create resource
1267         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1268         assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1269         String resourceName = resourceDetails.getName();
1270
1271         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1272         // restResponse);
1273
1274         // Certify Resource
1275         logger.debug("Changing resource life cycle ");
1276         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1277                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1278         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1279
1280         /*logger.debug("Changing resource life cycle ");
1281         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1282                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1283         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1284
1285         logger.debug("Changing resource life cycle ");
1286         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1287                 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1288         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1289
1290         logger.debug("Changing resource life cycle ");
1291         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1292                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1293         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1294
1295         String resourceCertifyVersion = "1.0";
1296         logger.debug("Changing resource life cycle ");
1297         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1298                 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1299         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1300
1301                 /*
1302                  * //ResourceReqDetails updatedResourceDetails =
1303                  * defineUpdatedResourse(resourceName); ResourceReqDetails
1304                  * updatedResourceDetails = defineResourse();
1305                  * 
1306                  * updatedResourceDetails.setResourceName("updatedResourceName");
1307                  * updatedResourceDetails.setIcon("updatedResourceName");
1308                  */
1309         resourceDetails.setName("updatedResourceName");
1310         List<String> tagList = new ArrayList<String>();
1311         tagList.add(0, "updatedResourceName");
1312         resourceDetails.setTags(tagList);
1313
1314         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1315                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1316         // validate response
1317         List<String> resourceList = new ArrayList<String>();
1318         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1319         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1320         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList,
1321                 updatedRestResponse.getResponse());
1322
1323     }
1324
1325     @Test
1326     public void UpdateResourceTag_resourceVersion_11() throws Exception {
1327         // Tag Can be updated when major version is "0".
1328         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1329         String resourceBaseVersion = "0.1";
1330
1331         // create resource
1332         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1333         String resourceName = resourceDetails.getName();
1334
1335         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1336         // restResponse);
1337
1338         // Certify Resource
1339         logger.debug("Changing resource life cycle ");
1340         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1341                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1342         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1343
1344         /*logger.debug("Changing resource life cycle ");
1345         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1346                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1347         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1348
1349         logger.debug("Changing resource life cycle ");
1350         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1351                 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1352         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1353
1354         logger.debug("Changing resource life cycle ");
1355         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1356                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1357         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1358
1359         String resourceCertifyVersion = "1.0";
1360         logger.debug("Changing resource life cycle ");
1361         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1362                 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1363         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1364
1365         // ResourceReqDetails updatedResourceDetails =
1366         // defineUpdatedResourse(resourceName);
1367         ResourceReqDetails updatedResourceDetails = defineResourse();
1368         // updatedResourceDetails.setVendorName("updatedVandorName");
1369
1370         ArrayList<String> resourceTags = new ArrayList<String>();
1371         resourceTags.add("NewTag");
1372         resourceTags.add(resourceDetails.getName());
1373
1374         updatedResourceDetails.setTags(resourceTags);
1375
1376         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1377                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1378         // validate response
1379         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1380         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1381         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1382
1383         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1384                 resourceDetails.getUniqueId());
1385         assertNotNull("check response object is not null after update resource", getRestResponse);
1386         parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1387
1388     }
1389
1390     @Test
1391     public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1392
1393         // Tag, contactId, vendorRelease,tags And description - Can be also
1394         // updated when major version is NOT "0".
1395         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1396         String resourceBaseVersion = "0.1";
1397
1398         // create resource
1399         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1400
1401         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1402         // restResponse);
1403
1404         // Certify Resource
1405         logger.debug("Changing resource life cycle ");
1406         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1407                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1408         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1409
1410         /*logger.debug("Changing resource life cycle ");
1411         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1412                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1413         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1414
1415         logger.debug("Changing resource life cycle ");
1416         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1417                 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1418         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1419
1420         logger.debug("Changing resource life cycle ");
1421         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1422                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1423         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1424
1425         String resourceCertifyVersion = "1.0";
1426         logger.debug("Changing resource life cycle ");
1427         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1428                 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1429         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1430
1431         // ResourceReqDetails updatedResourceDetails =
1432         // defineUpdatedResourse(resourceName);
1433         ResourceReqDetails updatedResourceDetails = defineResourse();
1434         // updatedResourceDetails.setVendorName("updatedVandorName");
1435
1436         // updated allowed parameters when major resource version is NOT "0"
1437         ArrayList<String> resourceTags = new ArrayList<String>();
1438         resourceTags.add("NewTag");
1439         resourceTags.add(resourceDetails.getName());
1440         updatedResourceDetails.setTags(resourceTags);
1441         updatedResourceDetails.setDescription("UpdatedDescription");
1442         updatedResourceDetails.setVendorRelease("5.1");
1443         updatedResourceDetails.setContactId("bt750h");
1444
1445         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1446                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1447         // validate response
1448         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1449         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1450         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1451
1452         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1453                 resourceDetails.getUniqueId());
1454         assertNotNull("check response object is not null after update resource", getRestResponse);
1455         parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1456
1457     }
1458
1459     @Test
1460     public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1461         // DerivedFrom parameter - Can be updated when major version is "0".
1462         User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1463         String resourceBaseVersion = "0.1";
1464
1465         // create resource
1466         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1467         String resourceName = resourceDetails.getName();
1468
1469         // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1470         // restResponse);
1471
1472         // Certify Resource
1473         logger.debug("Changing resource life cycle ");
1474         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1475                 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1476         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1477
1478         /*logger.debug("Changing resource life cycle ");
1479         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1480                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1481         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1482
1483         logger.debug("Changing resource life cycle ");
1484         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1485                 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1486         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1487
1488         logger.debug("Changing resource life cycle ");
1489         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1490                 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1491         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1492
1493         String resourceCertifyVersion = "1.0";
1494         logger.debug("Changing resource life cycle ");
1495         checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1496                 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1497         assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1498
1499         // ResourceReqDetails updatedResourceDetails =
1500         // defineUpdatedResourse(resourceName);
1501         ResourceReqDetails updatedResourceDetails = defineResourse();
1502         ArrayList<String> drivenFrom = new ArrayList<String>();
1503         drivenFrom.add(0, "tosca.nodes.Container.Application");
1504         updatedResourceDetails.setDerivedFrom(drivenFrom);
1505
1506         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1507                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1508         // validate response
1509         List<String> resourceList = new ArrayList<String>();
1510         ResourceRestUtils.checkSuccess(updatedRestResponse);
1511
1512         // get resource with original name. original metadata should be returned
1513         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1514                 resourceDetails.getUniqueId());
1515         // validate response
1516         assertNotNull("check response object is not null after get resource", getRestResponse);
1517         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1518         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1519         // parse updated response to javaObject
1520         Resource getResourceRespJavaObject = ResponseParser
1521                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1522         // validate that metadata was not changed
1523         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1524
1525     }
1526
1527     @Test
1528     public void UpdateResource_vendorNameValidation() throws Exception {
1529
1530         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1531         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1532         String updatedVendorName = "";
1533         String uniqueId = resourceDetails.getUniqueId();
1534         resourceDetails.setVendorName(updatedVendorName);
1535         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1536                 sdncModifierDetails, uniqueId, "");
1537         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1538         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1539         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1540                 updatedRestResponse.getResponse());
1541
1542         // update resource vendorName metadata: 1 characters
1543         updatedVendorName = "   ";
1544         // set vendorName
1545         resourceDetails.setVendorName(updatedVendorName);
1546         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1547                 "");
1548         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1549         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1550         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1551                 updatedRestResponse.getResponse());
1552
1553         // update resource vendorName metadata: 25 characters
1554         updatedVendorName = "Verification and validati";
1555         // set vendorName
1556         resourceDetails.setVendorName(updatedVendorName);
1557         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1558                 "");
1559         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1560         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1561         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1562         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1563
1564         // update resource vendorName metadata: 26 characters
1565         updatedVendorName = "Verification and validatii";
1566         // set vendorName
1567         List<String> myList = new ArrayList<String>();
1568         myList.add(0, "25");
1569         resourceDetails.setVendorName(updatedVendorName);
1570         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1571                 "");
1572         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1573         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList,
1574                 updatedRestResponse.getResponse());
1575
1576         // update resource VendorRelease metadata: forbidden characters
1577         updatedVendorName = "A1<";
1578         // set vendorName
1579         resourceDetails.setVendorName(updatedVendorName);
1580         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1581                 "");
1582         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1583         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1584                 updatedRestResponse.getResponse());
1585
1586         updatedVendorName = "A1>";
1587         // set vendorName
1588         resourceDetails.setVendorName(updatedVendorName);
1589         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1590                 "");
1591         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1592         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1593                 updatedRestResponse.getResponse());
1594
1595         updatedVendorName = "A1:";
1596         // set vendorName
1597         resourceDetails.setVendorName(updatedVendorName);
1598         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1599                 "");
1600         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1601         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1602                 updatedRestResponse.getResponse());
1603
1604         updatedVendorName = "A1\"";
1605         // set vendorName
1606         resourceDetails.setVendorName(updatedVendorName);
1607         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1608                 "");
1609         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1610         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1611                 updatedRestResponse.getResponse());
1612
1613         updatedVendorName = "A1/";
1614         // set vendorName
1615         resourceDetails.setVendorName(updatedVendorName);
1616         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1617                 "");
1618         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1619         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1620                 updatedRestResponse.getResponse());
1621
1622         updatedVendorName = "A1\\";
1623         // set vendorName
1624         resourceDetails.setVendorName(updatedVendorName);
1625         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1626                 "");
1627         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1628         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1629                 updatedRestResponse.getResponse());
1630
1631         updatedVendorName = "A1|";
1632         // set vendorName
1633         resourceDetails.setVendorName(updatedVendorName);
1634         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1635                 "");
1636         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1637         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1638                 updatedRestResponse.getResponse());
1639
1640         updatedVendorName = "A1?";
1641         // set vendorName
1642         resourceDetails.setVendorName(updatedVendorName);
1643         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1644                 "");
1645         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1646         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1647                 updatedRestResponse.getResponse());
1648
1649         updatedVendorName = "A1*";
1650         // set vendorName
1651         resourceDetails.setVendorName(updatedVendorName);
1652         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1653                 "");
1654         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1655         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1656                 updatedRestResponse.getResponse());
1657
1658         // update resource vendorName metadata: null
1659         updatedVendorName = null;
1660         // set vendorName
1661         resourceDetails.setVendorName(updatedVendorName);
1662         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1663                 "");
1664         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1665         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1666                 updatedRestResponse.getResponse());
1667
1668     }
1669
1670     @Test
1671     public void UpdateResource_vendorReleaseValidation() throws Exception {
1672
1673         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1674         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1675         RestResponse updatedRestResponse;
1676         String uniqueId = resourceDetails.getUniqueId();
1677         String updatedVendorRelease;
1678         // set VendorRelease
1679
1680         // update resource VendorRelease metadata: 1 characters
1681         updatedVendorRelease = "1";
1682         // set VendorRelease
1683         resourceDetails.setVendorRelease(updatedVendorRelease);
1684         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1685                 "");
1686         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1687         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1688         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1689         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1690
1691         // update resource VendorRelease metadata: 25 characters
1692         updatedVendorRelease = "(!#1.00000000000000000000";
1693         // set VendorRelease
1694         resourceDetails.setVendorRelease(updatedVendorRelease);
1695         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1696                 "");
1697         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1698         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1699         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1700         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1701
1702         // update resource VendorRelease metadata: 26 characters
1703         updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1704         resourceDetails.setVendorRelease(updatedVendorRelease);
1705         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1706                 "");
1707         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1708                 Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1709
1710         // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1711         // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1712         // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1713
1714         // update resource VendorRelease metadata: forbidden characters
1715         updatedVendorRelease = "A1<";
1716         // set VendorRelease
1717         resourceDetails.setVendorRelease(updatedVendorRelease);
1718         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1719                 "");
1720         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1721                 updatedRestResponse.getResponse());
1722
1723         updatedVendorRelease = "A1>";
1724         // set VendorRelease
1725         resourceDetails.setVendorRelease(updatedVendorRelease);
1726         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1727                 "");
1728         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1729                 updatedRestResponse.getResponse());
1730
1731         updatedVendorRelease = "A1:";
1732         // set VendorRelease
1733         resourceDetails.setVendorRelease(updatedVendorRelease);
1734         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1735                 "");
1736         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1737                 updatedRestResponse.getResponse());
1738
1739         updatedVendorRelease = "A1\"";
1740         // set VendorRelease
1741         resourceDetails.setVendorRelease(updatedVendorRelease);
1742         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1743                 "");
1744         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1745                 updatedRestResponse.getResponse());
1746
1747         updatedVendorRelease = "A1/";
1748         // set VendorRelease
1749         resourceDetails.setVendorRelease(updatedVendorRelease);
1750         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1751                 "");
1752         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1753                 updatedRestResponse.getResponse());
1754
1755         updatedVendorRelease = "A1\\";
1756         // set VendorRelease
1757         resourceDetails.setVendorRelease(updatedVendorRelease);
1758         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1759                 "");
1760         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1761                 updatedRestResponse.getResponse());
1762
1763         updatedVendorRelease = "A1|";
1764         // set VendorRelease
1765         resourceDetails.setVendorRelease(updatedVendorRelease);
1766         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1767                 "");
1768         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1769                 updatedRestResponse.getResponse());
1770
1771         updatedVendorRelease = "A1?";
1772         // set VendorRelease
1773         resourceDetails.setVendorRelease(updatedVendorRelease);
1774         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1775                 "");
1776         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1777                 updatedRestResponse.getResponse());
1778
1779         updatedVendorRelease = "A1*";
1780         // set VendorRelease
1781         resourceDetails.setVendorRelease(updatedVendorRelease);
1782         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1783                 "");
1784         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1785                 updatedRestResponse.getResponse());
1786
1787         // update resource VendorRelease metadata: null
1788         updatedVendorRelease = null;
1789         // set VendorRelease
1790         resourceDetails.setVendorRelease(updatedVendorRelease);
1791         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1792                 "");
1793         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1794         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List,
1795                 updatedRestResponse.getResponse());
1796
1797     }
1798
1799     @Test
1800     public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1801         // (6
1802         // characters
1803         // now,
1804         // may
1805         // be
1806         // expanded
1807         // up
1808         // to
1809         // 8
1810         // characters
1811         // in
1812         // the
1813         // future).
1814         // Convert
1815         // Upper
1816         // case
1817         // character
1818         // to
1819         // lower
1820         // case
1821         RestResponse updatedRestResponse;
1822
1823         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1824         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1825         String uniqueId = resourceDetails.getUniqueId();
1826
1827         List<String> myList = new ArrayList<String>();
1828         myList.add(0, "Resource");
1829         String updatedcontactId = "";
1830         resourceDetails.setContactId(updatedcontactId);
1831
1832         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1833                 "");
1834         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1835                 updatedRestResponse.getResponse());
1836
1837         updatedcontactId = "ab12345";
1838         resourceDetails.setContactId(updatedcontactId);
1839         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1840                 "");
1841         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1842                 updatedRestResponse.getResponse());
1843
1844         updatedcontactId = "      ";
1845         resourceDetails.setContactId(updatedcontactId);
1846         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1847                 "");
1848         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1849                 updatedRestResponse.getResponse());
1850
1851         updatedcontactId = "ab 50h";
1852         resourceDetails.setContactId(updatedcontactId);
1853         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1854                 "");
1855         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1856                 updatedRestResponse.getResponse());
1857
1858         updatedcontactId = "ab123c";
1859         resourceDetails.setContactId(updatedcontactId);
1860         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1861                 "");
1862         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1863         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1864         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1865
1866         updatedcontactId = "cd789E";
1867         resourceDetails.setContactId(updatedcontactId);
1868         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1869                 "");
1870         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1871         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1872
1873         resourceDetails.setContactId(updatedcontactId.toLowerCase());
1874         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1875
1876         updatedcontactId = "ef4567";
1877         resourceDetails.setContactId(updatedcontactId);
1878         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1879                 "");
1880         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1881         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1882         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1883         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1884
1885         updatedcontactId = "AA012A";
1886         resourceDetails.setContactId(updatedcontactId);
1887         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1888                 "");
1889         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1890         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1891         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1892
1893         resourceDetails.setContactId(updatedcontactId.toLowerCase());
1894         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1895
1896         updatedcontactId = "CD012c";
1897         resourceDetails.setContactId(updatedcontactId);
1898         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1899                 "");
1900         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1901         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1902         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1903
1904         resourceDetails.setContactId(updatedcontactId.toLowerCase());
1905         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1906
1907         updatedcontactId = "EF0123";
1908         resourceDetails.setContactId(updatedcontactId);
1909         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1910                 "");
1911         assertNotNull("check response object is not null after update resource", updatedRestResponse);
1912         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1913         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1914
1915         resourceDetails.setContactId(updatedcontactId.toLowerCase());
1916         parseResponseAndValidate(resourceDetails, updatedRestResponse);
1917
1918         ////////////////////////////// **************//////////////////////////////
1919         List<String> resource = Arrays.asList("Resource");
1920         updatedcontactId = "01345a";
1921         resourceDetails.setContactId(updatedcontactId);
1922         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1923                 "");
1924         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1925                 updatedRestResponse.getResponse());
1926
1927         updatedcontactId = "0y000B";
1928         resourceDetails.setContactId(updatedcontactId);
1929         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1930                 "");
1931         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1932                 updatedRestResponse.getResponse());
1933
1934         updatedcontactId = "Y1000b";
1935         resourceDetails.setContactId(updatedcontactId);
1936         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1937                 "");
1938         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1939                 updatedRestResponse.getResponse());
1940
1941         updatedcontactId = "abxyzC";
1942         resourceDetails.setContactId(updatedcontactId);
1943         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1944                 "");
1945         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1946                 updatedRestResponse.getResponse());
1947
1948         updatedcontactId = "cdXYZc";
1949         resourceDetails.setContactId(updatedcontactId);
1950         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1951                 "");
1952         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1953                 updatedRestResponse.getResponse());
1954
1955         updatedcontactId = "efXY1D";
1956         resourceDetails.setContactId(updatedcontactId);
1957         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1958                 "");
1959         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1960                 updatedRestResponse.getResponse());
1961
1962         updatedcontactId = "EFabcD";
1963         resourceDetails.setContactId(updatedcontactId);
1964         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1965                 "");
1966         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1967                 updatedRestResponse.getResponse());
1968
1969         updatedcontactId = "EFABCD";
1970         resourceDetails.setContactId(updatedcontactId);
1971         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1972                 "");
1973         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1974                 updatedRestResponse.getResponse());
1975
1976         updatedcontactId = "EFABC1";
1977         resourceDetails.setContactId(updatedcontactId);
1978         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1979                 "");
1980         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1981                 updatedRestResponse.getResponse());
1982
1983         updatedcontactId = "efui1D";
1984         resourceDetails.setContactId(updatedcontactId);
1985         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1986                 "");
1987         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1988                 updatedRestResponse.getResponse());
1989
1990         updatedcontactId = "efui1!";
1991         resourceDetails.setContactId(updatedcontactId);
1992         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1993                 "");
1994         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1995                 updatedRestResponse.getResponse());
1996
1997         updatedcontactId = "ef555!";
1998         resourceDetails.setContactId(updatedcontactId);
1999         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2000                 "");
2001         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2002                 updatedRestResponse.getResponse());
2003
2004         updatedcontactId = ",f555";
2005         resourceDetails.setContactId(updatedcontactId);
2006         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2007                 "");
2008         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2009                 updatedRestResponse.getResponse());
2010
2011         updatedcontactId = "EF55.5";
2012         resourceDetails.setContactId(updatedcontactId);
2013         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2014                 "");
2015         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2016                 updatedRestResponse.getResponse());
2017
2018         // update resource contactId metadata: extended character set (128–255)
2019         resourceDetails.setContactId(extendedCharsStringBuilder());
2020         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2021                 "");
2022         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2023                 updatedRestResponse.getResponse());
2024
2025         // update resource contactId metadata: null
2026         updatedcontactId = null;
2027         resourceDetails.setContactId(updatedcontactId);
2028         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2029                 "");
2030         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
2031                 updatedRestResponse.getResponse());
2032
2033     }
2034
2035     @Test
2036     public void UpdateResource_TagsFieldValidation() throws Exception {
2037         RestResponse updatedRestResponse;
2038         // define and create resource
2039
2040         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2041         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2042         String uniqueId = resourceDetails.getUniqueId();
2043
2044         String updatedTagField = "";
2045         ArrayList<String> resourceTags = new ArrayList<String>();
2046         resourceTags.add(updatedTagField);
2047         // set description
2048         resourceDetails.setTags(resourceTags);
2049         List<String> variables = Arrays.asList("Resource", "tag");
2050         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2051                 "");
2052         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2053                 updatedRestResponse.getResponse());
2054
2055         // update resource tags metadata: empty
2056         resourceTags = new ArrayList<String>();
2057         // set Tags
2058         resourceDetails.setTags(resourceTags);
2059         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2060                 "");
2061         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List,
2062                 updatedRestResponse.getResponse());
2063
2064         // update resource description metadata: 1 characters
2065         updatedTagField = "A";
2066         resourceTags = new ArrayList<String>();
2067         resourceTags.add(updatedTagField);
2068         resourceTags.add(resourceDetails.getName());
2069         // set description
2070         resourceDetails.setTags(resourceTags);
2071         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2072                 "");
2073         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2074         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2075         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2076         parseResponseAndValidate(resourceDetails, updatedRestResponse);
2077
2078         // OK - tag up to 50 chars
2079         updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
2080         resourceTags.add(updatedTagField);
2081         resourceDetails.setTags(resourceTags);
2082         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2083                 "");
2084         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2085         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2086         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2087         parseResponseAndValidate(resourceDetails, updatedRestResponse);
2088
2089         // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
2090         String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
2091         String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
2092         String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
2093         String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
2094         String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
2095         String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
2096         String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
2097         String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
2098         String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
2099         String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
2100         String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
2101         String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
2102         String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
2103         String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
2104         String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
2105         String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
2106         String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
2107         String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
2108         String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
2109
2110         resourceTags = new ArrayList<String>();
2111         resourceTags.add(updatedTagField);
2112         resourceTags.add(updatedTagField1);
2113         resourceTags.add(updatedTagField2);
2114         resourceTags.add(updatedTagField3);
2115         resourceTags.add(updatedTagField4);
2116         resourceTags.add(updatedTagField5);
2117         resourceTags.add(updatedTagField6);
2118         resourceTags.add(updatedTagField7);
2119         resourceTags.add(updatedTagField8);
2120         resourceTags.add(updatedTagField9);
2121         resourceTags.add(updatedTagField10);
2122         resourceTags.add(updatedTagField11);
2123         resourceTags.add(updatedTagField12);
2124         resourceTags.add(updatedTagField13);
2125         resourceTags.add(updatedTagField14);
2126         resourceTags.add(updatedTagField15);
2127         resourceTags.add(updatedTagField16);
2128         resourceTags.add(updatedTagField17);
2129         resourceTags.add(updatedTagField18);
2130         resourceTags.add(updatedTagField19);
2131         resourceTags.add(resourceDetails.getName());
2132         // set description
2133         resourceDetails.setTags(resourceTags);
2134         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2135                 "");
2136         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2137         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2138         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2139         parseResponseAndValidate(resourceDetails, updatedRestResponse);
2140
2141         // Add another tag-exceeds limit
2142         resourceTags.add("d");
2143         resourceDetails.setTags(resourceTags);
2144         ArrayList<String> myArray = new ArrayList<String>();
2145         myArray.add(0, "1024");
2146         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2147                 "");
2148         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray,
2149                 updatedRestResponse.getResponse());
2150
2151         // Tag exceeds limit - 51
2152         resourceTags = new ArrayList<String>();
2153         updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
2154         resourceTags.add(updatedTagField);
2155         resourceTags.add(resourceDetails.getName());
2156         // set description
2157         resourceDetails.setTags(resourceTags);
2158         myArray.remove(0);
2159         myArray.add(0, "50");
2160         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2161                 "");
2162         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray,
2163                 updatedRestResponse.getResponse());
2164
2165     }
2166
2167     @Test
2168     public void UpdateResource_DesriptionFieldValidation() throws Exception {
2169         // define and create resource
2170         RestResponse updatedRestResponse;
2171
2172         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2173         String uniqueId = resourceDetails.getUniqueId();
2174         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2175         List<String> resource = new ArrayList<>();
2176         resource.add("Resource");
2177         // update resource description metadata: 0 characters
2178         String updatedDescription = "";
2179         // set description
2180         resourceDetails.setDescription(updatedDescription);
2181         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2182                 "");
2183         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2184                 updatedRestResponse.getResponse());
2185
2186         // update resource description metadata: null
2187         updatedDescription = null;
2188         // set description
2189         resourceDetails.setDescription(updatedDescription);
2190         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2191                 "");
2192         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2193                 updatedRestResponse.getResponse());
2194
2195         // update resource description metadata: 1 characters
2196         updatedDescription = "A";
2197         // set description
2198         resourceDetails.setDescription(updatedDescription);
2199         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2200                 "");
2201         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2202         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2203         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2204         parseResponseAndValidate(resourceDetails, updatedRestResponse);
2205
2206         // update resource description metadata: 1024 characters
2207         updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2208                 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2209                 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2210                 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2211                 + "The longest quills grow from its shoulders to about a third of the animal's length."
2212                 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2213                 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2214                 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2215                 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
2216         // set description
2217         resourceDetails.setDescription(updatedDescription);
2218         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2219                 "");
2220         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2221         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2222         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2223         parseResponseAndValidate(resourceDetails, updatedRestResponse);
2224
2225         // update resource description metadata: 1025 characters
2226         updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2227                 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2228                 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2229                 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2230                 + "The longest quills grow from its shoulders to about a third of the animal's length."
2231                 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2232                 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2233                 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2234                 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
2235         // set description
2236         resourceDetails.setDescription(updatedDescription);
2237         resource.add(1, "1024");
2238         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2239                 "");
2240         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource,
2241                 updatedRestResponse.getResponse());
2242
2243     }
2244
2245     @Test
2246     public void UpdateResource_TagsFormatValidation() throws Exception {
2247         char[] notValidCharsArray = getTagInValidFormatChars();
2248
2249         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2250         assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
2251         String resourceName = resourceDetails.getName();
2252
2253         // update tag details
2254         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2255         ArrayList<String> resourceTags = new ArrayList<String>();
2256
2257         String updatedTagField;
2258         RestResponse updatedRestResponse;
2259         List<String> variables = Arrays.asList("Resource", "tag");
2260
2261         for (int i = 0; i < notValidCharsArray.length; i++) {
2262             updatedTagField = "UpdatedTag" + notValidCharsArray[i];
2263             resourceTags = new ArrayList<String>();
2264             resourceTags.add(updatedTagField);
2265             resourceTags.add(resourceDetails.getName());
2266             // set description
2267             updatedResourceDetails.setTags(resourceTags);
2268
2269             updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2270                     resourceDetails.getUniqueId(), "");
2271             // validate response
2272             assertNotNull("check response object is not null after update resource", updatedRestResponse);
2273             assertNotNull("check error code exists in response after update resource",
2274                     updatedRestResponse.getErrorCode());
2275             ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2276                     updatedRestResponse.getResponse());
2277             assertEquals("Check response code after updating resource icon", 400,
2278                     updatedRestResponse.getErrorCode().intValue());
2279             assertEquals("Check response code after updating resource icon", "Bad Request",
2280                     updatedRestResponse.getResponseMessage().toString());
2281
2282         }
2283
2284     }
2285
2286     @Test
2287     public void UpdateResourceCategory_negativeFlow() throws Exception {
2288
2289         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2290         assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2291         Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2292         String uniqueID = resourceDetails.getUniqueId();
2293
2294         // Update resource Category Successfully
2295         ResourceReqDetails updatedResourceDetails = resourceDetails;
2296
2297         updatedResourceDetails.removeAllCategories();
2298         updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(),
2299                 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2300         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2301                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2302
2303         // validate response
2304         List<String> resourceList = new ArrayList<String>();
2305         resourceList.add(0, "Resource");
2306         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2307         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2308         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2309                 updatedRestResponse.getResponse());
2310         assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2311
2312         // Updating resource category
2313         updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2314         updatedResourceDetails.addCategory("");
2315         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2316                 resourceDetails.getUniqueId(), "");
2317         // validate response
2318         resourceList = new ArrayList<String>();
2319         resourceList.add(0, "Resource");
2320         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2321         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2322         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList,
2323                 updatedRestResponse.getResponse());
2324         assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2325
2326         // Updating resource category
2327         updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2328         updatedResourceDetails.addCategory("XXXXXX");
2329         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2330                 resourceDetails.getUniqueId(), "");
2331         // validate response
2332         resourceList = new ArrayList<String>();
2333         resourceList.add(0, "Resource");
2334         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2335         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2336         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2337                 updatedRestResponse.getResponse());
2338         assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2339
2340         // CheckIn Resource
2341         logger.debug("Changing resource life cycle ");
2342         RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2343                 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2344         assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2345
2346         // Update resource Category
2347         updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2348         updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2349         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2350                 resourceDetails.getUniqueId(), "");
2351         // verify response
2352         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2353         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2354         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List,
2355                 updatedRestResponse.getResponse());
2356         assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2357
2358         // CheckIn Resource
2359         logger.debug("Changing resource life cycle ");
2360         RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2361                 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2362         assertNotNull("check response object is not null after checkout resource", checkoutResource);
2363         assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2364         assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2365
2366         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2367         assertNotNull("check response object is not null after update resource", getRestResponse);
2368         parseResponseAndValidate(resourceDetails, getRestResponse);
2369
2370     }
2371
2372     @Test
2373     public void UpdateResourceCategorySuccessfully() throws Exception {
2374
2375         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2376         assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2377         Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2378
2379         // Update resource Category Successfully
2380         ResourceReqDetails updatedResourceDetails = resourceDetails;
2381
2382         updatedResourceDetails.removeAllCategories();
2383         updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(),
2384                 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2385         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2386                 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2387
2388         // validate response
2389         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2390         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2391         assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2392         // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2393         // updatedRestResponse);
2394         parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2395
2396         // validate category updated
2397         assertTrue(updatedResourceDetails.getCategories().get(0).getName()
2398                 .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2399
2400         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
2401                 resourceDetails.getUniqueId());
2402         assertNotNull("check response object is not null after update resource", getRestResponse);
2403         parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2404
2405         ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2406     }
2407
2408     // Benny
2409
2410     @Test
2411     public void Validation_UpdateIcon() throws Exception {
2412         // Fields to update (Forbidden)
2413         String _updatedIcon = "mySecondIcon.Jpg";
2414
2415         // administrator permissions
2416         User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2417
2418         // define and create resource
2419         ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2420
2421         RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2422         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2423         String resourceName = resourceDetails.getName();
2424
2425         // update metadata details
2426         ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2427         // change icon of metadata
2428         updatedResourceDetails.setIcon(_updatedIcon);
2429         // PUT request
2430         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2431                 sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2432
2433         // validate response
2434         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2435         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2436         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(),
2437                 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2438
2439         // empty icon
2440         _updatedIcon = "";
2441         updatedResourceDetails.setIcon(_updatedIcon);
2442         updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
2443                 resourceDetails.getUniqueId(), "");
2444         assertNotNull("check response object is not null after update resource", updatedRestResponse);
2445         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2446         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(),
2447                 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2448
2449         // get resource with original name. original metadata should be returned
2450         RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
2451                 resourceDetails.getUniqueId());
2452         // validate response
2453         assertNotNull("check response object is not null after get resource", getRestResponse);
2454         assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2455         assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2456
2457         // parse updated response to javaObject
2458         Resource getResourceRespJavaObject = ResponseParser
2459                 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
2460         // validate that metadata was not changed
2461         ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2462
2463         ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(),
2464                 "0.1");
2465
2466     }
2467
2468     @Test
2469     public void UpdateResourceTypeSuccess() throws Exception {
2470         // LCS is CheckOut
2471         String newResourceType = ResourceTypeEnum.VL.toString();
2472         String currentResourceType = resourceDetails.getResourceType();
2473         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2474         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2475         Resource currentResourceJavaObject = ResponseParser
2476                 .convertResourceResponseToJavaObject(restResponse.getResponse());
2477
2478         resourceDetails.setResourceType(newResourceType);
2479         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2480                 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2481         assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2482         Resource updatedResourceJavaObject = ResponseParser
2483                 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2484         // assertTrue("Check resource type after update resource",
2485         // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2486         assertTrue("Check resource type after update resource",
2487                 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2488
2489     }
2490
2491     @Test
2492     public void UpdateResourceTypeAndNameSuccess() throws Exception {
2493         // LCS is CheckOut
2494         String newResourceType = ResourceTypeEnum.VL.toString();
2495         String currentResourceType = resourceDetails.getResourceType();
2496         String newResourceName = "new Name";
2497
2498         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2499         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2500         Resource currentResourceJavaObject = ResponseParser
2501                 .convertResourceResponseToJavaObject(restResponse.getResponse());
2502
2503         resourceDetails.setResourceType(newResourceType);
2504         resourceDetails.setName(newResourceName);
2505         List<String> tags = resourceDetails.getTags();
2506         tags.add(newResourceName);
2507         resourceDetails.setTags(tags);
2508
2509         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2510                 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2511         assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2512         Resource updatedResourceJavaObject = ResponseParser
2513                 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2514         assertTrue("Check resource type after update resource",
2515                 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2516         assertTrue("Check resource name after update resource",
2517                 updatedResourceJavaObject.getName().equals(newResourceName));
2518
2519     }
2520
2521     @Test
2522     public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2523
2524         String newResourceType = ResourceTypeEnum.VF.toString();
2525         String currentResourceType = resourceDetails.getResourceType();
2526         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2527         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2528         Resource currentResourceJavaObject = ResponseParser
2529                 .convertResourceResponseToJavaObject(restResponse.getResponse());
2530
2531         resourceDetails.setResourceType(newResourceType);
2532         restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2533         assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2534         restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2535                 LifeCycleStatesEnum.CHECKOUT);
2536         assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2537         currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2538
2539         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2540                 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2541         assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2542         Resource updatedResourceJavaObject = ResponseParser
2543                 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2544         // assertTrue("Check resource type after update resource",
2545         // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2546         assertTrue("Check resource type after update resource",
2547                 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2548
2549     }
2550
2551     @Test
2552     public void UpdateResourceTypeCheckInLCS() throws Exception {
2553
2554         String resourceType = ResourceTypeEnum.VL.toString();
2555         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2556         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2557         Resource currentResourceJavaObject = ResponseParser
2558                 .convertResourceResponseToJavaObject(restResponse.getResponse());
2559
2560         resourceDetails.setResourceType(resourceType);
2561         restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2562                 LifeCycleStatesEnum.CHECKIN);
2563         assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2564
2565         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2566                 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2567
2568         ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2569
2570         assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2571         assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2572         assertEquals("Check response code after create resource", errorInfo.getCode(),
2573                 updatedRestResponse.getErrorCode());
2574
2575         List<String> variables = new ArrayList<>();
2576         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2577                 updatedRestResponse.getResponse());
2578
2579     }
2580
2581     @Test
2582     public void UpdateResourceTypeCertifiedLCS() throws Exception {
2583
2584         String resourceType = ResourceTypeEnum.VL.toString();
2585         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2586         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2587         Resource currentResourceJavaObject = ResponseParser
2588                 .convertResourceResponseToJavaObject(restResponse.getResponse());
2589
2590         restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2591         assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2592
2593         resourceDetails.setResourceType(resourceType);
2594         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2595                 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2596
2597         ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2598
2599         assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2600         assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2601         assertEquals("Check response code after create resource", errorInfo.getCode(),
2602                 updatedRestResponse.getErrorCode());
2603
2604         List<String> variables = new ArrayList<>();
2605         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2606                 updatedRestResponse.getResponse());
2607
2608     }
2609
2610     @Test
2611     public void UpdateResourceTypeInvalidType() throws Exception {
2612
2613         String resourceType = "INVALID TYPE";
2614         RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2615         assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2616         Resource currentResourceJavaObject = ResponseParser
2617                 .convertResourceResponseToJavaObject(restResponse.getResponse());
2618
2619         resourceDetails.setResourceType(resourceType);
2620         RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2621                 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2622
2623         ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2624
2625         assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2626         assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2627         assertEquals("Check response code after update resource", errorInfo.getCode(),
2628                 updatedRestResponse.getErrorCode());
2629
2630         List<String> variables = new ArrayList<>();
2631         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
2632                 updatedRestResponse.getResponse());
2633
2634     }
2635 }