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