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