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