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