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