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 UpdateResourceMetadataTest() {
76 super(name, UpdateResourceMetadataTest.class.getName());
80 public String extendedCharsStringBuilder() throws Exception {
81 char[] extendedCharsArray = new char[128];
83 for (int i = 0; i < extendedCharsArray.length - 1; i++) {
84 extendedCharsArray[i] = ch;
87 extendedChars = new String(extendedCharsArray);
93 public void setup() throws Exception {
94 sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
95 resourceDetails = defineResourse();
101 public void UpdateDerivedFromSuccess() throws Exception {
103 String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
104 String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
106 // Getting both derived from resources for validation
108 * RestResponse resourceByNameAndVersion =
109 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
110 * oldDerivedFromName, "1.0");
111 * assertEquals("Check response code after get database normative", 200,
112 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
113 * databaseNormative =
114 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
116 * resourceByNameAndVersion =
117 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
118 * newDerivedFromName, "1.0");
119 * assertEquals("Check response code after get database normative", 200,
120 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
122 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
125 // Derived from set to Database
126 List<String> derivedFrom = new ArrayList<>();
127 derivedFrom.add(oldDerivedFromName);
128 resourceDetails.setDerivedFrom(derivedFrom);
130 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
131 AssertJUnit.assertEquals("Check response code after create resource", 201,
132 restResponse.getErrorCode().intValue());
133 Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
136 derivedFrom.add(newDerivedFromName);
137 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
138 sdncModifierDetails, currentResource.getUniqueId(), "");
139 AssertJUnit.assertEquals("Check response code after create resource", 200,
140 updatedRestResponse.getErrorCode().intValue());
144 protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
145 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
147 updatedResourceDetails.setVersion("mumu");
148 updatedResourceDetails.setIsAbstract(true);
149 updatedResourceDetails.setIsHighestVersion(true);
150 updatedResourceDetails.setCreatorUserId("df4444");
151 updatedResourceDetails.setCreatorFullName("John Doe");
152 updatedResourceDetails.setLastUpdaterUserId("gf5646");
153 updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
154 updatedResourceDetails.setCreationDate(new Long(4444));
155 updatedResourceDetails.setLastUpdateDate(new Long("534535"));
156 updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
157 updatedResourceDetails.setCost("6.1");
158 updatedResourceDetails.setLicenseType("Installation");
159 updatedResourceDetails.setUUID("dfsfsdf");
160 return updatedResourceDetails;
163 public void UpdateResourceNotFoundTest() throws Exception {
165 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
167 String resourceName = "cisco4";
169 String description = "updatedDescription";
170 ArrayList<String> resourceTags = new ArrayList<String>();
171 resourceTags.add("tag2");
172 String category = ServiceCategoriesEnum.MOBILITY.getValue();
173 ArrayList<String> derivedFrom = new ArrayList<String>();
174 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
175 String vendorName = "newOracle";
176 String vendorRelease = "2.5";
177 String contactId = "jh0003";
178 String icon = "myICON";
180 ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags,
181 category, derivedFrom, vendorName, vendorRelease, contactId, icon);
182 updatedResourceDetails.setUniqueId("dummyId");
183 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
184 sdncModifierDetails, "0.1");
187 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
188 AssertJUnit.assertNotNull("check error code exists in response after update resource",
189 updatedRestResponse.getErrorCode());
190 AssertJUnit.assertEquals("Check response code after update resource", 404,
191 updatedRestResponse.getErrorCode().intValue());
192 // String resourceId =
193 // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
194 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
195 updatedRestResponse.getResponse());
198 // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
200 updatedResourceDetails = defineUpdatedResourse(resourceName);
201 updatedResourceDetails.setUniqueId("dummyId");
202 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
204 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
205 AssertJUnit.assertNotNull("check error code exists in response after update resource",
206 updatedRestResponse.getErrorCode());
207 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
208 updatedRestResponse.getResponse());
212 public char[] getInValidChars() throws Exception {
214 char[] extendedCharsArray = new char[59];
216 for (int i = 0; i < 44; i++) {
217 extendedCharsArray[i] = ch;
221 for (int i = 44; i < 51; i++) {
222 extendedCharsArray[i] = ch;
226 for (int i = 51; i < 55; i++) {
227 extendedCharsArray[i] = ch;
231 for (int i = 55; i < 59; i++) {
232 extendedCharsArray[i] = ch;
235 return extendedCharsArray;
238 public char[] getTagInValidFormatChars() throws Exception {
239 // Tag format is the same as defined for "Resource Name" :
240 // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
241 // ('_'), dash ('-'), dot ('.')
242 char[] notValidCharsArray = new char[30];
244 for (int i = 0; i < 12; i++) {
245 notValidCharsArray[i] = ch;
248 notValidCharsArray[13] = 47;
250 for (int i = 14; i < 21; i++) {
251 notValidCharsArray[i] = ch;
255 for (int i = 21; i < 24; i++) {
256 notValidCharsArray[i] = ch;
259 notValidCharsArray[24] = 96;
261 for (int i = 25; i < 30; i++) {
262 notValidCharsArray[i] = ch;
265 return notValidCharsArray;
268 public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
270 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
272 // define and create resource
273 ResourceReqDetails resourceDetails = defineResourse();
274 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
275 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
276 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
278 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
279 String resourceId = resourceDetails.getUniqueId();
280 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
283 JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
285 List<String> resource = new ArrayList<>();
286 resource.add("Resource");
288 // remove Description
289 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description",
290 ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
292 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags",
293 ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
295 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category",
296 ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
298 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName",
299 ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
300 // remove VendorRelease
301 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease",
302 ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
303 // remove AT&T Contact
304 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId",
305 ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
307 // get resource with original name. original metadata should be returned
308 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
310 AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
311 AssertJUnit.assertNotNull("check error code exists in response after get resource",
312 getRestResponse.getErrorCode());
313 AssertJUnit.assertEquals("Check response code after update resource", 200,
314 getRestResponse.getErrorCode().intValue());
316 // parse updated response to javaObject
317 Resource getResourceRespJavaObject = ResponseParser
318 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
319 // validate that metadata was not changed
320 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
322 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
323 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
324 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
327 // End of validation tests
328 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
330 protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
331 String description = "updatedDescription";
332 ArrayList<String> resourceTags = new ArrayList<String>();
333 // Duplicate tags are allowed and should be de-duplicated by server side
334 resourceTags.add(resourceName);
335 resourceTags.add("tag1");
336 resourceTags.add("tag1");
337 resourceTags.add("tag2");
338 resourceTags.add("tag2");
339 String category = ServiceCategoriesEnum.VOIP.getValue();
340 ArrayList<String> derivedFrom = new ArrayList<String>();
341 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
342 String vendorName = "updatedOracle";
343 String vendorRelease = "3.5";
344 String contactId = "jh0001";
345 String icon = "myUpdatedICON";
347 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
348 derivedFrom, vendorName, vendorRelease, contactId, icon);
349 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
350 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
352 return resourceDetails;
355 protected ResourceReqDetails defineResourse() {
356 String resourceName = "cisco4";
357 String description = "description";
358 ArrayList<String> resourceTags = new ArrayList<String>();
359 resourceTags.add(resourceName);
360 ArrayList<String> derivedFrom = new ArrayList<String>();
361 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
362 String vendorName = "Oracle";
363 String vendorRelease = "1.5";
364 String contactId = "jh0003";
365 String icon = "objectStorage";
367 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null,
368 derivedFrom, vendorName, vendorRelease, contactId, icon);
369 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
370 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
372 return resourceDetails;
375 protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails)
378 DbUtils.cleanAllAudits();
381 RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
384 AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
385 AssertJUnit.assertNotNull("check error code exists in response after create resource",
386 restResponse.getErrorCode());
387 AssertJUnit.assertEquals("Check response code after create resource", 201,
388 restResponse.getErrorCode().intValue());
393 protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails,
394 String uri) throws Exception {
397 RestResponse ResourceResponse;
399 config = Utils.getConfig();
400 Map<String, String> headersMap = new HashMap<String, String>();
401 headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
402 headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
403 headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
404 HttpRequest http = new HttpRequest();
405 String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(),
406 config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
409 ResourceResponse = http.httpSendGet(url, headersMap);
410 } else if (uri == "POST") {
411 Gson gson = new Gson();
412 String userBodyJson = gson.toJson(updatedResourceDetails);
413 ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
414 } else if (uri == "DELETE") {
415 ResourceResponse = http.httpSendDelete(url, headersMap);
419 return ResourceResponse;
420 } catch (FileNotFoundException e) {
428 protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
429 // json object: resourceName and icon are must
430 JSONObject jObject = new JSONObject();
432 List<String> tagsList = Arrays.asList(resourceDetails.getName());
433 List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
435 jObject.put("name", resourceDetails.getName());
436 jObject.put("description", "updatedDescription");
437 jObject.put("tags", tagsList);
438 jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
439 jObject.put("derivedFrom", derivedFromList);
440 jObject.put("vendorName", "newOracle");
441 jObject.put("vendorRelease", "1.5");
442 jObject.put("contactId", "jh0003");
443 jObject.put("icon", resourceDetails.getIcon());
448 protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
449 jObject.remove(removedPropery);
454 // purpose: function for controlling json body fields and validating
456 protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject,
457 String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
459 JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
460 // remove description from jsonObject
461 jObject = RemoveFromJsonObject(jObject, removedField);
462 // update with incomplete body.
463 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(),
464 sdncModifierDetails, resourceId);
466 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
467 AssertJUnit.assertNotNull("check error code exists in response after update resource",
468 updatedRestResponse.getErrorCode());
469 ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
473 // purpose: function for validating error response
474 protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails,
475 String recievedMessage, List<String> variables) throws Exception {
476 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
477 sdncModifierDetails, "0.1");
479 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
480 AssertJUnit.assertNotNull("check error code exists in response after update resource",
481 updatedRestResponse.getErrorCode());
482 ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
486 protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse)
488 // parse response to javaObject
489 Resource updatedResourceRespJavaObject = ResponseParser
490 .convertResourceResponseToJavaObject(restResponse.getResponse());
491 AssertJUnit.assertTrue(
492 !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
493 AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
494 AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
495 AssertJUnit.assertTrue(
496 !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
497 AssertJUnit.assertTrue(
498 !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
499 AssertJUnit.assertTrue(
500 !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
502 .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
503 AssertJUnit.assertTrue(
504 !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
505 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName()
506 .equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
507 AssertJUnit.assertTrue(
508 !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
509 AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
511 .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
512 AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
516 protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse)
518 // parse response to javaObject
519 Resource updatedResourceRespJavaObject = ResponseParser
520 .convertResourceResponseToJavaObject(restResponse.getResponse());
521 // validate request vs response
522 ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
525 public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails,
526 String resourceVersion) {
528 ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
530 expectedResourceAuditJavaObject.setAction("Checkout");
531 expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
532 expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
533 expectedResourceAuditJavaObject.setStatus("200.0");
534 expectedResourceAuditJavaObject.setDesc("OK");
535 expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
536 expectedResourceAuditJavaObject.setResourceType("Resource");
537 expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
538 expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
539 expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
540 expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
542 return expectedResourceAuditJavaObject;
546 public enum FieldToValidate {
547 contactId, Tags, VendorName, VendorRelease, Description
551 public void UpdateBy_postTest() throws Exception {
553 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
554 String resourceName = resourceDetails.getName();
556 // update resource - without changing resourceName
557 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
559 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
562 assertNotNull("check response object is not null after update resource", updatedRestResponse);
563 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
564 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
565 updatedRestResponse.getResponse());
567 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
568 resourceDetails.getUniqueId());
569 assertNotNull("check response object is not null after update resource", getRestResponse);
570 parseResponseAndValidate(resourceDetails, getRestResponse);
575 public void UpdateBy_getTest() throws Exception {
577 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
578 String resourceName = resourceDetails.getName();
580 // update resource - without changing resourceName
581 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
582 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
585 assertNotNull("check response object is not null after update resource", updatedRestResponse);
586 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
587 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
588 updatedRestResponse.getResponse());
590 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
591 resourceDetails.getUniqueId());
592 assertNotNull("check response object is not null after update resource", getRestResponse);
593 parseResponseAndValidate(resourceDetails, getRestResponse);
598 public void UpdateBy_deleteTest() throws Exception {
600 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
601 String resourceName = resourceDetails.getName();
603 // update resource - without changing resourceName
604 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
605 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails,
609 assertNotNull("check response object is not null after update resource", updatedRestResponse);
610 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
611 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
612 updatedRestResponse.getResponse());
614 RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails,
615 resourceDetails.getUniqueId(), "");
616 assertNotNull("check response object is not null after update resource", getRestResponse);
617 parseResponseAndValidate(resourceDetails, getRestResponse);
624 public void UpdateWithInvaldJsonBodyTest() throws Exception {
626 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
627 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
628 String resourceId = resourceDetails.getUniqueId();
630 // update Descirption value
631 String description = "updatedDescription";
633 // send update with incompleted json, only description string
634 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails,
638 assertNotNull("check response object is not null after update resource", updatedRestResponse);
639 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
640 assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
642 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
643 resourceDetails.getUniqueId());
644 assertNotNull("check response object is not null after update resource", getRestResponse);
645 parseResponseAndValidate(resourceDetails, getRestResponse);
650 // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
653 // RestResponse restResponse = createResource(sdncModifierDetails,
655 // String resourceName = resourceDetails.getName();
657 // // new user parameters
658 // String userFirstName = "Kot";
659 // String userLastName = "Matroskin";
660 // String role = "ADMIN";
661 // User sdncUserDetails = new User(userFirstName, userLastName,
662 // httpCspUserId, email, role,null);
663 // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
664 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
666 // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
667 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
669 // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
670 // httpCspUserId, email,role,null);
671 // ResourceReqDetails updatedResourceDetails =
672 // defineUpdatedResourse(resourceName);
673 // RestResponse updatedRestResponse =
674 // ResourceRestUtils.updateResource(updatedResourceDetails,
675 // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
677 // // validate response
678 // assertNotNull("check response object is not null after update resource",
679 // updatedRestResponse);
680 // assertNotNull("check error code exists in response after update
681 // resource", updatedRestResponse.getErrorCode());
682 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
683 // Empty_List, updatedRestResponse.getResponse());
685 // RestResponse getRestResponse =
686 // ResourceRestUtils.getResource(sdncModifierDetails,
687 // resourceDetails.getUniqueId());
688 // assertNotNull("check response object is not null after update resource",
690 // parseResponseAndValidate(resourceDetails, getRestResponse);
696 public void UpdateResourceNameSensitiveTest() throws Exception {
697 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
698 String resourceBaseVersion = "0.1";
699 String resourceName = "Ab";
700 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
702 RestResponse response = null;
703 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
704 updatedResourceDetails.getName(), "0.1");
705 BaseRestUtils.checkDeleteResponse(response);
706 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
707 updatedResourceDetails.getName(), "0.2");
708 BaseRestUtils.checkDeleteResponse(response);
710 RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
711 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
714 logger.debug("Changing resource life cycle ");
715 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails,
716 sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
717 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
719 // String resourceCertifyVersion = "0.1";
720 logger.debug("Changing resource life cycle ");
721 checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails,
722 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
723 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
725 updatedResourceDetails.setName("ABC_-bt.aT");
726 ArrayList<String> resourceTag = new ArrayList<String>();
727 resourceTag.add(0, "ABC_-bt.aT");
728 updatedResourceDetails.setTags(resourceTag);
729 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
730 sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
731 assertNotNull("check response object is not null after update resource", updatedRestResponse);
732 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
733 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
734 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
737 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
738 updatedResourceDetails.getName(), "0.1");
739 BaseRestUtils.checkDeleteResponse(response);
740 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
741 updatedResourceDetails.getName(), "0.2");
742 BaseRestUtils.checkDeleteResponse(response);
747 public void UpdateIcon_InegativeFlow() throws Exception {
749 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
750 String resourceName = resourceDetails.getName();
752 List<String> resourceList = new ArrayList<String>();
753 resourceList.add(0, "Resource");
754 // check InValid Characters
755 char[] notValidCharsArray = new char[59];
756 notValidCharsArray = getInValidChars();
757 // update metadata details
758 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
759 RestResponse updatedRestResponse;
761 for (int i = 0; i < notValidCharsArray.length; i++) {
762 // change icon of metadata
763 updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
765 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
766 resourceDetails.getUniqueId(), "");
768 assertNotNull("check response object is not null after update resource", updatedRestResponse);
769 assertNotNull("check error code exists in response after update resource",
770 updatedRestResponse.getErrorCode());
771 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList,
772 updatedRestResponse.getResponse());
773 assertEquals("Check response code after updating resource icon", 400,
774 updatedRestResponse.getErrorCode().intValue());
775 assertEquals("Check response code after updating resource icon", "Bad Request",
776 updatedRestResponse.getResponseMessage().toString());
781 String updateIcon = "";
782 updatedResourceDetails.setIcon(updateIcon);
783 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
784 resourceDetails.getUniqueId(), "");
785 assertNotNull("check response object is not null after update resource", updatedRestResponse);
786 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
787 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList,
788 updatedRestResponse.getResponse());
790 // Icon length more then 25 characters
791 resourceList.add(1, "25");
792 updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
793 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
794 resourceDetails.getUniqueId(), "");
796 assertNotNull("check response object is not null after update resource", updatedRestResponse);
797 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
798 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList,
799 updatedRestResponse.getResponse());
800 assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
801 assertEquals("Check response code after updating resource icon", "Bad Request",
802 updatedRestResponse.getResponseMessage().toString());
804 // get resource with original name. original metadata should be returned
805 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
806 resourceDetails.getUniqueId());
808 assertNotNull("check response object is not null after get resource", getRestResponse);
809 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
810 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
812 // parse updated response to javaObject
813 Resource getResourceRespJavaObject = ResponseParser
814 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
815 // validate that metadata was not changed
816 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
821 public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
823 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
824 String resourceBaseVersion = "0.1";
827 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
828 String resourceName = resourceDetails.getName();
830 ResourceReqDetails updatedResourceDetails = defineResourse();
831 updatedResourceDetails.setName("updatedResourceName");
832 List<String> tags = updatedResourceDetails.getTags();
834 for (Iterator<String> iter = tags.listIterator(); iter.hasNext(); ) {
835 String a = iter.next();
836 if (a.equals("updatedResourceName")) {
841 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
842 sdncModifierDetails, resourceDetails.getUniqueId(), "");
844 List<String> resourceList = new ArrayList<String>();
845 assertNotNull("check response object is not null after update resource", updatedRestResponse);
846 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
847 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
848 resourceList, updatedRestResponse.getResponse());
849 assertEquals("Check response code after updating resource icon", 400,
850 updatedRestResponse.getErrorCode().intValue());
852 // get resource with original name. original metadata should be returned
853 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
854 resourceDetails.getUniqueId());
856 assertNotNull("check response object is not null after get resource", getRestResponse);
857 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
858 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
859 // parse updated response to javaObject
860 Resource getResourceRespJavaObject = ResponseParser
861 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
862 // validate that metadata was not changed
863 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
868 public void UpdateResourceName_negativeFlow() throws Exception {
869 // The validation are done in Tag's validation
870 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
872 RestResponse updatedRestResponse;
873 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
874 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
875 String uniqueId = resourceDetails.getUniqueId();
876 String resourceName = resourceDetails.getName();
877 // check InValid Characters
878 char[] notValidCharsArray = new char[59];
879 notValidCharsArray = getInValidChars();
880 ArrayList<String> resource_Name = new ArrayList<String>();
881 List<String> resourceList = new ArrayList<String>();
883 ArrayList<String> resourceTags = new ArrayList<String>();
884 resourceList.add(0, "Resource");
886 // update metadata details
887 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
888 for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
889 if (i != 1 && i != 46
891 * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
892 */ i != 31) // space ("") and dot(.)
894 // change resourceName parameter
895 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
896 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
897 updatedResourceDetails.setTags(resource_Name);
898 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
899 sdncAdminModifierDetails, uniqueId, "");
901 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
902 // Empty_List, updatedRestResponse.getResponse());
903 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList,
904 updatedRestResponse.getResponse());
909 // resourceName length more then 50 characters
910 // Duplicate tags are allowed and should be de-duplicated by server side
911 resource_Name.add(resourceName);
912 resource_Name.add("tag1");
913 resource_Name.add("tag1");
914 resource_Name.add("tag2");
915 resource_Name.add("tag2");
917 resourceList.add(1, "1024");
918 // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
919 updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
920 // resource_Name.add("123456789012345678901234567890123456789012345678901");
921 updatedResourceDetails.setTags(resource_Name);
922 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
925 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList,
926 updatedRestResponse.getResponse());
928 // get resource with original name. original metadata should be returned
929 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
930 resourceDetails.getUniqueId());
932 assertNotNull("check response object is not null after get resource", getRestResponse);
933 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
934 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
935 // parse updated response to javaObject
936 Resource getResourceRespJavaObject = ResponseParser
937 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
938 // validate that metadata was not changed
939 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
942 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails,
943 updatedResourceDetails.getName(), "0.1");
944 BaseRestUtils.checkDeleteResponse(response);
948 public void UpdateResourceInformation_NotCheckedOut() throws Exception {
950 String resourceBaseVersion = "0.1";
951 List<String> resourceList = new ArrayList<String>();
953 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
954 String resourceName = resourceDetails.getName();
957 logger.debug("Changing resource life cycle ");
958 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
959 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
960 assertNotNull("check response object is not null after checkout resource", checkoutResource);
961 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
962 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
964 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
966 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
967 sdncModifierDetails, resourceDetails.getUniqueId(), "");
968 assertNotNull("check response object is not null after update resource", updatedRestResponse);
969 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
970 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
971 updatedRestResponse.getResponse());
972 assertEquals("Check response code after updating resource icon", 409,
973 updatedRestResponse.getErrorCode().intValue());
975 // get resource with original name. original metadata should be returned
976 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
977 resourceDetails.getUniqueId());
979 assertNotNull("check response object is not null after get resource", getRestResponse);
980 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
981 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
983 // parse updated response to javaObject
984 Resource getResourceRespJavaObject = ResponseParser
985 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
986 // validate that metadata was not changed
987 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
992 public void UpdateResourceInformation_resourceVersion_11() throws Exception {
994 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
995 String resourceBaseVersion = "0.1";
998 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
999 String resourceName = resourceDetails.getName();
1001 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1005 logger.debug("Changing resource life cycle ");
1006 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1007 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1008 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1010 /*logger.debug("Changing resource life cycle ");
1011 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1012 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
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.STARTCERTIFICATION);
1018 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1020 logger.debug("Changing resource life cycle ");
1021 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1022 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1023 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1025 String resourceCertifyVersion = "1.0";
1026 logger.debug("Changing resource life cycle ");
1027 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1028 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
1029 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1031 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1033 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1034 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1035 // validate response
1036 List<String> resourceList = new ArrayList<String>();
1037 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1038 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1039 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
1040 updatedRestResponse.getResponse());
1041 // assertEquals("Check response code after updating resource icon", 409,
1042 // updatedRestResponse.getErrorCode().intValue());
1044 // get resource with original name. original metadata should be returned
1045 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1046 resourceDetails.getUniqueId());
1047 // validate response
1048 assertNotNull("check response object is not null after get resource", getRestResponse);
1050 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1052 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1053 // parse updated response to javaObject
1054 Resource getResourceRespJavaObject = ResponseParser
1055 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1056 // validate that metadata was not changed
1057 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1062 public void UpdateResourceInformation_resourceVersion_02() throws Exception {
1064 String resourceBaseVersion = "0.1";
1067 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1068 String resourceName = resourceDetails.getName();
1070 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1074 logger.debug("Changing resource life cycle ");
1075 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1076 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1077 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1079 // String resourceCertifyVersion = "0.1";
1080 logger.debug("Changing resource life cycle ");
1081 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1082 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
1083 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1085 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1087 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1088 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1089 // validate response
1090 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1091 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1092 assertEquals("Check response code after updating resource icon", 200,
1093 updatedRestResponse.getErrorCode().intValue());
1095 // get resource with original name. original metadata should be returned
1096 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1097 resourceDetails.getUniqueId());
1098 // validate response
1099 assertNotNull("check response object is not null after get resource", getRestResponse);
1100 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1101 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1103 // parse updated response to javaObject
1104 Resource getResourceRespJavaObject = ResponseParser
1105 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1106 // validate that metadata was not changed
1107 ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
1110 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1111 updatedResourceDetails.getName(), "0.1");
1112 BaseRestUtils.checkDeleteResponse(response);
1113 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1114 updatedResourceDetails.getName(), "0.2");
1115 BaseRestUtils.checkDeleteResponse(response);
1120 public void UpdateResourceIcon_resourceVersion_11() throws Exception {
1121 // Can be changed only if major version is "0".
1123 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1124 String resourceBaseVersion = "0.1";
1127 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1128 String resourceName = resourceDetails.getName();
1130 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1134 logger.debug("Changing resource life cycle ");
1135 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1136 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1137 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1139 /*logger.debug("Changing resource life cycle ");
1140 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1141 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
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.STARTCERTIFICATION);
1147 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1149 logger.debug("Changing resource life cycle ");
1150 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1151 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1152 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1154 String resourceCertifyVersion = "1.0";
1155 logger.debug("Changing resource life cycle ");
1156 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1157 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1158 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1160 // ResourceReqDetails updatedResourceDetails =
1161 // defineUpdatedResourse(resourceName);
1162 ResourceReqDetails updatedResourceDetails = defineResourse();
1163 // updatedResourceDetails.setVendorName("updatedVandorName");
1164 updatedResourceDetails.setIcon("updatedIcon");
1166 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1167 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1168 // validate response
1169 List<String> resourceList = new ArrayList<String>();
1170 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList,
1171 updatedRestResponse.getResponse());
1173 // get resource with original name. original metadata should be returned
1174 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1175 resourceDetails.getUniqueId());
1176 // validate response
1177 assertNotNull("check response object is not null after get resource", getRestResponse);
1178 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1179 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1180 // parse updated response to javaObject
1181 Resource getResourceRespJavaObject = ResponseParser
1182 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1183 // validate that metadata was not changed
1184 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1189 public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1190 // Can be changed only if the major resource version is "0".
1191 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1192 String resourceBaseVersion = "0.1";
1195 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1196 String resourceName = resourceDetails.getName();
1198 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1202 logger.debug("Changing resource life cycle ");
1203 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1204 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1205 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1207 /*logger.debug("Changing resource life cycle ");
1208 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1209 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
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.STARTCERTIFICATION);
1215 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1217 logger.debug("Changing resource life cycle ");
1218 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1219 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1220 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1222 String resourceCertifyVersion = "1.0";
1223 logger.debug("Changing resource life cycle ");
1224 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1225 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1226 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1228 // ResourceReqDetails updatedResourceDetails =
1229 // defineUpdatedResourse(resourceName);
1230 ResourceReqDetails updatedResourceDetails = defineResourse();
1232 updatedResourceDetails.setVendorName("updatedVandorName");
1234 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1235 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1236 // validate response
1237 List<String> resourceList = new ArrayList<String>();
1238 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1239 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1240 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(),
1241 resourceList, updatedRestResponse.getResponse());
1242 assertEquals("Check response code after updating resource icon", 400,
1243 updatedRestResponse.getErrorCode().intValue());
1245 // get resource with original name. original metadata should be returned
1246 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1247 resourceDetails.getUniqueId());
1248 // validate response
1249 assertNotNull("check response object is not null after get resource", getRestResponse);
1250 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1251 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1252 // parse updated response to javaObject
1253 Resource getResourceRespJavaObject = ResponseParser
1254 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1255 // validate that metadata was not changed
1256 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1261 public void UpdateResourceName_resourceVersion_11() throws Exception {
1262 // Can be changed only if the major resource version is "0".
1263 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1264 String resourceBaseVersion = "0.1";
1267 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1268 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1269 String resourceName = resourceDetails.getName();
1271 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1275 logger.debug("Changing resource life cycle ");
1276 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1277 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1278 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1280 /*logger.debug("Changing resource life cycle ");
1281 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1282 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
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.STARTCERTIFICATION);
1288 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1290 logger.debug("Changing resource life cycle ");
1291 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1292 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1293 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1295 String resourceCertifyVersion = "1.0";
1296 logger.debug("Changing resource life cycle ");
1297 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1298 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1299 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1302 * //ResourceReqDetails updatedResourceDetails =
1303 * defineUpdatedResourse(resourceName); ResourceReqDetails
1304 * updatedResourceDetails = defineResourse();
1306 * updatedResourceDetails.setResourceName("updatedResourceName");
1307 * updatedResourceDetails.setIcon("updatedResourceName");
1309 resourceDetails.setName("updatedResourceName");
1310 List<String> tagList = new ArrayList<String>();
1311 tagList.add(0, "updatedResourceName");
1312 resourceDetails.setTags(tagList);
1314 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1315 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1316 // validate response
1317 List<String> resourceList = new ArrayList<String>();
1318 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1319 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1320 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList,
1321 updatedRestResponse.getResponse());
1326 public void UpdateResourceTag_resourceVersion_11() throws Exception {
1327 // Tag Can be updated when major version is "0".
1328 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1329 String resourceBaseVersion = "0.1";
1332 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1333 String resourceName = resourceDetails.getName();
1335 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1339 logger.debug("Changing resource life cycle ");
1340 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1341 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1342 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1344 /*logger.debug("Changing resource life cycle ");
1345 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1346 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
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.STARTCERTIFICATION);
1352 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1354 logger.debug("Changing resource life cycle ");
1355 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1356 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1357 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1359 String resourceCertifyVersion = "1.0";
1360 logger.debug("Changing resource life cycle ");
1361 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1362 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1363 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1365 // ResourceReqDetails updatedResourceDetails =
1366 // defineUpdatedResourse(resourceName);
1367 ResourceReqDetails updatedResourceDetails = defineResourse();
1368 // updatedResourceDetails.setVendorName("updatedVandorName");
1370 ArrayList<String> resourceTags = new ArrayList<String>();
1371 resourceTags.add("NewTag");
1372 resourceTags.add(resourceDetails.getName());
1374 updatedResourceDetails.setTags(resourceTags);
1376 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1377 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1378 // validate response
1379 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1380 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1381 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1383 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1384 resourceDetails.getUniqueId());
1385 assertNotNull("check response object is not null after update resource", getRestResponse);
1386 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1391 public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1393 // Tag, contactId, vendorRelease,tags And description - Can be also
1394 // updated when major version is NOT "0".
1395 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1396 String resourceBaseVersion = "0.1";
1399 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1401 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1405 logger.debug("Changing resource life cycle ");
1406 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1407 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1408 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1410 /*logger.debug("Changing resource life cycle ");
1411 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1412 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
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.STARTCERTIFICATION);
1418 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1420 logger.debug("Changing resource life cycle ");
1421 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1422 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1423 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1425 String resourceCertifyVersion = "1.0";
1426 logger.debug("Changing resource life cycle ");
1427 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1428 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1429 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1431 // ResourceReqDetails updatedResourceDetails =
1432 // defineUpdatedResourse(resourceName);
1433 ResourceReqDetails updatedResourceDetails = defineResourse();
1434 // updatedResourceDetails.setVendorName("updatedVandorName");
1436 // updated allowed parameters when major resource version is NOT "0"
1437 ArrayList<String> resourceTags = new ArrayList<String>();
1438 resourceTags.add("NewTag");
1439 resourceTags.add(resourceDetails.getName());
1440 updatedResourceDetails.setTags(resourceTags);
1441 updatedResourceDetails.setDescription("UpdatedDescription");
1442 updatedResourceDetails.setVendorRelease("5.1");
1443 updatedResourceDetails.setContactId("bt750h");
1445 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1446 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1447 // validate response
1448 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1449 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1450 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1452 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1453 resourceDetails.getUniqueId());
1454 assertNotNull("check response object is not null after update resource", getRestResponse);
1455 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1460 public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1461 // DerivedFrom parameter - Can be updated when major version is "0".
1462 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1463 String resourceBaseVersion = "0.1";
1466 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1467 String resourceName = resourceDetails.getName();
1469 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1473 logger.debug("Changing resource life cycle ");
1474 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1475 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1476 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1478 /*logger.debug("Changing resource life cycle ");
1479 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1480 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
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.STARTCERTIFICATION);
1486 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
1488 logger.debug("Changing resource life cycle ");
1489 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1490 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1491 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1493 String resourceCertifyVersion = "1.0";
1494 logger.debug("Changing resource life cycle ");
1495 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1496 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1497 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1499 // ResourceReqDetails updatedResourceDetails =
1500 // defineUpdatedResourse(resourceName);
1501 ResourceReqDetails updatedResourceDetails = defineResourse();
1502 ArrayList<String> drivenFrom = new ArrayList<String>();
1503 drivenFrom.add(0, "tosca.nodes.Container.Application");
1504 updatedResourceDetails.setDerivedFrom(drivenFrom);
1506 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1507 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1508 // validate response
1509 List<String> resourceList = new ArrayList<String>();
1510 ResourceRestUtils.checkSuccess(updatedRestResponse);
1512 // get resource with original name. original metadata should be returned
1513 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1514 resourceDetails.getUniqueId());
1515 // validate response
1516 assertNotNull("check response object is not null after get resource", getRestResponse);
1517 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1518 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1519 // parse updated response to javaObject
1520 Resource getResourceRespJavaObject = ResponseParser
1521 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1522 // validate that metadata was not changed
1523 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1528 public void UpdateResource_vendorNameValidation() throws Exception {
1530 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1531 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1532 String updatedVendorName = "";
1533 String uniqueId = resourceDetails.getUniqueId();
1534 resourceDetails.setVendorName(updatedVendorName);
1535 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1536 sdncModifierDetails, uniqueId, "");
1537 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1538 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1539 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1540 updatedRestResponse.getResponse());
1542 // update resource vendorName metadata: 1 characters
1543 updatedVendorName = " ";
1545 resourceDetails.setVendorName(updatedVendorName);
1546 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1548 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1549 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1550 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1551 updatedRestResponse.getResponse());
1553 // update resource vendorName metadata: 25 characters
1554 updatedVendorName = "Verification and validati";
1556 resourceDetails.setVendorName(updatedVendorName);
1557 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1559 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1560 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1561 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1562 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1564 // update resource vendorName metadata: 26 characters
1565 updatedVendorName = "Verification and validatii";
1567 List<String> myList = new ArrayList<String>();
1568 myList.add(0, "25");
1569 resourceDetails.setVendorName(updatedVendorName);
1570 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1572 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1573 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList,
1574 updatedRestResponse.getResponse());
1576 // update resource VendorRelease metadata: forbidden characters
1577 updatedVendorName = "A1<";
1579 resourceDetails.setVendorName(updatedVendorName);
1580 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1582 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1583 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1584 updatedRestResponse.getResponse());
1586 updatedVendorName = "A1>";
1588 resourceDetails.setVendorName(updatedVendorName);
1589 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1591 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1592 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1593 updatedRestResponse.getResponse());
1595 updatedVendorName = "A1:";
1597 resourceDetails.setVendorName(updatedVendorName);
1598 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1600 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1601 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1602 updatedRestResponse.getResponse());
1604 updatedVendorName = "A1\"";
1606 resourceDetails.setVendorName(updatedVendorName);
1607 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1609 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1610 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1611 updatedRestResponse.getResponse());
1613 updatedVendorName = "A1/";
1615 resourceDetails.setVendorName(updatedVendorName);
1616 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1618 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1619 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1620 updatedRestResponse.getResponse());
1622 updatedVendorName = "A1\\";
1624 resourceDetails.setVendorName(updatedVendorName);
1625 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1627 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1628 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1629 updatedRestResponse.getResponse());
1631 updatedVendorName = "A1|";
1633 resourceDetails.setVendorName(updatedVendorName);
1634 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1636 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1637 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1638 updatedRestResponse.getResponse());
1640 updatedVendorName = "A1?";
1642 resourceDetails.setVendorName(updatedVendorName);
1643 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1645 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1646 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1647 updatedRestResponse.getResponse());
1649 updatedVendorName = "A1*";
1651 resourceDetails.setVendorName(updatedVendorName);
1652 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1654 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1655 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1656 updatedRestResponse.getResponse());
1658 // update resource vendorName metadata: null
1659 updatedVendorName = null;
1661 resourceDetails.setVendorName(updatedVendorName);
1662 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1664 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1665 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1666 updatedRestResponse.getResponse());
1671 public void UpdateResource_vendorReleaseValidation() throws Exception {
1673 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1674 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1675 RestResponse updatedRestResponse;
1676 String uniqueId = resourceDetails.getUniqueId();
1677 String updatedVendorRelease;
1678 // set VendorRelease
1680 // update resource VendorRelease metadata: 1 characters
1681 updatedVendorRelease = "1";
1682 // set VendorRelease
1683 resourceDetails.setVendorRelease(updatedVendorRelease);
1684 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1686 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1687 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1688 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1689 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1691 // update resource VendorRelease metadata: 25 characters
1692 updatedVendorRelease = "(!#1.00000000000000000000";
1693 // set VendorRelease
1694 resourceDetails.setVendorRelease(updatedVendorRelease);
1695 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1697 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1698 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1699 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1700 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1702 // update resource VendorRelease metadata: 26 characters
1703 updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1704 resourceDetails.setVendorRelease(updatedVendorRelease);
1705 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1707 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1708 Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1710 // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1711 // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1712 // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1714 // update resource VendorRelease metadata: forbidden characters
1715 updatedVendorRelease = "A1<";
1716 // set VendorRelease
1717 resourceDetails.setVendorRelease(updatedVendorRelease);
1718 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1720 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1721 updatedRestResponse.getResponse());
1723 updatedVendorRelease = "A1>";
1724 // set VendorRelease
1725 resourceDetails.setVendorRelease(updatedVendorRelease);
1726 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1728 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1729 updatedRestResponse.getResponse());
1731 updatedVendorRelease = "A1:";
1732 // set VendorRelease
1733 resourceDetails.setVendorRelease(updatedVendorRelease);
1734 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1736 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1737 updatedRestResponse.getResponse());
1739 updatedVendorRelease = "A1\"";
1740 // set VendorRelease
1741 resourceDetails.setVendorRelease(updatedVendorRelease);
1742 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1744 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1745 updatedRestResponse.getResponse());
1747 updatedVendorRelease = "A1/";
1748 // set VendorRelease
1749 resourceDetails.setVendorRelease(updatedVendorRelease);
1750 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1752 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1753 updatedRestResponse.getResponse());
1755 updatedVendorRelease = "A1\\";
1756 // set VendorRelease
1757 resourceDetails.setVendorRelease(updatedVendorRelease);
1758 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1760 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1761 updatedRestResponse.getResponse());
1763 updatedVendorRelease = "A1|";
1764 // set VendorRelease
1765 resourceDetails.setVendorRelease(updatedVendorRelease);
1766 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1768 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1769 updatedRestResponse.getResponse());
1771 updatedVendorRelease = "A1?";
1772 // set VendorRelease
1773 resourceDetails.setVendorRelease(updatedVendorRelease);
1774 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1776 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1777 updatedRestResponse.getResponse());
1779 updatedVendorRelease = "A1*";
1780 // set VendorRelease
1781 resourceDetails.setVendorRelease(updatedVendorRelease);
1782 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1784 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1785 updatedRestResponse.getResponse());
1787 // update resource VendorRelease metadata: null
1788 updatedVendorRelease = null;
1789 // set VendorRelease
1790 resourceDetails.setVendorRelease(updatedVendorRelease);
1791 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1793 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1794 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List,
1795 updatedRestResponse.getResponse());
1800 public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1821 RestResponse updatedRestResponse;
1823 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1824 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1825 String uniqueId = resourceDetails.getUniqueId();
1827 List<String> myList = new ArrayList<String>();
1828 myList.add(0, "Resource");
1829 String updatedcontactId = "";
1830 resourceDetails.setContactId(updatedcontactId);
1832 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1834 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1835 updatedRestResponse.getResponse());
1837 updatedcontactId = "ab12345";
1838 resourceDetails.setContactId(updatedcontactId);
1839 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1841 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1842 updatedRestResponse.getResponse());
1844 updatedcontactId = " ";
1845 resourceDetails.setContactId(updatedcontactId);
1846 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1848 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1849 updatedRestResponse.getResponse());
1851 updatedcontactId = "ab 50h";
1852 resourceDetails.setContactId(updatedcontactId);
1853 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1855 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1856 updatedRestResponse.getResponse());
1858 updatedcontactId = "ab123c";
1859 resourceDetails.setContactId(updatedcontactId);
1860 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1862 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1863 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1864 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1866 updatedcontactId = "cd789E";
1867 resourceDetails.setContactId(updatedcontactId);
1868 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1870 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1871 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1873 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1874 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1876 updatedcontactId = "ef4567";
1877 resourceDetails.setContactId(updatedcontactId);
1878 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1880 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1881 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1882 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1883 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1885 updatedcontactId = "AA012A";
1886 resourceDetails.setContactId(updatedcontactId);
1887 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1889 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1890 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1891 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1893 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1894 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1896 updatedcontactId = "CD012c";
1897 resourceDetails.setContactId(updatedcontactId);
1898 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1900 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1901 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1902 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1904 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1905 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1907 updatedcontactId = "EF0123";
1908 resourceDetails.setContactId(updatedcontactId);
1909 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1911 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1912 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1913 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1915 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1916 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1918 ////////////////////////////// **************//////////////////////////////
1919 List<String> resource = Arrays.asList("Resource");
1920 updatedcontactId = "01345a";
1921 resourceDetails.setContactId(updatedcontactId);
1922 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1924 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1925 updatedRestResponse.getResponse());
1927 updatedcontactId = "0y000B";
1928 resourceDetails.setContactId(updatedcontactId);
1929 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1931 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1932 updatedRestResponse.getResponse());
1934 updatedcontactId = "Y1000b";
1935 resourceDetails.setContactId(updatedcontactId);
1936 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1938 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1939 updatedRestResponse.getResponse());
1941 updatedcontactId = "abxyzC";
1942 resourceDetails.setContactId(updatedcontactId);
1943 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1945 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1946 updatedRestResponse.getResponse());
1948 updatedcontactId = "cdXYZc";
1949 resourceDetails.setContactId(updatedcontactId);
1950 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1952 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1953 updatedRestResponse.getResponse());
1955 updatedcontactId = "efXY1D";
1956 resourceDetails.setContactId(updatedcontactId);
1957 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1959 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1960 updatedRestResponse.getResponse());
1962 updatedcontactId = "EFabcD";
1963 resourceDetails.setContactId(updatedcontactId);
1964 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1966 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1967 updatedRestResponse.getResponse());
1969 updatedcontactId = "EFABCD";
1970 resourceDetails.setContactId(updatedcontactId);
1971 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1973 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1974 updatedRestResponse.getResponse());
1976 updatedcontactId = "EFABC1";
1977 resourceDetails.setContactId(updatedcontactId);
1978 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1980 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1981 updatedRestResponse.getResponse());
1983 updatedcontactId = "efui1D";
1984 resourceDetails.setContactId(updatedcontactId);
1985 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1987 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1988 updatedRestResponse.getResponse());
1990 updatedcontactId = "efui1!";
1991 resourceDetails.setContactId(updatedcontactId);
1992 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1994 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1995 updatedRestResponse.getResponse());
1997 updatedcontactId = "ef555!";
1998 resourceDetails.setContactId(updatedcontactId);
1999 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2001 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2002 updatedRestResponse.getResponse());
2004 updatedcontactId = ",f555";
2005 resourceDetails.setContactId(updatedcontactId);
2006 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2008 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2009 updatedRestResponse.getResponse());
2011 updatedcontactId = "EF55.5";
2012 resourceDetails.setContactId(updatedcontactId);
2013 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2015 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2016 updatedRestResponse.getResponse());
2018 // update resource contactId metadata: extended character set (128–255)
2019 resourceDetails.setContactId(extendedCharsStringBuilder());
2020 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2022 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2023 updatedRestResponse.getResponse());
2025 // update resource contactId metadata: null
2026 updatedcontactId = null;
2027 resourceDetails.setContactId(updatedcontactId);
2028 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2030 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
2031 updatedRestResponse.getResponse());
2036 public void UpdateResource_TagsFieldValidation() throws Exception {
2037 RestResponse updatedRestResponse;
2038 // define and create resource
2040 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2041 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2042 String uniqueId = resourceDetails.getUniqueId();
2044 String updatedTagField = "";
2045 ArrayList<String> resourceTags = new ArrayList<String>();
2046 resourceTags.add(updatedTagField);
2048 resourceDetails.setTags(resourceTags);
2049 List<String> variables = Arrays.asList("Resource", "tag");
2050 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2052 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2053 updatedRestResponse.getResponse());
2055 // update resource tags metadata: empty
2056 resourceTags = new ArrayList<String>();
2058 resourceDetails.setTags(resourceTags);
2059 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2061 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List,
2062 updatedRestResponse.getResponse());
2064 // update resource description metadata: 1 characters
2065 updatedTagField = "A";
2066 resourceTags = new ArrayList<String>();
2067 resourceTags.add(updatedTagField);
2068 resourceTags.add(resourceDetails.getName());
2070 resourceDetails.setTags(resourceTags);
2071 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2073 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2074 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2075 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2076 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2078 // OK - tag up to 50 chars
2079 updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
2080 resourceTags.add(updatedTagField);
2081 resourceDetails.setTags(resourceTags);
2082 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2084 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2085 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2086 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2087 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2089 // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
2090 String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
2091 String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
2092 String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
2093 String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
2094 String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
2095 String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
2096 String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
2097 String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
2098 String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
2099 String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
2100 String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
2101 String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
2102 String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
2103 String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
2104 String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
2105 String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
2106 String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
2107 String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
2108 String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
2110 resourceTags = new ArrayList<String>();
2111 resourceTags.add(updatedTagField);
2112 resourceTags.add(updatedTagField1);
2113 resourceTags.add(updatedTagField2);
2114 resourceTags.add(updatedTagField3);
2115 resourceTags.add(updatedTagField4);
2116 resourceTags.add(updatedTagField5);
2117 resourceTags.add(updatedTagField6);
2118 resourceTags.add(updatedTagField7);
2119 resourceTags.add(updatedTagField8);
2120 resourceTags.add(updatedTagField9);
2121 resourceTags.add(updatedTagField10);
2122 resourceTags.add(updatedTagField11);
2123 resourceTags.add(updatedTagField12);
2124 resourceTags.add(updatedTagField13);
2125 resourceTags.add(updatedTagField14);
2126 resourceTags.add(updatedTagField15);
2127 resourceTags.add(updatedTagField16);
2128 resourceTags.add(updatedTagField17);
2129 resourceTags.add(updatedTagField18);
2130 resourceTags.add(updatedTagField19);
2131 resourceTags.add(resourceDetails.getName());
2133 resourceDetails.setTags(resourceTags);
2134 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2136 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2137 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2138 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2139 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2141 // Add another tag-exceeds limit
2142 resourceTags.add("d");
2143 resourceDetails.setTags(resourceTags);
2144 ArrayList<String> myArray = new ArrayList<String>();
2145 myArray.add(0, "1024");
2146 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2148 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray,
2149 updatedRestResponse.getResponse());
2151 // Tag exceeds limit - 51
2152 resourceTags = new ArrayList<String>();
2153 updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
2154 resourceTags.add(updatedTagField);
2155 resourceTags.add(resourceDetails.getName());
2157 resourceDetails.setTags(resourceTags);
2159 myArray.add(0, "50");
2160 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2162 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray,
2163 updatedRestResponse.getResponse());
2168 public void UpdateResource_DesriptionFieldValidation() throws Exception {
2169 // define and create resource
2170 RestResponse updatedRestResponse;
2172 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2173 String uniqueId = resourceDetails.getUniqueId();
2174 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2175 List<String> resource = new ArrayList<>();
2176 resource.add("Resource");
2177 // update resource description metadata: 0 characters
2178 String updatedDescription = "";
2180 resourceDetails.setDescription(updatedDescription);
2181 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2183 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2184 updatedRestResponse.getResponse());
2186 // update resource description metadata: null
2187 updatedDescription = null;
2189 resourceDetails.setDescription(updatedDescription);
2190 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2192 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2193 updatedRestResponse.getResponse());
2195 // update resource description metadata: 1 characters
2196 updatedDescription = "A";
2198 resourceDetails.setDescription(updatedDescription);
2199 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2201 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2202 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2203 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2204 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2206 // update resource description metadata: 1024 characters
2207 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2208 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2209 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2210 + "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."
2211 + "The longest quills grow from its shoulders to about a third of the animal's length."
2212 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2213 + "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."
2214 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2215 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
2217 resourceDetails.setDescription(updatedDescription);
2218 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2220 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2221 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2222 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2223 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2225 // update resource description metadata: 1025 characters
2226 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2227 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2228 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2229 + "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."
2230 + "The longest quills grow from its shoulders to about a third of the animal's length."
2231 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2232 + "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."
2233 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2234 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
2236 resourceDetails.setDescription(updatedDescription);
2237 resource.add(1, "1024");
2238 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2240 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource,
2241 updatedRestResponse.getResponse());
2246 public void UpdateResource_TagsFormatValidation() throws Exception {
2247 char[] notValidCharsArray = getTagInValidFormatChars();
2249 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2250 assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
2251 String resourceName = resourceDetails.getName();
2253 // update tag details
2254 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2255 ArrayList<String> resourceTags = new ArrayList<String>();
2257 String updatedTagField;
2258 RestResponse updatedRestResponse;
2259 List<String> variables = Arrays.asList("Resource", "tag");
2261 for (int i = 0; i < notValidCharsArray.length; i++) {
2262 updatedTagField = "UpdatedTag" + notValidCharsArray[i];
2263 resourceTags = new ArrayList<String>();
2264 resourceTags.add(updatedTagField);
2265 resourceTags.add(resourceDetails.getName());
2267 updatedResourceDetails.setTags(resourceTags);
2269 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2270 resourceDetails.getUniqueId(), "");
2271 // validate response
2272 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2273 assertNotNull("check error code exists in response after update resource",
2274 updatedRestResponse.getErrorCode());
2275 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2276 updatedRestResponse.getResponse());
2277 assertEquals("Check response code after updating resource icon", 400,
2278 updatedRestResponse.getErrorCode().intValue());
2279 assertEquals("Check response code after updating resource icon", "Bad Request",
2280 updatedRestResponse.getResponseMessage().toString());
2287 public void UpdateResourceCategory_negativeFlow() throws Exception {
2289 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2290 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2291 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2292 String uniqueID = resourceDetails.getUniqueId();
2294 // Update resource Category Successfully
2295 ResourceReqDetails updatedResourceDetails = resourceDetails;
2297 updatedResourceDetails.removeAllCategories();
2298 updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(),
2299 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2300 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2301 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2303 // validate response
2304 List<String> resourceList = new ArrayList<String>();
2305 resourceList.add(0, "Resource");
2306 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2307 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2308 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2309 updatedRestResponse.getResponse());
2310 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2312 // Updating resource category
2313 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2314 updatedResourceDetails.addCategory("");
2315 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2316 resourceDetails.getUniqueId(), "");
2317 // validate response
2318 resourceList = new ArrayList<String>();
2319 resourceList.add(0, "Resource");
2320 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2321 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2322 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList,
2323 updatedRestResponse.getResponse());
2324 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2326 // Updating resource category
2327 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2328 updatedResourceDetails.addCategory("XXXXXX");
2329 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2330 resourceDetails.getUniqueId(), "");
2331 // validate response
2332 resourceList = new ArrayList<String>();
2333 resourceList.add(0, "Resource");
2334 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2335 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2336 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2337 updatedRestResponse.getResponse());
2338 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2341 logger.debug("Changing resource life cycle ");
2342 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2343 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2344 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2346 // Update resource Category
2347 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2348 updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2349 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2350 resourceDetails.getUniqueId(), "");
2352 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2353 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2354 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List,
2355 updatedRestResponse.getResponse());
2356 assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2359 logger.debug("Changing resource life cycle ");
2360 RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2361 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2362 assertNotNull("check response object is not null after checkout resource", checkoutResource);
2363 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2364 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2366 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2367 assertNotNull("check response object is not null after update resource", getRestResponse);
2368 parseResponseAndValidate(resourceDetails, getRestResponse);
2373 public void UpdateResourceCategorySuccessfully() throws Exception {
2375 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2376 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2377 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2379 // Update resource Category Successfully
2380 ResourceReqDetails updatedResourceDetails = resourceDetails;
2382 updatedResourceDetails.removeAllCategories();
2383 updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(),
2384 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2385 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2386 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2388 // validate response
2389 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2390 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2391 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2392 // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2393 // updatedRestResponse);
2394 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2396 // validate category updated
2397 assertTrue(updatedResourceDetails.getCategories().get(0).getName()
2398 .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2400 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
2401 resourceDetails.getUniqueId());
2402 assertNotNull("check response object is not null after update resource", getRestResponse);
2403 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2405 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2411 public void Validation_UpdateIcon() throws Exception {
2412 // Fields to update (Forbidden)
2413 String _updatedIcon = "mySecondIcon.Jpg";
2415 // administrator permissions
2416 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2418 // define and create resource
2419 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2421 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2422 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2423 String resourceName = resourceDetails.getName();
2425 // update metadata details
2426 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2427 // change icon of metadata
2428 updatedResourceDetails.setIcon(_updatedIcon);
2430 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2431 sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2433 // validate response
2434 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2435 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2436 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(),
2437 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2441 updatedResourceDetails.setIcon(_updatedIcon);
2442 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
2443 resourceDetails.getUniqueId(), "");
2444 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2445 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2446 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(),
2447 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2449 // get resource with original name. original metadata should be returned
2450 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
2451 resourceDetails.getUniqueId());
2452 // validate response
2453 assertNotNull("check response object is not null after get resource", getRestResponse);
2454 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2455 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2457 // parse updated response to javaObject
2458 Resource getResourceRespJavaObject = ResponseParser
2459 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
2460 // validate that metadata was not changed
2461 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2463 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(),
2469 public void UpdateResourceTypeSuccess() throws Exception {
2471 String newResourceType = ResourceTypeEnum.VL.toString();
2472 String currentResourceType = resourceDetails.getResourceType();
2473 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2474 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2475 Resource currentResourceJavaObject = ResponseParser
2476 .convertResourceResponseToJavaObject(restResponse.getResponse());
2478 resourceDetails.setResourceType(newResourceType);
2479 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2480 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2481 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2482 Resource updatedResourceJavaObject = ResponseParser
2483 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2484 // assertTrue("Check resource type after update resource",
2485 // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2486 assertTrue("Check resource type after update resource",
2487 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2492 public void UpdateResourceTypeAndNameSuccess() throws Exception {
2494 String newResourceType = ResourceTypeEnum.VL.toString();
2495 String currentResourceType = resourceDetails.getResourceType();
2496 String newResourceName = "new Name";
2498 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2499 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2500 Resource currentResourceJavaObject = ResponseParser
2501 .convertResourceResponseToJavaObject(restResponse.getResponse());
2503 resourceDetails.setResourceType(newResourceType);
2504 resourceDetails.setName(newResourceName);
2505 List<String> tags = resourceDetails.getTags();
2506 tags.add(newResourceName);
2507 resourceDetails.setTags(tags);
2509 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2510 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2511 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2512 Resource updatedResourceJavaObject = ResponseParser
2513 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2514 assertTrue("Check resource type after update resource",
2515 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2516 assertTrue("Check resource name after update resource",
2517 updatedResourceJavaObject.getName().equals(newResourceName));
2522 public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2524 String newResourceType = ResourceTypeEnum.VF.toString();
2525 String currentResourceType = resourceDetails.getResourceType();
2526 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2527 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2528 Resource currentResourceJavaObject = ResponseParser
2529 .convertResourceResponseToJavaObject(restResponse.getResponse());
2531 resourceDetails.setResourceType(newResourceType);
2532 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2533 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2534 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2535 LifeCycleStatesEnum.CHECKOUT);
2536 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2537 currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2539 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2540 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2541 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2542 Resource updatedResourceJavaObject = ResponseParser
2543 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2544 // assertTrue("Check resource type after update resource",
2545 // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2546 assertTrue("Check resource type after update resource",
2547 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2552 public void UpdateResourceTypeCheckInLCS() throws Exception {
2554 String resourceType = ResourceTypeEnum.VL.toString();
2555 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2556 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2557 Resource currentResourceJavaObject = ResponseParser
2558 .convertResourceResponseToJavaObject(restResponse.getResponse());
2560 resourceDetails.setResourceType(resourceType);
2561 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2562 LifeCycleStatesEnum.CHECKIN);
2563 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2565 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2566 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2568 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2570 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2571 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2572 assertEquals("Check response code after create resource", errorInfo.getCode(),
2573 updatedRestResponse.getErrorCode());
2575 List<String> variables = new ArrayList<>();
2576 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2577 updatedRestResponse.getResponse());
2582 public void UpdateResourceTypeCertifiedLCS() throws Exception {
2584 String resourceType = ResourceTypeEnum.VL.toString();
2585 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2586 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2587 Resource currentResourceJavaObject = ResponseParser
2588 .convertResourceResponseToJavaObject(restResponse.getResponse());
2590 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2591 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2593 resourceDetails.setResourceType(resourceType);
2594 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2595 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2597 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2599 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2600 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2601 assertEquals("Check response code after create resource", errorInfo.getCode(),
2602 updatedRestResponse.getErrorCode());
2604 List<String> variables = new ArrayList<>();
2605 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2606 updatedRestResponse.getResponse());
2611 public void UpdateResourceTypeInvalidType() throws Exception {
2613 String resourceType = "INVALID TYPE";
2614 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2615 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2616 Resource currentResourceJavaObject = ResponseParser
2617 .convertResourceResponseToJavaObject(restResponse.getResponse());
2619 resourceDetails.setResourceType(resourceType);
2620 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2621 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2623 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2625 assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2626 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2627 assertEquals("Check response code after update resource", errorInfo.getCode(),
2628 updatedRestResponse.getErrorCode());
2630 List<String> variables = new ArrayList<>();
2631 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
2632 updatedRestResponse.getResponse());