2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.ci.tests.execute.resource;
23 import com.google.gson.Gson;
24 import org.json.JSONException;
25 import org.json.JSONObject;
26 import org.junit.rules.TestName;
27 import org.openecomp.sdc.be.dao.api.ActionStatus;
28 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
29 import org.openecomp.sdc.be.model.LifecycleStateEnum;
30 import org.openecomp.sdc.be.model.Resource;
31 import org.openecomp.sdc.be.model.User;
32 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
33 import org.openecomp.sdc.ci.tests.api.Urls;
34 import org.openecomp.sdc.ci.tests.config.Config;
35 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.*;
37 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
38 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
40 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
41 import org.openecomp.sdc.ci.tests.utils.DbUtils;
42 import org.openecomp.sdc.ci.tests.utils.Utils;
43 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
44 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
45 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
46 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
47 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
48 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
49 import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
50 import org.openecomp.sdc.common.util.ValidationUtils;
51 import org.slf4j.Logger;
52 import org.slf4j.LoggerFactory;
53 import org.testng.AssertJUnit;
54 import org.testng.annotations.BeforeMethod;
55 import org.testng.annotations.Test;
57 import java.io.FileNotFoundException;
60 import static org.testng.AssertJUnit.*;
62 public class UpdateResourceMetadataTest extends ComponentBaseTest {
63 private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
64 protected List<String> Empty_List = new ArrayList<String>();
65 protected String extendedChars;
67 protected final String contentTypeHeaderData = "application/json";
68 protected final String acceptHeaderDate = "application/json";
69 protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
71 public static TestName name = new TestName();
72 protected User sdncModifierDetails;
73 protected ResourceReqDetails resourceDetails;
75 public String extendedCharsStringBuilder() throws Exception {
76 char[] extendedCharsArray = new char[128];
78 for (int i = 0; i < extendedCharsArray.length - 1; i++) {
79 extendedCharsArray[i] = ch;
82 extendedChars = new String(extendedCharsArray);
88 public void setup() throws Exception {
89 sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
90 resourceDetails = defineResourse();
96 public void UpdateDerivedFromSuccess() throws Exception {
98 String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
99 String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
101 // Getting both derived from resources for validation
103 * RestResponse resourceByNameAndVersion =
104 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
105 * oldDerivedFromName, "1.0");
106 * assertEquals("Check response code after get database normative", 200,
107 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
108 * databaseNormative =
109 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
111 * resourceByNameAndVersion =
112 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
113 * newDerivedFromName, "1.0");
114 * assertEquals("Check response code after get database normative", 200,
115 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
117 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
120 // Derived from set to Database
121 List<String> derivedFrom = new ArrayList<>();
122 derivedFrom.add(oldDerivedFromName);
123 resourceDetails.setDerivedFrom(derivedFrom);
125 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
126 AssertJUnit.assertEquals("Check response code after create resource", 201,
127 restResponse.getErrorCode().intValue());
128 Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
131 derivedFrom.add(newDerivedFromName);
132 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
133 sdncModifierDetails, currentResource.getUniqueId(), "");
134 AssertJUnit.assertEquals("Check response code after create resource", 200,
135 updatedRestResponse.getErrorCode().intValue());
139 protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
140 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
142 updatedResourceDetails.setVersion("mumu");
143 updatedResourceDetails.setIsAbstract(true);
144 updatedResourceDetails.setIsHighestVersion(true);
145 updatedResourceDetails.setCreatorUserId("df4444");
146 updatedResourceDetails.setCreatorFullName("John Doe");
147 updatedResourceDetails.setLastUpdaterUserId("gf5646");
148 updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
149 updatedResourceDetails.setCreationDate(new Long(4444));
150 updatedResourceDetails.setLastUpdateDate(new Long("534535"));
151 updatedResourceDetails.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
152 updatedResourceDetails.setCost("6.1");
153 updatedResourceDetails.setLicenseType("Installation");
154 updatedResourceDetails.setUUID("dfsfsdf");
155 return updatedResourceDetails;
158 public void UpdateResourceNotFoundTest() throws Exception {
160 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
162 String resourceName = "cisco4";
164 String description = "updatedDescription";
165 ArrayList<String> resourceTags = new ArrayList<String>();
166 resourceTags.add("tag2");
167 String category = ServiceCategoriesEnum.MOBILITY.getValue();
168 ArrayList<String> derivedFrom = new ArrayList<String>();
169 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
170 String vendorName = "newOracle";
171 String vendorRelease = "2.5";
172 String contactId = "jh0003";
173 String icon = "myICON";
175 ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags,
176 category, derivedFrom, vendorName, vendorRelease, contactId, icon);
177 updatedResourceDetails.setUniqueId("dummyId");
178 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
179 sdncModifierDetails, "0.1");
182 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
183 AssertJUnit.assertNotNull("check error code exists in response after update resource",
184 updatedRestResponse.getErrorCode());
185 AssertJUnit.assertEquals("Check response code after update resource", 404,
186 updatedRestResponse.getErrorCode().intValue());
187 // String resourceId =
188 // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
189 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
190 updatedRestResponse.getResponse());
193 // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
195 updatedResourceDetails = defineUpdatedResourse(resourceName);
196 updatedResourceDetails.setUniqueId("dummyId");
197 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
199 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
200 AssertJUnit.assertNotNull("check error code exists in response after update resource",
201 updatedRestResponse.getErrorCode());
202 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
203 updatedRestResponse.getResponse());
207 public char[] getInValidChars() throws Exception {
209 char[] extendedCharsArray = new char[59];
211 for (int i = 0; i < 44; i++) {
212 extendedCharsArray[i] = ch;
216 for (int i = 44; i < 51; i++) {
217 extendedCharsArray[i] = ch;
221 for (int i = 51; i < 55; i++) {
222 extendedCharsArray[i] = ch;
226 for (int i = 55; i < 59; i++) {
227 extendedCharsArray[i] = ch;
230 return extendedCharsArray;
233 public char[] getTagInValidFormatChars() throws Exception {
234 // Tag format is the same as defined for "Resource Name" :
235 // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
236 // ('_'), dash ('-'), dot ('.')
237 char[] notValidCharsArray = new char[30];
239 for (int i = 0; i < 12; i++) {
240 notValidCharsArray[i] = ch;
243 notValidCharsArray[13] = 47;
245 for (int i = 14; i < 21; i++) {
246 notValidCharsArray[i] = ch;
250 for (int i = 21; i < 24; i++) {
251 notValidCharsArray[i] = ch;
254 notValidCharsArray[24] = 96;
256 for (int i = 25; i < 30; i++) {
257 notValidCharsArray[i] = ch;
260 return notValidCharsArray;
263 public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
265 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
267 // define and create resource
268 ResourceReqDetails resourceDetails = defineResourse();
269 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
270 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
271 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
273 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
274 String resourceId = resourceDetails.getUniqueId();
275 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
278 JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
280 List<String> resource = new ArrayList<>();
281 resource.add("Resource");
283 // remove Description
284 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description",
285 ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
287 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags",
288 ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
290 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category",
291 ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
293 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName",
294 ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
295 // remove VendorRelease
296 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease",
297 ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
298 // remove AT&T Contact
299 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId",
300 ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
302 // get resource with original name. original metadata should be returned
303 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
305 AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
306 AssertJUnit.assertNotNull("check error code exists in response after get resource",
307 getRestResponse.getErrorCode());
308 AssertJUnit.assertEquals("Check response code after update resource", 200,
309 getRestResponse.getErrorCode().intValue());
311 // parse updated response to javaObject
312 Resource getResourceRespJavaObject = ResponseParser
313 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
314 // validate that metadata was not changed
315 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
317 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
318 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
319 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
322 // End of validation tests
323 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
325 protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
326 String description = "updatedDescription";
327 ArrayList<String> resourceTags = new ArrayList<String>();
328 // Duplicate tags are allowed and should be de-duplicated by server side
329 resourceTags.add(resourceName);
330 resourceTags.add("tag1");
331 resourceTags.add("tag1");
332 resourceTags.add("tag2");
333 resourceTags.add("tag2");
334 String category = ServiceCategoriesEnum.VOIP.getValue();
335 ArrayList<String> derivedFrom = new ArrayList<String>();
336 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
337 String vendorName = "updatedOracle";
338 String vendorRelease = "3.5";
339 String contactId = "jh0001";
340 String icon = "myUpdatedICON";
342 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
343 derivedFrom, vendorName, vendorRelease, contactId, icon);
344 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
345 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
347 return resourceDetails;
350 protected ResourceReqDetails defineResourse() {
351 String resourceName = "cisco4";
352 String description = "description";
353 ArrayList<String> resourceTags = new ArrayList<String>();
354 resourceTags.add(resourceName);
355 ArrayList<String> derivedFrom = new ArrayList<String>();
356 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
357 String vendorName = "Oracle";
358 String vendorRelease = "1.5";
359 String contactId = "jh0003";
360 String icon = "objectStorage";
362 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null,
363 derivedFrom, vendorName, vendorRelease, contactId, icon);
364 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
365 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
367 return resourceDetails;
370 protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails)
373 DbUtils.cleanAllAudits();
376 RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
379 AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
380 AssertJUnit.assertNotNull("check error code exists in response after create resource",
381 restResponse.getErrorCode());
382 AssertJUnit.assertEquals("Check response code after create resource", 201,
383 restResponse.getErrorCode().intValue());
388 protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails,
389 String uri) throws Exception {
392 RestResponse ResourceResponse;
394 config = Utils.getConfig();
395 Map<String, String> headersMap = new HashMap<String, String>();
396 headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
397 headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
398 headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
399 HttpRequest http = new HttpRequest();
400 String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(),
401 config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
404 ResourceResponse = http.httpSendGet(url, headersMap);
405 } else if (uri == "POST") {
406 Gson gson = new Gson();
407 String userBodyJson = gson.toJson(updatedResourceDetails);
408 ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
409 } else if (uri == "DELETE") {
410 ResourceResponse = http.httpSendDelete(url, headersMap);
414 return ResourceResponse;
415 } catch (FileNotFoundException e) {
423 protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
424 // json object: resourceName and icon are must
425 JSONObject jObject = new JSONObject();
427 List<String> tagsList = Arrays.asList(resourceDetails.getName());
428 List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
430 jObject.put("name", resourceDetails.getName());
431 jObject.put("description", "updatedDescription");
432 jObject.put("tags", tagsList);
433 jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
434 jObject.put("derivedFrom", derivedFromList);
435 jObject.put("vendorName", "newOracle");
436 jObject.put("vendorRelease", "1.5");
437 jObject.put("contactId", "jh0003");
438 jObject.put("icon", resourceDetails.getIcon());
443 protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
444 jObject.remove(removedPropery);
449 // purpose: function for controlling json body fields and validating
451 protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject,
452 String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
454 JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
455 // remove description from jsonObject
456 jObject = RemoveFromJsonObject(jObject, removedField);
457 // update with incomplete body.
458 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(),
459 sdncModifierDetails, resourceId);
461 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
462 AssertJUnit.assertNotNull("check error code exists in response after update resource",
463 updatedRestResponse.getErrorCode());
464 ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
468 // purpose: function for validating error response
469 protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails,
470 String recievedMessage, List<String> variables) throws Exception {
471 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
472 sdncModifierDetails, "0.1");
474 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
475 AssertJUnit.assertNotNull("check error code exists in response after update resource",
476 updatedRestResponse.getErrorCode());
477 ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
481 protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse)
483 // parse response to javaObject
484 Resource updatedResourceRespJavaObject = ResponseParser
485 .convertResourceResponseToJavaObject(restResponse.getResponse());
486 AssertJUnit.assertTrue(
487 !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
488 AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
489 AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
490 AssertJUnit.assertTrue(
491 !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
492 AssertJUnit.assertTrue(
493 !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
494 AssertJUnit.assertTrue(
495 !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
497 .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
498 AssertJUnit.assertTrue(
499 !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
500 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName()
501 .equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
502 AssertJUnit.assertTrue(
503 !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
504 AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
506 .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
507 AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
511 protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse)
513 // parse response to javaObject
514 Resource updatedResourceRespJavaObject = ResponseParser
515 .convertResourceResponseToJavaObject(restResponse.getResponse());
516 // validate request vs response
517 ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
520 public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails,
521 String resourceVersion) {
523 ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
525 expectedResourceAuditJavaObject.setAction("Checkout");
526 expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
527 expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
528 expectedResourceAuditJavaObject.setStatus("200.0");
529 expectedResourceAuditJavaObject.setDesc("OK");
530 expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
531 expectedResourceAuditJavaObject.setResourceType("Resource");
532 expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
533 expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
534 expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
535 expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
537 return expectedResourceAuditJavaObject;
541 public enum FieldToValidate {
542 contactId, Tags, VendorName, VendorRelease, Description
546 public void UpdateBy_postTest() throws Exception {
548 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
549 String resourceName = resourceDetails.getName();
551 // update resource - without changing resourceName
552 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
554 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
557 assertNotNull("check response object is not null after update resource", updatedRestResponse);
558 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
559 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
560 updatedRestResponse.getResponse());
562 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
563 resourceDetails.getUniqueId());
564 assertNotNull("check response object is not null after update resource", getRestResponse);
565 parseResponseAndValidate(resourceDetails, getRestResponse);
570 public void UpdateBy_getTest() throws Exception {
572 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
573 String resourceName = resourceDetails.getName();
575 // update resource - without changing resourceName
576 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
577 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
580 assertNotNull("check response object is not null after update resource", updatedRestResponse);
581 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
582 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
583 updatedRestResponse.getResponse());
585 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
586 resourceDetails.getUniqueId());
587 assertNotNull("check response object is not null after update resource", getRestResponse);
588 parseResponseAndValidate(resourceDetails, getRestResponse);
593 public void UpdateBy_deleteTest() throws Exception {
595 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
596 String resourceName = resourceDetails.getName();
598 // update resource - without changing resourceName
599 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
600 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails,
604 assertNotNull("check response object is not null after update resource", updatedRestResponse);
605 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
606 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
607 updatedRestResponse.getResponse());
609 RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails,
610 resourceDetails.getUniqueId(), "");
611 assertNotNull("check response object is not null after update resource", getRestResponse);
612 parseResponseAndValidate(resourceDetails, getRestResponse);
619 public void UpdateWithInvaldJsonBodyTest() throws Exception {
621 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
622 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
623 String resourceId = resourceDetails.getUniqueId();
625 // update Descirption value
626 String description = "updatedDescription";
628 // send update with incompleted json, only description string
629 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails,
633 assertNotNull("check response object is not null after update resource", updatedRestResponse);
634 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
635 assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
637 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
638 resourceDetails.getUniqueId());
639 assertNotNull("check response object is not null after update resource", getRestResponse);
640 parseResponseAndValidate(resourceDetails, getRestResponse);
645 // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
648 // RestResponse restResponse = createResource(sdncModifierDetails,
650 // String resourceName = resourceDetails.getName();
652 // // new user parameters
653 // String userFirstName = "Kot";
654 // String userLastName = "Matroskin";
655 // String role = "ADMIN";
656 // User sdncUserDetails = new User(userFirstName, userLastName,
657 // httpCspUserId, email, role,null);
658 // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
659 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
661 // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
662 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
664 // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
665 // httpCspUserId, email,role,null);
666 // ResourceReqDetails updatedResourceDetails =
667 // defineUpdatedResourse(resourceName);
668 // RestResponse updatedRestResponse =
669 // ResourceRestUtils.updateResource(updatedResourceDetails,
670 // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
672 // // validate response
673 // assertNotNull("check response object is not null after update resource",
674 // updatedRestResponse);
675 // assertNotNull("check error code exists in response after update
676 // resource", updatedRestResponse.getErrorCode());
677 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
678 // Empty_List, updatedRestResponse.getResponse());
680 // RestResponse getRestResponse =
681 // ResourceRestUtils.getResource(sdncModifierDetails,
682 // resourceDetails.getUniqueId());
683 // assertNotNull("check response object is not null after update resource",
685 // parseResponseAndValidate(resourceDetails, getRestResponse);
691 public void UpdateResourceNameSensitiveTest() throws Exception {
692 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
693 String resourceBaseVersion = "0.1";
694 String resourceName = "Ab";
695 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
697 RestResponse response = null;
698 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
699 updatedResourceDetails.getName(), "0.1");
700 BaseRestUtils.checkDeleteResponse(response);
701 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
702 updatedResourceDetails.getName(), "0.2");
703 BaseRestUtils.checkDeleteResponse(response);
705 RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
706 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
709 logger.debug("Changing resource life cycle ");
710 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails,
711 sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
712 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
714 // String resourceCertifyVersion = "0.1";
715 logger.debug("Changing resource life cycle ");
716 checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails,
717 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
718 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
720 updatedResourceDetails.setName("ABC_-bt.aT");
721 ArrayList<String> resourceTag = new ArrayList<String>();
722 resourceTag.add(0, "ABC_-bt.aT");
723 updatedResourceDetails.setTags(resourceTag);
724 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
725 sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
726 assertNotNull("check response object is not null after update resource", updatedRestResponse);
727 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
728 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
729 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
732 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
733 updatedResourceDetails.getName(), "0.1");
734 BaseRestUtils.checkDeleteResponse(response);
735 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
736 updatedResourceDetails.getName(), "0.2");
737 BaseRestUtils.checkDeleteResponse(response);
742 public void UpdateIcon_InegativeFlow() throws Exception {
744 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
745 String resourceName = resourceDetails.getName();
747 List<String> resourceList = new ArrayList<String>();
748 resourceList.add(0, "Resource");
749 // check InValid Characters
750 char[] notValidCharsArray = new char[59];
751 notValidCharsArray = getInValidChars();
752 // update metadata details
753 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
754 RestResponse updatedRestResponse;
756 for (int i = 0; i < notValidCharsArray.length; i++) {
757 // change icon of metadata
758 updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
760 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
761 resourceDetails.getUniqueId(), "");
763 assertNotNull("check response object is not null after update resource", updatedRestResponse);
764 assertNotNull("check error code exists in response after update resource",
765 updatedRestResponse.getErrorCode());
766 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList,
767 updatedRestResponse.getResponse());
768 assertEquals("Check response code after updating resource icon", 400,
769 updatedRestResponse.getErrorCode().intValue());
770 assertEquals("Check response code after updating resource icon", "Bad Request",
771 updatedRestResponse.getResponseMessage().toString());
776 String updateIcon = "";
777 updatedResourceDetails.setIcon(updateIcon);
778 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
779 resourceDetails.getUniqueId(), "");
780 assertNotNull("check response object is not null after update resource", updatedRestResponse);
781 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
782 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList,
783 updatedRestResponse.getResponse());
785 // Icon length more then 25 characters
786 resourceList.add(1, "25");
787 updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
788 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
789 resourceDetails.getUniqueId(), "");
791 assertNotNull("check response object is not null after update resource", updatedRestResponse);
792 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
793 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList,
794 updatedRestResponse.getResponse());
795 assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
796 assertEquals("Check response code after updating resource icon", "Bad Request",
797 updatedRestResponse.getResponseMessage().toString());
799 // get resource with original name. original metadata should be returned
800 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
801 resourceDetails.getUniqueId());
803 assertNotNull("check response object is not null after get resource", getRestResponse);
804 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
805 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
807 // parse updated response to javaObject
808 Resource getResourceRespJavaObject = ResponseParser
809 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
810 // validate that metadata was not changed
811 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
816 public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
818 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
819 String resourceBaseVersion = "0.1";
822 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
823 String resourceName = resourceDetails.getName();
825 ResourceReqDetails updatedResourceDetails = defineResourse();
826 updatedResourceDetails.setName("updatedResourceName");
827 List<String> tags = updatedResourceDetails.getTags();
829 for (Iterator<String> iter = tags.listIterator(); iter.hasNext(); ) {
830 String a = iter.next();
831 if (a.equals("updatedResourceName")) {
836 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
837 sdncModifierDetails, resourceDetails.getUniqueId(), "");
839 List<String> resourceList = new ArrayList<String>();
840 assertNotNull("check response object is not null after update resource", updatedRestResponse);
841 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
842 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
843 resourceList, updatedRestResponse.getResponse());
844 assertEquals("Check response code after updating resource icon", 400,
845 updatedRestResponse.getErrorCode().intValue());
847 // get resource with original name. original metadata should be returned
848 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
849 resourceDetails.getUniqueId());
851 assertNotNull("check response object is not null after get resource", getRestResponse);
852 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
853 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
854 // parse updated response to javaObject
855 Resource getResourceRespJavaObject = ResponseParser
856 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
857 // validate that metadata was not changed
858 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
863 public void UpdateResourceName_negativeFlow() throws Exception {
864 // The validation are done in Tag's validation
865 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
867 RestResponse updatedRestResponse;
868 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
869 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
870 String uniqueId = resourceDetails.getUniqueId();
871 String resourceName = resourceDetails.getName();
872 // check InValid Characters
873 char[] notValidCharsArray = new char[59];
874 notValidCharsArray = getInValidChars();
875 ArrayList<String> resource_Name = new ArrayList<String>();
876 List<String> resourceList = new ArrayList<String>();
878 ArrayList<String> resourceTags = new ArrayList<String>();
879 resourceList.add(0, "Resource");
881 // update metadata details
882 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
883 for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
884 if (i != 1 && i != 46
886 * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
887 */ i != 31) // space ("") and dot(.)
889 // change resourceName parameter
890 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
891 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
892 updatedResourceDetails.setTags(resource_Name);
893 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
894 sdncAdminModifierDetails, uniqueId, "");
896 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
897 // Empty_List, updatedRestResponse.getResponse());
898 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList,
899 updatedRestResponse.getResponse());
904 // resourceName length more then 50 characters
905 // Duplicate tags are allowed and should be de-duplicated by server side
906 resource_Name.add(resourceName);
907 resource_Name.add("tag1");
908 resource_Name.add("tag1");
909 resource_Name.add("tag2");
910 resource_Name.add("tag2");
912 resourceList.add(1, "1024");
913 // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
914 updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
915 // resource_Name.add("123456789012345678901234567890123456789012345678901");
916 updatedResourceDetails.setTags(resource_Name);
917 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
920 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList,
921 updatedRestResponse.getResponse());
923 // get resource with original name. original metadata should be returned
924 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
925 resourceDetails.getUniqueId());
927 assertNotNull("check response object is not null after get resource", getRestResponse);
928 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
929 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
930 // parse updated response to javaObject
931 Resource getResourceRespJavaObject = ResponseParser
932 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
933 // validate that metadata was not changed
934 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
937 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails,
938 updatedResourceDetails.getName(), "0.1");
939 BaseRestUtils.checkDeleteResponse(response);
943 public void UpdateResourceInformation_NotCheckedOut() throws Exception {
945 String resourceBaseVersion = "0.1";
946 List<String> resourceList = new ArrayList<String>();
948 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
949 String resourceName = resourceDetails.getName();
952 logger.debug("Changing resource life cycle ");
953 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
954 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
955 assertNotNull("check response object is not null after checkout resource", checkoutResource);
956 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
957 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
959 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
961 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
962 sdncModifierDetails, resourceDetails.getUniqueId(), "");
963 assertNotNull("check response object is not null after update resource", updatedRestResponse);
964 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
965 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
966 updatedRestResponse.getResponse());
967 assertEquals("Check response code after updating resource icon", 409,
968 updatedRestResponse.getErrorCode().intValue());
970 // get resource with original name. original metadata should be returned
971 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
972 resourceDetails.getUniqueId());
974 assertNotNull("check response object is not null after get resource", getRestResponse);
975 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
976 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
978 // parse updated response to javaObject
979 Resource getResourceRespJavaObject = ResponseParser
980 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
981 // validate that metadata was not changed
982 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
987 public void UpdateResourceInformation_resourceVersion_11() throws Exception {
989 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
990 String resourceBaseVersion = "0.1";
993 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
994 String resourceName = resourceDetails.getName();
996 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1000 logger.debug("Changing resource life cycle ");
1001 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1002 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1003 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1005 /*logger.debug("Changing resource life cycle ");
1006 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1007 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1008 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1010 logger.debug("Changing resource life cycle ");
1011 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1012 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1013 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1015 logger.debug("Changing resource life cycle ");
1016 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1017 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1018 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1020 String resourceCertifyVersion = "1.0";
1021 logger.debug("Changing resource life cycle ");
1022 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1023 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
1024 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1026 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1028 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1029 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1030 // validate response
1031 List<String> resourceList = new ArrayList<String>();
1032 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1033 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1034 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
1035 updatedRestResponse.getResponse());
1036 // assertEquals("Check response code after updating resource icon", 409,
1037 // updatedRestResponse.getErrorCode().intValue());
1039 // get resource with original name. original metadata should be returned
1040 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1041 resourceDetails.getUniqueId());
1042 // validate response
1043 assertNotNull("check response object is not null after get resource", getRestResponse);
1045 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1047 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1048 // parse updated response to javaObject
1049 Resource getResourceRespJavaObject = ResponseParser
1050 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1051 // validate that metadata was not changed
1052 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1057 public void UpdateResourceInformation_resourceVersion_02() throws Exception {
1059 String resourceBaseVersion = "0.1";
1062 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1063 String resourceName = resourceDetails.getName();
1065 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1069 logger.debug("Changing resource life cycle ");
1070 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1071 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1072 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1074 // String resourceCertifyVersion = "0.1";
1075 logger.debug("Changing resource life cycle ");
1076 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1077 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
1078 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1080 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1082 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1083 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1084 // validate response
1085 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1086 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1087 assertEquals("Check response code after updating resource icon", 200,
1088 updatedRestResponse.getErrorCode().intValue());
1090 // get resource with original name. original metadata should be returned
1091 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1092 resourceDetails.getUniqueId());
1093 // validate response
1094 assertNotNull("check response object is not null after get resource", getRestResponse);
1095 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1096 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1098 // parse updated response to javaObject
1099 Resource getResourceRespJavaObject = ResponseParser
1100 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1101 // validate that metadata was not changed
1102 ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
1105 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1106 updatedResourceDetails.getName(), "0.1");
1107 BaseRestUtils.checkDeleteResponse(response);
1108 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1109 updatedResourceDetails.getName(), "0.2");
1110 BaseRestUtils.checkDeleteResponse(response);
1115 public void UpdateResourceIcon_resourceVersion_11() throws Exception {
1116 // Can be changed only if major version is "0".
1118 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1119 String resourceBaseVersion = "0.1";
1122 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1123 String resourceName = resourceDetails.getName();
1125 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1129 logger.debug("Changing resource life cycle ");
1130 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1131 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1132 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1134 /*logger.debug("Changing resource life cycle ");
1135 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1136 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1137 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1139 logger.debug("Changing resource life cycle ");
1140 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1141 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1142 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1144 logger.debug("Changing resource life cycle ");
1145 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1146 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1147 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1149 String resourceCertifyVersion = "1.0";
1150 logger.debug("Changing resource life cycle ");
1151 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1152 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1153 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1155 // ResourceReqDetails updatedResourceDetails =
1156 // defineUpdatedResourse(resourceName);
1157 ResourceReqDetails updatedResourceDetails = defineResourse();
1158 // updatedResourceDetails.setVendorName("updatedVandorName");
1159 updatedResourceDetails.setIcon("updatedIcon");
1161 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1162 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1163 // validate response
1164 List<String> resourceList = new ArrayList<String>();
1165 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList,
1166 updatedRestResponse.getResponse());
1168 // get resource with original name. original metadata should be returned
1169 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1170 resourceDetails.getUniqueId());
1171 // validate response
1172 assertNotNull("check response object is not null after get resource", getRestResponse);
1173 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1174 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1175 // parse updated response to javaObject
1176 Resource getResourceRespJavaObject = ResponseParser
1177 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1178 // validate that metadata was not changed
1179 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1184 public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1185 // Can be changed only if the major resource version is "0".
1186 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1187 String resourceBaseVersion = "0.1";
1190 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1191 String resourceName = resourceDetails.getName();
1193 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1197 logger.debug("Changing resource life cycle ");
1198 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1199 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1200 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1202 /*logger.debug("Changing resource life cycle ");
1203 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1204 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1205 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1207 logger.debug("Changing resource life cycle ");
1208 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1209 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1210 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1212 logger.debug("Changing resource life cycle ");
1213 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1214 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1215 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1217 String resourceCertifyVersion = "1.0";
1218 logger.debug("Changing resource life cycle ");
1219 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1220 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1221 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1223 // ResourceReqDetails updatedResourceDetails =
1224 // defineUpdatedResourse(resourceName);
1225 ResourceReqDetails updatedResourceDetails = defineResourse();
1227 updatedResourceDetails.setVendorName("updatedVandorName");
1229 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1230 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1231 // validate response
1232 List<String> resourceList = new ArrayList<String>();
1233 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1234 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1235 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(),
1236 resourceList, updatedRestResponse.getResponse());
1237 assertEquals("Check response code after updating resource icon", 400,
1238 updatedRestResponse.getErrorCode().intValue());
1240 // get resource with original name. original metadata should be returned
1241 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1242 resourceDetails.getUniqueId());
1243 // validate response
1244 assertNotNull("check response object is not null after get resource", getRestResponse);
1245 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1246 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1247 // parse updated response to javaObject
1248 Resource getResourceRespJavaObject = ResponseParser
1249 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1250 // validate that metadata was not changed
1251 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1256 public void UpdateResourceName_resourceVersion_11() throws Exception {
1257 // Can be changed only if the major resource version is "0".
1258 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1259 String resourceBaseVersion = "0.1";
1262 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1263 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1264 String resourceName = resourceDetails.getName();
1266 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1270 logger.debug("Changing resource life cycle ");
1271 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1272 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1273 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1275 /*logger.debug("Changing resource life cycle ");
1276 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1277 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1278 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1280 logger.debug("Changing resource life cycle ");
1281 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1282 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1283 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1285 logger.debug("Changing resource life cycle ");
1286 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1287 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1288 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1290 String resourceCertifyVersion = "1.0";
1291 logger.debug("Changing resource life cycle ");
1292 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1293 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1294 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1297 * //ResourceReqDetails updatedResourceDetails =
1298 * defineUpdatedResourse(resourceName); ResourceReqDetails
1299 * updatedResourceDetails = defineResourse();
1301 * updatedResourceDetails.setResourceName("updatedResourceName");
1302 * updatedResourceDetails.setIcon("updatedResourceName");
1304 resourceDetails.setName("updatedResourceName");
1305 List<String> tagList = new ArrayList<String>();
1306 tagList.add(0, "updatedResourceName");
1307 resourceDetails.setTags(tagList);
1309 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1310 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1311 // validate response
1312 List<String> resourceList = new ArrayList<String>();
1313 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1314 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1315 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList,
1316 updatedRestResponse.getResponse());
1321 public void UpdateResourceTag_resourceVersion_11() throws Exception {
1322 // Tag Can be updated when major version is "0".
1323 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1324 String resourceBaseVersion = "0.1";
1327 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1328 String resourceName = resourceDetails.getName();
1330 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1334 logger.debug("Changing resource life cycle ");
1335 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1336 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1337 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1339 /*logger.debug("Changing resource life cycle ");
1340 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1341 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1342 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1344 logger.debug("Changing resource life cycle ");
1345 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1346 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1347 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1349 logger.debug("Changing resource life cycle ");
1350 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1351 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1352 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1354 String resourceCertifyVersion = "1.0";
1355 logger.debug("Changing resource life cycle ");
1356 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1357 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1358 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1360 // ResourceReqDetails updatedResourceDetails =
1361 // defineUpdatedResourse(resourceName);
1362 ResourceReqDetails updatedResourceDetails = defineResourse();
1363 // updatedResourceDetails.setVendorName("updatedVandorName");
1365 ArrayList<String> resourceTags = new ArrayList<String>();
1366 resourceTags.add("NewTag");
1367 resourceTags.add(resourceDetails.getName());
1369 updatedResourceDetails.setTags(resourceTags);
1371 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1372 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1373 // validate response
1374 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1375 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1376 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1378 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1379 resourceDetails.getUniqueId());
1380 assertNotNull("check response object is not null after update resource", getRestResponse);
1381 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1386 public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1388 // Tag, contactId, vendorRelease,tags And description - Can be also
1389 // updated when major version is NOT "0".
1390 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1391 String resourceBaseVersion = "0.1";
1394 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1396 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1400 logger.debug("Changing resource life cycle ");
1401 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1402 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1403 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1405 /*logger.debug("Changing resource life cycle ");
1406 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1407 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1408 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1410 logger.debug("Changing resource life cycle ");
1411 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1412 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1413 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1415 logger.debug("Changing resource life cycle ");
1416 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1417 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1418 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1420 String resourceCertifyVersion = "1.0";
1421 logger.debug("Changing resource life cycle ");
1422 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1423 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1424 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1426 // ResourceReqDetails updatedResourceDetails =
1427 // defineUpdatedResourse(resourceName);
1428 ResourceReqDetails updatedResourceDetails = defineResourse();
1429 // updatedResourceDetails.setVendorName("updatedVandorName");
1431 // updated allowed parameters when major resource version is NOT "0"
1432 ArrayList<String> resourceTags = new ArrayList<String>();
1433 resourceTags.add("NewTag");
1434 resourceTags.add(resourceDetails.getName());
1435 updatedResourceDetails.setTags(resourceTags);
1436 updatedResourceDetails.setDescription("UpdatedDescription");
1437 updatedResourceDetails.setVendorRelease("5.1");
1438 updatedResourceDetails.setContactId("bt750h");
1440 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1441 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1442 // validate response
1443 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1444 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1445 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1447 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1448 resourceDetails.getUniqueId());
1449 assertNotNull("check response object is not null after update resource", getRestResponse);
1450 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1455 public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1456 // DerivedFrom parameter - Can be updated when major version is "0".
1457 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1458 String resourceBaseVersion = "0.1";
1461 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1462 String resourceName = resourceDetails.getName();
1464 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1468 logger.debug("Changing resource life cycle ");
1469 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1470 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1471 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1473 /*logger.debug("Changing resource life cycle ");
1474 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1475 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1476 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1478 logger.debug("Changing resource life cycle ");
1479 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1480 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1481 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1483 logger.debug("Changing resource life cycle ");
1484 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1485 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1486 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1488 String resourceCertifyVersion = "1.0";
1489 logger.debug("Changing resource life cycle ");
1490 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1491 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1492 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1494 // ResourceReqDetails updatedResourceDetails =
1495 // defineUpdatedResourse(resourceName);
1496 ResourceReqDetails updatedResourceDetails = defineResourse();
1497 ArrayList<String> drivenFrom = new ArrayList<String>();
1498 drivenFrom.add(0, "tosca.nodes.Container.Application");
1499 updatedResourceDetails.setDerivedFrom(drivenFrom);
1501 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1502 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1503 // validate response
1504 List<String> resourceList = new ArrayList<String>();
1505 ResourceRestUtils.checkSuccess(updatedRestResponse);
1507 // get resource with original name. original metadata should be returned
1508 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1509 resourceDetails.getUniqueId());
1510 // validate response
1511 assertNotNull("check response object is not null after get resource", getRestResponse);
1512 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1513 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1514 // parse updated response to javaObject
1515 Resource getResourceRespJavaObject = ResponseParser
1516 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1517 // validate that metadata was not changed
1518 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1523 public void UpdateResource_vendorNameValidation() throws Exception {
1525 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1526 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1527 String updatedVendorName = "";
1528 String uniqueId = resourceDetails.getUniqueId();
1529 resourceDetails.setVendorName(updatedVendorName);
1530 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1531 sdncModifierDetails, uniqueId, "");
1532 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1533 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1534 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1535 updatedRestResponse.getResponse());
1537 // update resource vendorName metadata: 1 characters
1538 updatedVendorName = " ";
1540 resourceDetails.setVendorName(updatedVendorName);
1541 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1543 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1544 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1545 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1546 updatedRestResponse.getResponse());
1548 // update resource vendorName metadata: 25 characters
1549 updatedVendorName = "Verification and validati";
1551 resourceDetails.setVendorName(updatedVendorName);
1552 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1554 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1555 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1556 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1557 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1559 // update resource vendorName metadata: 26 characters
1560 updatedVendorName = "Verification and validatii";
1562 List<String> myList = new ArrayList<String>();
1563 myList.add(0, "25");
1564 resourceDetails.setVendorName(updatedVendorName);
1565 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1567 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1568 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList,
1569 updatedRestResponse.getResponse());
1571 // update resource VendorRelease metadata: forbidden characters
1572 updatedVendorName = "A1<";
1574 resourceDetails.setVendorName(updatedVendorName);
1575 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1577 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1578 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1579 updatedRestResponse.getResponse());
1581 updatedVendorName = "A1>";
1583 resourceDetails.setVendorName(updatedVendorName);
1584 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1586 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1587 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1588 updatedRestResponse.getResponse());
1590 updatedVendorName = "A1:";
1592 resourceDetails.setVendorName(updatedVendorName);
1593 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1595 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1596 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1597 updatedRestResponse.getResponse());
1599 updatedVendorName = "A1\"";
1601 resourceDetails.setVendorName(updatedVendorName);
1602 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1604 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1605 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1606 updatedRestResponse.getResponse());
1608 updatedVendorName = "A1/";
1610 resourceDetails.setVendorName(updatedVendorName);
1611 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1613 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1614 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1615 updatedRestResponse.getResponse());
1617 updatedVendorName = "A1\\";
1619 resourceDetails.setVendorName(updatedVendorName);
1620 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1622 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1623 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1624 updatedRestResponse.getResponse());
1626 updatedVendorName = "A1|";
1628 resourceDetails.setVendorName(updatedVendorName);
1629 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1631 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1632 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1633 updatedRestResponse.getResponse());
1635 updatedVendorName = "A1?";
1637 resourceDetails.setVendorName(updatedVendorName);
1638 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1640 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1641 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1642 updatedRestResponse.getResponse());
1644 updatedVendorName = "A1*";
1646 resourceDetails.setVendorName(updatedVendorName);
1647 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1649 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1650 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1651 updatedRestResponse.getResponse());
1653 // update resource vendorName metadata: null
1654 updatedVendorName = null;
1656 resourceDetails.setVendorName(updatedVendorName);
1657 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1659 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1660 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1661 updatedRestResponse.getResponse());
1666 public void UpdateResource_vendorReleaseValidation() throws Exception {
1668 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1669 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1670 RestResponse updatedRestResponse;
1671 String uniqueId = resourceDetails.getUniqueId();
1672 String updatedVendorRelease;
1673 // set VendorRelease
1675 // update resource VendorRelease metadata: 1 characters
1676 updatedVendorRelease = "1";
1677 // set VendorRelease
1678 resourceDetails.setVendorRelease(updatedVendorRelease);
1679 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1681 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1682 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1683 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1684 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1686 // update resource VendorRelease metadata: 25 characters
1687 updatedVendorRelease = "(!#1.00000000000000000000";
1688 // set VendorRelease
1689 resourceDetails.setVendorRelease(updatedVendorRelease);
1690 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1692 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1693 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1694 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1695 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1697 // update resource VendorRelease metadata: 26 characters
1698 updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1699 resourceDetails.setVendorRelease(updatedVendorRelease);
1700 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1702 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1703 Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1705 // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1706 // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1707 // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1709 // update resource VendorRelease metadata: forbidden characters
1710 updatedVendorRelease = "A1<";
1711 // set VendorRelease
1712 resourceDetails.setVendorRelease(updatedVendorRelease);
1713 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1715 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1716 updatedRestResponse.getResponse());
1718 updatedVendorRelease = "A1>";
1719 // set VendorRelease
1720 resourceDetails.setVendorRelease(updatedVendorRelease);
1721 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1723 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1724 updatedRestResponse.getResponse());
1726 updatedVendorRelease = "A1:";
1727 // set VendorRelease
1728 resourceDetails.setVendorRelease(updatedVendorRelease);
1729 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1731 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1732 updatedRestResponse.getResponse());
1734 updatedVendorRelease = "A1\"";
1735 // set VendorRelease
1736 resourceDetails.setVendorRelease(updatedVendorRelease);
1737 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1739 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1740 updatedRestResponse.getResponse());
1742 updatedVendorRelease = "A1/";
1743 // set VendorRelease
1744 resourceDetails.setVendorRelease(updatedVendorRelease);
1745 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1747 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1748 updatedRestResponse.getResponse());
1750 updatedVendorRelease = "A1\\";
1751 // set VendorRelease
1752 resourceDetails.setVendorRelease(updatedVendorRelease);
1753 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1755 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1756 updatedRestResponse.getResponse());
1758 updatedVendorRelease = "A1|";
1759 // set VendorRelease
1760 resourceDetails.setVendorRelease(updatedVendorRelease);
1761 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1763 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1764 updatedRestResponse.getResponse());
1766 updatedVendorRelease = "A1?";
1767 // set VendorRelease
1768 resourceDetails.setVendorRelease(updatedVendorRelease);
1769 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1771 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1772 updatedRestResponse.getResponse());
1774 updatedVendorRelease = "A1*";
1775 // set VendorRelease
1776 resourceDetails.setVendorRelease(updatedVendorRelease);
1777 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1779 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1780 updatedRestResponse.getResponse());
1782 // update resource VendorRelease metadata: null
1783 updatedVendorRelease = null;
1784 // set VendorRelease
1785 resourceDetails.setVendorRelease(updatedVendorRelease);
1786 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1788 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1789 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List,
1790 updatedRestResponse.getResponse());
1795 public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1816 RestResponse updatedRestResponse;
1818 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1819 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1820 String uniqueId = resourceDetails.getUniqueId();
1822 List<String> myList = new ArrayList<String>();
1823 myList.add(0, "Resource");
1824 String updatedcontactId = "";
1825 resourceDetails.setContactId(updatedcontactId);
1827 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1829 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1830 updatedRestResponse.getResponse());
1832 updatedcontactId = "ab12345";
1833 resourceDetails.setContactId(updatedcontactId);
1834 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1836 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1837 updatedRestResponse.getResponse());
1839 updatedcontactId = " ";
1840 resourceDetails.setContactId(updatedcontactId);
1841 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1843 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1844 updatedRestResponse.getResponse());
1846 updatedcontactId = "ab 50h";
1847 resourceDetails.setContactId(updatedcontactId);
1848 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1850 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1851 updatedRestResponse.getResponse());
1853 updatedcontactId = "ab123c";
1854 resourceDetails.setContactId(updatedcontactId);
1855 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1857 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1858 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1859 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1861 updatedcontactId = "cd789E";
1862 resourceDetails.setContactId(updatedcontactId);
1863 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1865 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1866 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1868 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1869 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1871 updatedcontactId = "ef4567";
1872 resourceDetails.setContactId(updatedcontactId);
1873 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1875 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1876 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1877 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1878 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1880 updatedcontactId = "AA012A";
1881 resourceDetails.setContactId(updatedcontactId);
1882 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1884 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1885 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1886 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1888 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1889 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1891 updatedcontactId = "CD012c";
1892 resourceDetails.setContactId(updatedcontactId);
1893 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
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());
1899 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1900 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1902 updatedcontactId = "EF0123";
1903 resourceDetails.setContactId(updatedcontactId);
1904 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1906 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1907 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1908 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1910 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1911 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1913 ////////////////////////////// **************//////////////////////////////
1914 List<String> resource = Arrays.asList("Resource");
1915 updatedcontactId = "01345a";
1916 resourceDetails.setContactId(updatedcontactId);
1917 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1919 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1920 updatedRestResponse.getResponse());
1922 updatedcontactId = "0y000B";
1923 resourceDetails.setContactId(updatedcontactId);
1924 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1926 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1927 updatedRestResponse.getResponse());
1929 updatedcontactId = "Y1000b";
1930 resourceDetails.setContactId(updatedcontactId);
1931 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1933 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1934 updatedRestResponse.getResponse());
1936 updatedcontactId = "abxyzC";
1937 resourceDetails.setContactId(updatedcontactId);
1938 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1940 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1941 updatedRestResponse.getResponse());
1943 updatedcontactId = "cdXYZc";
1944 resourceDetails.setContactId(updatedcontactId);
1945 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1947 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1948 updatedRestResponse.getResponse());
1950 updatedcontactId = "efXY1D";
1951 resourceDetails.setContactId(updatedcontactId);
1952 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1954 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1955 updatedRestResponse.getResponse());
1957 updatedcontactId = "EFabcD";
1958 resourceDetails.setContactId(updatedcontactId);
1959 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1961 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1962 updatedRestResponse.getResponse());
1964 updatedcontactId = "EFABCD";
1965 resourceDetails.setContactId(updatedcontactId);
1966 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1968 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1969 updatedRestResponse.getResponse());
1971 updatedcontactId = "EFABC1";
1972 resourceDetails.setContactId(updatedcontactId);
1973 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1975 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1976 updatedRestResponse.getResponse());
1978 updatedcontactId = "efui1D";
1979 resourceDetails.setContactId(updatedcontactId);
1980 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1982 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1983 updatedRestResponse.getResponse());
1985 updatedcontactId = "efui1!";
1986 resourceDetails.setContactId(updatedcontactId);
1987 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1989 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1990 updatedRestResponse.getResponse());
1992 updatedcontactId = "ef555!";
1993 resourceDetails.setContactId(updatedcontactId);
1994 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1996 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1997 updatedRestResponse.getResponse());
1999 updatedcontactId = ",f555";
2000 resourceDetails.setContactId(updatedcontactId);
2001 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2003 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2004 updatedRestResponse.getResponse());
2006 updatedcontactId = "EF55.5";
2007 resourceDetails.setContactId(updatedcontactId);
2008 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2010 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2011 updatedRestResponse.getResponse());
2013 // update resource contactId metadata: extended character set (128–255)
2014 resourceDetails.setContactId(extendedCharsStringBuilder());
2015 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2017 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2018 updatedRestResponse.getResponse());
2020 // update resource contactId metadata: null
2021 updatedcontactId = null;
2022 resourceDetails.setContactId(updatedcontactId);
2023 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2025 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
2026 updatedRestResponse.getResponse());
2031 public void UpdateResource_TagsFieldValidation() throws Exception {
2032 RestResponse updatedRestResponse;
2033 // define and create resource
2035 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2036 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2037 String uniqueId = resourceDetails.getUniqueId();
2039 String updatedTagField = "";
2040 ArrayList<String> resourceTags = new ArrayList<String>();
2041 resourceTags.add(updatedTagField);
2043 resourceDetails.setTags(resourceTags);
2044 List<String> variables = Arrays.asList("Resource", "tag");
2045 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2047 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2048 updatedRestResponse.getResponse());
2050 // update resource tags metadata: empty
2051 resourceTags = new ArrayList<String>();
2053 resourceDetails.setTags(resourceTags);
2054 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2056 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List,
2057 updatedRestResponse.getResponse());
2059 // update resource description metadata: 1 characters
2060 updatedTagField = "A";
2061 resourceTags = new ArrayList<String>();
2062 resourceTags.add(updatedTagField);
2063 resourceTags.add(resourceDetails.getName());
2065 resourceDetails.setTags(resourceTags);
2066 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2068 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2069 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2070 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2071 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2073 // OK - tag up to 50 chars
2074 updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
2075 resourceTags.add(updatedTagField);
2076 resourceDetails.setTags(resourceTags);
2077 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2079 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2080 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2081 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2082 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2084 // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
2085 String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
2086 String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
2087 String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
2088 String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
2089 String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
2090 String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
2091 String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
2092 String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
2093 String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
2094 String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
2095 String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
2096 String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
2097 String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
2098 String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
2099 String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
2100 String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
2101 String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
2102 String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
2103 String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
2105 resourceTags = new ArrayList<String>();
2106 resourceTags.add(updatedTagField);
2107 resourceTags.add(updatedTagField1);
2108 resourceTags.add(updatedTagField2);
2109 resourceTags.add(updatedTagField3);
2110 resourceTags.add(updatedTagField4);
2111 resourceTags.add(updatedTagField5);
2112 resourceTags.add(updatedTagField6);
2113 resourceTags.add(updatedTagField7);
2114 resourceTags.add(updatedTagField8);
2115 resourceTags.add(updatedTagField9);
2116 resourceTags.add(updatedTagField10);
2117 resourceTags.add(updatedTagField11);
2118 resourceTags.add(updatedTagField12);
2119 resourceTags.add(updatedTagField13);
2120 resourceTags.add(updatedTagField14);
2121 resourceTags.add(updatedTagField15);
2122 resourceTags.add(updatedTagField16);
2123 resourceTags.add(updatedTagField17);
2124 resourceTags.add(updatedTagField18);
2125 resourceTags.add(updatedTagField19);
2126 resourceTags.add(resourceDetails.getName());
2128 resourceDetails.setTags(resourceTags);
2129 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2131 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2132 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2133 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2134 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2136 // Add another tag-exceeds limit
2137 resourceTags.add("d");
2138 resourceDetails.setTags(resourceTags);
2139 ArrayList<String> myArray = new ArrayList<String>();
2140 myArray.add(0, "1024");
2141 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2143 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray,
2144 updatedRestResponse.getResponse());
2146 // Tag exceeds limit - 51
2147 resourceTags = new ArrayList<String>();
2148 updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
2149 resourceTags.add(updatedTagField);
2150 resourceTags.add(resourceDetails.getName());
2152 resourceDetails.setTags(resourceTags);
2154 myArray.add(0, "50");
2155 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2157 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray,
2158 updatedRestResponse.getResponse());
2163 public void UpdateResource_DesriptionFieldValidation() throws Exception {
2164 // define and create resource
2165 RestResponse updatedRestResponse;
2167 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2168 String uniqueId = resourceDetails.getUniqueId();
2169 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2170 List<String> resource = new ArrayList<>();
2171 resource.add("Resource");
2172 // update resource description metadata: 0 characters
2173 String updatedDescription = "";
2175 resourceDetails.setDescription(updatedDescription);
2176 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2178 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2179 updatedRestResponse.getResponse());
2181 // update resource description metadata: null
2182 updatedDescription = null;
2184 resourceDetails.setDescription(updatedDescription);
2185 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2187 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2188 updatedRestResponse.getResponse());
2190 // update resource description metadata: 1 characters
2191 updatedDescription = "A";
2193 resourceDetails.setDescription(updatedDescription);
2194 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2196 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2197 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2198 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2199 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2201 // update resource description metadata: 1024 characters
2202 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2203 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2204 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2205 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2206 + "The longest quills grow from its shoulders to about a third of the animal's length."
2207 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2208 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2209 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2210 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
2212 resourceDetails.setDescription(updatedDescription);
2213 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2215 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2216 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2217 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2218 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2220 // update resource description metadata: 1025 characters
2221 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2222 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2223 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2224 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2225 + "The longest quills grow from its shoulders to about a third of the animal's length."
2226 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2227 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2228 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2229 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
2231 resourceDetails.setDescription(updatedDescription);
2232 resource.add(1, "1024");
2233 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2235 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource,
2236 updatedRestResponse.getResponse());
2241 public void UpdateResource_TagsFormatValidation() throws Exception {
2242 char[] notValidCharsArray = getTagInValidFormatChars();
2244 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2245 assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
2246 String resourceName = resourceDetails.getName();
2248 // update tag details
2249 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2250 ArrayList<String> resourceTags = new ArrayList<String>();
2252 String updatedTagField;
2253 RestResponse updatedRestResponse;
2254 List<String> variables = Arrays.asList("Resource", "tag");
2256 for (int i = 0; i < notValidCharsArray.length; i++) {
2257 updatedTagField = "UpdatedTag" + notValidCharsArray[i];
2258 resourceTags = new ArrayList<String>();
2259 resourceTags.add(updatedTagField);
2260 resourceTags.add(resourceDetails.getName());
2262 updatedResourceDetails.setTags(resourceTags);
2264 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2265 resourceDetails.getUniqueId(), "");
2266 // validate response
2267 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2268 assertNotNull("check error code exists in response after update resource",
2269 updatedRestResponse.getErrorCode());
2270 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2271 updatedRestResponse.getResponse());
2272 assertEquals("Check response code after updating resource icon", 400,
2273 updatedRestResponse.getErrorCode().intValue());
2274 assertEquals("Check response code after updating resource icon", "Bad Request",
2275 updatedRestResponse.getResponseMessage().toString());
2282 public void UpdateResourceCategory_negativeFlow() throws Exception {
2284 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2285 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2286 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2287 String uniqueID = resourceDetails.getUniqueId();
2289 // Update resource Category Successfully
2290 ResourceReqDetails updatedResourceDetails = resourceDetails;
2292 updatedResourceDetails.removeAllCategories();
2293 updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(),
2294 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2295 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2296 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2298 // validate response
2299 List<String> resourceList = new ArrayList<String>();
2300 resourceList.add(0, "Resource");
2301 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2302 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2303 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2304 updatedRestResponse.getResponse());
2305 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2307 // Updating resource category
2308 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2309 updatedResourceDetails.addCategory("");
2310 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2311 resourceDetails.getUniqueId(), "");
2312 // validate response
2313 resourceList = new ArrayList<String>();
2314 resourceList.add(0, "Resource");
2315 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2316 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2317 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList,
2318 updatedRestResponse.getResponse());
2319 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2321 // Updating resource category
2322 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2323 updatedResourceDetails.addCategory("XXXXXX");
2324 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2325 resourceDetails.getUniqueId(), "");
2326 // validate response
2327 resourceList = new ArrayList<String>();
2328 resourceList.add(0, "Resource");
2329 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2330 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2331 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2332 updatedRestResponse.getResponse());
2333 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2336 logger.debug("Changing resource life cycle ");
2337 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2338 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2339 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2341 // Update resource Category
2342 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2343 updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2344 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2345 resourceDetails.getUniqueId(), "");
2347 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2348 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2349 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List,
2350 updatedRestResponse.getResponse());
2351 assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2354 logger.debug("Changing resource life cycle ");
2355 RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2356 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2357 assertNotNull("check response object is not null after checkout resource", checkoutResource);
2358 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2359 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2361 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2362 assertNotNull("check response object is not null after update resource", getRestResponse);
2363 parseResponseAndValidate(resourceDetails, getRestResponse);
2368 public void UpdateResourceCategorySuccessfully() throws Exception {
2370 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2371 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2372 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2374 // Update resource Category Successfully
2375 ResourceReqDetails updatedResourceDetails = resourceDetails;
2377 updatedResourceDetails.removeAllCategories();
2378 updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(),
2379 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2380 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2381 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2383 // validate response
2384 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2385 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2386 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2387 // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2388 // updatedRestResponse);
2389 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2391 // validate category updated
2392 assertTrue(updatedResourceDetails.getCategories().get(0).getName()
2393 .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2395 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
2396 resourceDetails.getUniqueId());
2397 assertNotNull("check response object is not null after update resource", getRestResponse);
2398 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2400 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2406 public void Validation_UpdateIcon() throws Exception {
2407 // Fields to update (Forbidden)
2408 String _updatedIcon = "mySecondIcon.Jpg";
2410 // administrator permissions
2411 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2413 // define and create resource
2414 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2416 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2417 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2418 String resourceName = resourceDetails.getName();
2420 // update metadata details
2421 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2422 // change icon of metadata
2423 updatedResourceDetails.setIcon(_updatedIcon);
2425 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2426 sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2428 // validate response
2429 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2430 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2431 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(),
2432 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2436 updatedResourceDetails.setIcon(_updatedIcon);
2437 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
2438 resourceDetails.getUniqueId(), "");
2439 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2440 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2441 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(),
2442 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2444 // get resource with original name. original metadata should be returned
2445 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
2446 resourceDetails.getUniqueId());
2447 // validate response
2448 assertNotNull("check response object is not null after get resource", getRestResponse);
2449 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2450 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2452 // parse updated response to javaObject
2453 Resource getResourceRespJavaObject = ResponseParser
2454 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
2455 // validate that metadata was not changed
2456 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2458 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(),
2464 public void UpdateResourceTypeSuccess() throws Exception {
2466 String newResourceType = ResourceTypeEnum.VL.toString();
2467 String currentResourceType = resourceDetails.getResourceType();
2468 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2469 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2470 Resource currentResourceJavaObject = ResponseParser
2471 .convertResourceResponseToJavaObject(restResponse.getResponse());
2473 resourceDetails.setResourceType(newResourceType);
2474 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2475 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2476 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2477 Resource updatedResourceJavaObject = ResponseParser
2478 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2479 // assertTrue("Check resource type after update resource",
2480 // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2481 assertTrue("Check resource type after update resource",
2482 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2487 public void UpdateResourceTypeAndNameSuccess() throws Exception {
2489 String newResourceType = ResourceTypeEnum.VL.toString();
2490 String currentResourceType = resourceDetails.getResourceType();
2491 String newResourceName = "new Name";
2493 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2494 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2495 Resource currentResourceJavaObject = ResponseParser
2496 .convertResourceResponseToJavaObject(restResponse.getResponse());
2498 resourceDetails.setResourceType(newResourceType);
2499 resourceDetails.setName(newResourceName);
2500 List<String> tags = resourceDetails.getTags();
2501 tags.add(newResourceName);
2502 resourceDetails.setTags(tags);
2504 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2505 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2506 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2507 Resource updatedResourceJavaObject = ResponseParser
2508 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2509 assertTrue("Check resource type after update resource",
2510 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2511 assertTrue("Check resource name after update resource",
2512 updatedResourceJavaObject.getName().equals(newResourceName));
2517 public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2519 String newResourceType = ResourceTypeEnum.VF.toString();
2520 String currentResourceType = resourceDetails.getResourceType();
2521 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2522 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2523 Resource currentResourceJavaObject = ResponseParser
2524 .convertResourceResponseToJavaObject(restResponse.getResponse());
2526 resourceDetails.setResourceType(newResourceType);
2527 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2528 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2529 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2530 LifeCycleStatesEnum.CHECKOUT);
2531 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2532 currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2534 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2535 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2536 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2537 Resource updatedResourceJavaObject = ResponseParser
2538 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2539 // assertTrue("Check resource type after update resource",
2540 // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2541 assertTrue("Check resource type after update resource",
2542 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2547 public void UpdateResourceTypeCheckInLCS() throws Exception {
2549 String resourceType = ResourceTypeEnum.VL.toString();
2550 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2551 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2552 Resource currentResourceJavaObject = ResponseParser
2553 .convertResourceResponseToJavaObject(restResponse.getResponse());
2555 resourceDetails.setResourceType(resourceType);
2556 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2557 LifeCycleStatesEnum.CHECKIN);
2558 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2560 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2561 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2563 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2565 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2566 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2567 assertEquals("Check response code after create resource", errorInfo.getCode(),
2568 updatedRestResponse.getErrorCode());
2570 List<String> variables = new ArrayList<>();
2571 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2572 updatedRestResponse.getResponse());
2577 public void UpdateResourceTypeCertifiedLCS() throws Exception {
2579 String resourceType = ResourceTypeEnum.VL.toString();
2580 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2581 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2582 Resource currentResourceJavaObject = ResponseParser
2583 .convertResourceResponseToJavaObject(restResponse.getResponse());
2585 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2586 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2588 resourceDetails.setResourceType(resourceType);
2589 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2590 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2592 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2594 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2595 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2596 assertEquals("Check response code after create resource", errorInfo.getCode(),
2597 updatedRestResponse.getErrorCode());
2599 List<String> variables = new ArrayList<>();
2600 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2601 updatedRestResponse.getResponse());
2606 public void UpdateResourceTypeInvalidType() throws Exception {
2608 String resourceType = "INVALID TYPE";
2609 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2610 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2611 Resource currentResourceJavaObject = ResponseParser
2612 .convertResourceResponseToJavaObject(restResponse.getResponse());
2614 resourceDetails.setResourceType(resourceType);
2615 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2616 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2618 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2620 assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2621 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2622 assertEquals("Check response code after update resource", errorInfo.getCode(),
2623 updatedRestResponse.getErrorCode());
2625 List<String> variables = new ArrayList<>();
2626 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
2627 updatedRestResponse.getResponse());