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 static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertNotNull;
25 import static org.testng.AssertJUnit.assertTrue;
27 import java.io.FileNotFoundException;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.HashMap;
31 import java.util.Iterator;
32 import java.util.List;
35 import org.json.JSONException;
36 import org.json.JSONObject;
37 import org.junit.rules.TestName;
38 import org.openecomp.sdc.be.dao.api.ActionStatus;
39 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
40 import org.openecomp.sdc.be.model.LifecycleStateEnum;
41 import org.openecomp.sdc.be.model.Resource;
42 import org.openecomp.sdc.be.model.User;
43 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
44 import org.openecomp.sdc.ci.tests.api.Urls;
45 import org.openecomp.sdc.ci.tests.config.Config;
46 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
47 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
48 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
49 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
50 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
53 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
54 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
55 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
56 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
57 import org.openecomp.sdc.ci.tests.utils.DbUtils;
58 import org.openecomp.sdc.ci.tests.utils.Utils;
59 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
60 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
61 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
63 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
64 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
65 import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
66 import org.openecomp.sdc.common.util.ValidationUtils;
67 import org.slf4j.Logger;
68 import org.slf4j.LoggerFactory;
69 import org.testng.AssertJUnit;
70 import org.testng.annotations.BeforeMethod;
71 import org.testng.annotations.Test;
73 import com.google.gson.Gson;
75 public class UpdateResourceMetadataTest extends ComponentBaseTest {
76 private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
77 protected List<String> Empty_List = new ArrayList<String>();
78 protected String extendedChars;
80 protected final String contentTypeHeaderData = "application/json";
81 protected final String acceptHeaderDate = "application/json";
82 protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
84 public static TestName name = new TestName();
85 protected User sdncModifierDetails;
86 protected ResourceReqDetails resourceDetails;
88 public UpdateResourceMetadataTest() {
89 super(name, UpdateResourceMetadataTest.class.getName());
93 public String extendedCharsStringBuilder() throws Exception {
94 char[] extendedCharsArray = new char[128];
96 for (int i = 0; i < extendedCharsArray.length - 1; i++) {
97 extendedCharsArray[i] = ch;
100 extendedChars = new String(extendedCharsArray);
101 return extendedChars;
106 public void setup() throws Exception {
107 sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
108 resourceDetails = defineResourse();
114 public void UpdateDerivedFromSuccess() throws Exception {
116 String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
117 String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
119 // Getting both derived from resources for validation
121 * RestResponse resourceByNameAndVersion =
122 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
123 * oldDerivedFromName, "1.0");
124 * assertEquals("Check response code after get database normative", 200,
125 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
126 * databaseNormative =
127 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
129 * resourceByNameAndVersion =
130 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
131 * newDerivedFromName, "1.0");
132 * assertEquals("Check response code after get database normative", 200,
133 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
135 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
138 // Derived from set to Database
139 List<String> derivedFrom = new ArrayList<>();
140 derivedFrom.add(oldDerivedFromName);
141 resourceDetails.setDerivedFrom(derivedFrom);
143 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
144 AssertJUnit.assertEquals("Check response code after create resource", 201,
145 restResponse.getErrorCode().intValue());
146 Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
149 derivedFrom.add(newDerivedFromName);
150 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
151 sdncModifierDetails, currentResource.getUniqueId(), "");
152 AssertJUnit.assertEquals("Check response code after create resource", 200,
153 updatedRestResponse.getErrorCode().intValue());
157 protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
158 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
160 updatedResourceDetails.setVersion("mumu");
161 updatedResourceDetails.setIsAbstract(true);
162 updatedResourceDetails.setIsHighestVersion(true);
163 updatedResourceDetails.setCreatorUserId("df4444");
164 updatedResourceDetails.setCreatorFullName("John Doe");
165 updatedResourceDetails.setLastUpdaterUserId("gf5646");
166 updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
167 updatedResourceDetails.setCreationDate(new Long(4444));
168 updatedResourceDetails.setLastUpdateDate(new Long("534535"));
169 updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
170 updatedResourceDetails.setCost("6.1");
171 updatedResourceDetails.setLicenseType("Installation");
172 updatedResourceDetails.setUUID("dfsfsdf");
173 return updatedResourceDetails;
176 public void UpdateResourceNotFoundTest() throws Exception {
178 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
180 String resourceName = "cisco4";
182 String description = "updatedDescription";
183 ArrayList<String> resourceTags = new ArrayList<String>();
184 resourceTags.add("tag2");
185 String category = ServiceCategoriesEnum.MOBILITY.getValue();
186 ArrayList<String> derivedFrom = new ArrayList<String>();
187 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
188 String vendorName = "newOracle";
189 String vendorRelease = "2.5";
190 String contactId = "jh0003";
191 String icon = "myICON";
193 ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags,
194 category, derivedFrom, vendorName, vendorRelease, contactId, icon);
195 updatedResourceDetails.setUniqueId("dummyId");
196 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
197 sdncModifierDetails, "0.1");
200 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
201 AssertJUnit.assertNotNull("check error code exists in response after update resource",
202 updatedRestResponse.getErrorCode());
203 AssertJUnit.assertEquals("Check response code after update resource", 404,
204 updatedRestResponse.getErrorCode().intValue());
205 // String resourceId =
206 // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
207 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
208 updatedRestResponse.getResponse());
211 // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
213 updatedResourceDetails = defineUpdatedResourse(resourceName);
214 updatedResourceDetails.setUniqueId("dummyId");
215 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
217 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
218 AssertJUnit.assertNotNull("check error code exists in response after update resource",
219 updatedRestResponse.getErrorCode());
220 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
221 updatedRestResponse.getResponse());
225 public char[] getInValidChars() throws Exception {
227 char[] extendedCharsArray = new char[59];
229 for (int i = 0; i < 44; i++) {
230 extendedCharsArray[i] = ch;
234 for (int i = 44; i < 51; i++) {
235 extendedCharsArray[i] = ch;
239 for (int i = 51; i < 55; i++) {
240 extendedCharsArray[i] = ch;
244 for (int i = 55; i < 59; i++) {
245 extendedCharsArray[i] = ch;
248 return extendedCharsArray;
251 public char[] getTagInValidFormatChars() throws Exception {
252 // Tag format is the same as defined for "Resource Name" :
253 // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
254 // ('_'), dash ('-'), dot ('.')
255 char[] notValidCharsArray = new char[30];
257 for (int i = 0; i < 12; i++) {
258 notValidCharsArray[i] = ch;
261 notValidCharsArray[13] = 47;
263 for (int i = 14; i < 21; i++) {
264 notValidCharsArray[i] = ch;
268 for (int i = 21; i < 24; i++) {
269 notValidCharsArray[i] = ch;
272 notValidCharsArray[24] = 96;
274 for (int i = 25; i < 30; i++) {
275 notValidCharsArray[i] = ch;
278 return notValidCharsArray;
281 public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
283 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
285 // define and create resource
286 ResourceReqDetails resourceDetails = defineResourse();
287 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
288 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
289 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
291 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
292 String resourceId = resourceDetails.getUniqueId();
293 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
296 JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
298 List<String> resource = new ArrayList<>();
299 resource.add("Resource");
301 // remove Description
302 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description",
303 ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
305 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags",
306 ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
308 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category",
309 ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
311 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName",
312 ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
313 // remove VendorRelease
314 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease",
315 ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
316 // remove AT&T Contact
317 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId",
318 ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
320 // get resource with original name. original metadata should be returned
321 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
323 AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
324 AssertJUnit.assertNotNull("check error code exists in response after get resource",
325 getRestResponse.getErrorCode());
326 AssertJUnit.assertEquals("Check response code after update resource", 200,
327 getRestResponse.getErrorCode().intValue());
329 // parse updated response to javaObject
330 Resource getResourceRespJavaObject = ResponseParser
331 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
332 // validate that metadata was not changed
333 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
335 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
336 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
337 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
340 // End of validation tests
341 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
343 protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
344 String description = "updatedDescription";
345 ArrayList<String> resourceTags = new ArrayList<String>();
346 // Duplicate tags are allowed and should be de-duplicated by server side
347 resourceTags.add(resourceName);
348 resourceTags.add("tag1");
349 resourceTags.add("tag1");
350 resourceTags.add("tag2");
351 resourceTags.add("tag2");
352 String category = ServiceCategoriesEnum.VOIP.getValue();
353 ArrayList<String> derivedFrom = new ArrayList<String>();
354 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
355 String vendorName = "updatedOracle";
356 String vendorRelease = "3.5";
357 String contactId = "jh0001";
358 String icon = "myUpdatedICON";
360 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
361 derivedFrom, vendorName, vendorRelease, contactId, icon);
362 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
363 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
365 return resourceDetails;
368 protected ResourceReqDetails defineResourse() {
369 String resourceName = "cisco4";
370 String description = "description";
371 ArrayList<String> resourceTags = new ArrayList<String>();
372 resourceTags.add(resourceName);
373 ArrayList<String> derivedFrom = new ArrayList<String>();
374 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
375 String vendorName = "Oracle";
376 String vendorRelease = "1.5";
377 String contactId = "jh0003";
378 String icon = "objectStorage";
380 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null,
381 derivedFrom, vendorName, vendorRelease, contactId, icon);
382 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
383 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
385 return resourceDetails;
388 protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails)
391 DbUtils.cleanAllAudits();
394 RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
397 AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
398 AssertJUnit.assertNotNull("check error code exists in response after create resource",
399 restResponse.getErrorCode());
400 AssertJUnit.assertEquals("Check response code after create resource", 201,
401 restResponse.getErrorCode().intValue());
406 protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails,
407 String uri) throws Exception {
410 RestResponse ResourceResponse;
412 config = Utils.getConfig();
413 Map<String, String> headersMap = new HashMap<String, String>();
414 headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
415 headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
416 headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
417 HttpRequest http = new HttpRequest();
418 String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(),
419 config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
422 ResourceResponse = http.httpSendGet(url, headersMap);
423 } else if (uri == "POST") {
424 Gson gson = new Gson();
425 String userBodyJson = gson.toJson(updatedResourceDetails);
426 ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
427 } else if (uri == "DELETE") {
428 ResourceResponse = http.httpSendDelete(url, headersMap);
432 return ResourceResponse;
433 } catch (FileNotFoundException e) {
441 protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
442 // json object: resourceName and icon are must
443 JSONObject jObject = new JSONObject();
445 List<String> tagsList = Arrays.asList(resourceDetails.getName());
446 List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
448 jObject.put("name", resourceDetails.getName());
449 jObject.put("description", "updatedDescription");
450 jObject.put("tags", tagsList);
451 jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
452 jObject.put("derivedFrom", derivedFromList);
453 jObject.put("vendorName", "newOracle");
454 jObject.put("vendorRelease", "1.5");
455 jObject.put("contactId", "jh0003");
456 jObject.put("icon", resourceDetails.getIcon());
461 protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
462 jObject.remove(removedPropery);
467 // purpose: function for controlling json body fields and validating
469 protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject,
470 String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
472 JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
473 // remove description from jsonObject
474 jObject = RemoveFromJsonObject(jObject, removedField);
475 // update with incomplete body.
476 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(),
477 sdncModifierDetails, resourceId);
479 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
480 AssertJUnit.assertNotNull("check error code exists in response after update resource",
481 updatedRestResponse.getErrorCode());
482 ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
486 // purpose: function for validating error response
487 protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails,
488 String recievedMessage, List<String> variables) throws Exception {
489 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
490 sdncModifierDetails, "0.1");
492 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
493 AssertJUnit.assertNotNull("check error code exists in response after update resource",
494 updatedRestResponse.getErrorCode());
495 ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
499 protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse)
501 // parse response to javaObject
502 Resource updatedResourceRespJavaObject = ResponseParser
503 .convertResourceResponseToJavaObject(restResponse.getResponse());
504 AssertJUnit.assertTrue(
505 !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
506 AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
507 AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
508 AssertJUnit.assertTrue(
509 !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
510 AssertJUnit.assertTrue(
511 !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
512 AssertJUnit.assertTrue(
513 !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
515 .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
516 AssertJUnit.assertTrue(
517 !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
518 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName()
519 .equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
520 AssertJUnit.assertTrue(
521 !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
522 AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
524 .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
525 AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
529 protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse)
531 // parse response to javaObject
532 Resource updatedResourceRespJavaObject = ResponseParser
533 .convertResourceResponseToJavaObject(restResponse.getResponse());
534 // validate request vs response
535 ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
538 public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails,
539 String resourceVersion) {
541 ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
543 expectedResourceAuditJavaObject.setAction("Checkout");
544 expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
545 expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
546 expectedResourceAuditJavaObject.setStatus("200.0");
547 expectedResourceAuditJavaObject.setDesc("OK");
548 expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
549 expectedResourceAuditJavaObject.setResourceType("Resource");
550 expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
551 expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
552 expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
553 expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
555 return expectedResourceAuditJavaObject;
559 public enum FieldToValidate {
560 contactId, Tags, VendorName, VendorRelease, Description
564 public void UpdateBy_postTest() throws Exception {
566 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
567 String resourceName = resourceDetails.getName();
569 // update resource - without changing resourceName
570 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
572 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
575 assertNotNull("check response object is not null after update resource", updatedRestResponse);
576 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
577 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
578 updatedRestResponse.getResponse());
580 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
581 resourceDetails.getUniqueId());
582 assertNotNull("check response object is not null after update resource", getRestResponse);
583 parseResponseAndValidate(resourceDetails, getRestResponse);
588 public void UpdateBy_getTest() throws Exception {
590 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
591 String resourceName = resourceDetails.getName();
593 // update resource - without changing resourceName
594 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
595 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
598 assertNotNull("check response object is not null after update resource", updatedRestResponse);
599 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
600 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
601 updatedRestResponse.getResponse());
603 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
604 resourceDetails.getUniqueId());
605 assertNotNull("check response object is not null after update resource", getRestResponse);
606 parseResponseAndValidate(resourceDetails, getRestResponse);
611 public void UpdateBy_deleteTest() throws Exception {
613 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
614 String resourceName = resourceDetails.getName();
616 // update resource - without changing resourceName
617 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
618 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails,
622 assertNotNull("check response object is not null after update resource", updatedRestResponse);
623 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
624 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
625 updatedRestResponse.getResponse());
627 RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails,
628 resourceDetails.getUniqueId(), "");
629 assertNotNull("check response object is not null after update resource", getRestResponse);
630 parseResponseAndValidate(resourceDetails, getRestResponse);
637 public void UpdateWithInvaldJsonBodyTest() throws Exception {
639 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
640 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
641 String resourceId = resourceDetails.getUniqueId();
643 // update Descirption value
644 String description = "updatedDescription";
646 // send update with incompleted json, only description string
647 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails,
651 assertNotNull("check response object is not null after update resource", updatedRestResponse);
652 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
653 assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
655 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
656 resourceDetails.getUniqueId());
657 assertNotNull("check response object is not null after update resource", getRestResponse);
658 parseResponseAndValidate(resourceDetails, getRestResponse);
663 // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
666 // RestResponse restResponse = createResource(sdncModifierDetails,
668 // String resourceName = resourceDetails.getName();
670 // // new user parameters
671 // String userFirstName = "Kot";
672 // String userLastName = "Matroskin";
673 // String role = "ADMIN";
674 // User sdncUserDetails = new User(userFirstName, userLastName,
675 // httpCspUserId, email, role,null);
676 // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
677 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
679 // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
680 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
682 // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
683 // httpCspUserId, email,role,null);
684 // ResourceReqDetails updatedResourceDetails =
685 // defineUpdatedResourse(resourceName);
686 // RestResponse updatedRestResponse =
687 // ResourceRestUtils.updateResource(updatedResourceDetails,
688 // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
690 // // validate response
691 // assertNotNull("check response object is not null after update resource",
692 // updatedRestResponse);
693 // assertNotNull("check error code exists in response after update
694 // resource", updatedRestResponse.getErrorCode());
695 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
696 // Empty_List, updatedRestResponse.getResponse());
698 // RestResponse getRestResponse =
699 // ResourceRestUtils.getResource(sdncModifierDetails,
700 // resourceDetails.getUniqueId());
701 // assertNotNull("check response object is not null after update resource",
703 // parseResponseAndValidate(resourceDetails, getRestResponse);
709 public void UpdateResourceNameSensitiveTest() throws Exception {
710 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
711 String resourceBaseVersion = "0.1";
712 String resourceName = "Ab";
713 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
715 RestResponse response = null;
716 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
717 updatedResourceDetails.getName(), "0.1");
718 BaseRestUtils.checkDeleteResponse(response);
719 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
720 updatedResourceDetails.getName(), "0.2");
721 BaseRestUtils.checkDeleteResponse(response);
723 RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
724 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
727 logger.debug("Changing resource life cycle ");
728 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails,
729 sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
730 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
732 // String resourceCertifyVersion = "0.1";
733 logger.debug("Changing resource life cycle ");
734 checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails,
735 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
736 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
738 updatedResourceDetails.setName("ABC_-bt.aT");
739 ArrayList<String> resourceTag = new ArrayList<String>();
740 resourceTag.add(0, "ABC_-bt.aT");
741 updatedResourceDetails.setTags(resourceTag);
742 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
743 sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
744 assertNotNull("check response object is not null after update resource", updatedRestResponse);
745 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
746 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
747 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
750 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
751 updatedResourceDetails.getName(), "0.1");
752 BaseRestUtils.checkDeleteResponse(response);
753 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
754 updatedResourceDetails.getName(), "0.2");
755 BaseRestUtils.checkDeleteResponse(response);
760 public void UpdateIcon_InegativeFlow() throws Exception {
762 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
763 String resourceName = resourceDetails.getName();
765 List<String> resourceList = new ArrayList<String>();
766 resourceList.add(0, "Resource");
767 // check InValid Characters
768 char[] notValidCharsArray = new char[59];
769 notValidCharsArray = getInValidChars();
770 // update metadata details
771 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
772 RestResponse updatedRestResponse;
774 for (int i = 0; i < notValidCharsArray.length; i++) {
775 // change icon of metadata
776 updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
778 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
779 resourceDetails.getUniqueId(), "");
781 assertNotNull("check response object is not null after update resource", updatedRestResponse);
782 assertNotNull("check error code exists in response after update resource",
783 updatedRestResponse.getErrorCode());
784 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList,
785 updatedRestResponse.getResponse());
786 assertEquals("Check response code after updating resource icon", 400,
787 updatedRestResponse.getErrorCode().intValue());
788 assertEquals("Check response code after updating resource icon", "Bad Request",
789 updatedRestResponse.getResponseMessage().toString());
794 String updateIcon = "";
795 updatedResourceDetails.setIcon(updateIcon);
796 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
797 resourceDetails.getUniqueId(), "");
798 assertNotNull("check response object is not null after update resource", updatedRestResponse);
799 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
800 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList,
801 updatedRestResponse.getResponse());
803 // Icon length more then 25 characters
804 resourceList.add(1, "25");
805 updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
806 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
807 resourceDetails.getUniqueId(), "");
809 assertNotNull("check response object is not null after update resource", updatedRestResponse);
810 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
811 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList,
812 updatedRestResponse.getResponse());
813 assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
814 assertEquals("Check response code after updating resource icon", "Bad Request",
815 updatedRestResponse.getResponseMessage().toString());
817 // get resource with original name. original metadata should be returned
818 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
819 resourceDetails.getUniqueId());
821 assertNotNull("check response object is not null after get resource", getRestResponse);
822 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
823 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
825 // parse updated response to javaObject
826 Resource getResourceRespJavaObject = ResponseParser
827 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
828 // validate that metadata was not changed
829 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
834 public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
836 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
837 String resourceBaseVersion = "0.1";
840 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
841 String resourceName = resourceDetails.getName();
843 ResourceReqDetails updatedResourceDetails = defineResourse();
844 updatedResourceDetails.setName("updatedResourceName");
845 List<String> tags = updatedResourceDetails.getTags();
847 for (Iterator<String> iter = tags.listIterator(); iter.hasNext();) {
848 String a = iter.next();
849 if (a.equals("updatedResourceName")) {
854 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
855 sdncModifierDetails, resourceDetails.getUniqueId(), "");
857 List<String> resourceList = new ArrayList<String>();
858 assertNotNull("check response object is not null after update resource", updatedRestResponse);
859 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
860 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
861 resourceList, updatedRestResponse.getResponse());
862 assertEquals("Check response code after updating resource icon", 400,
863 updatedRestResponse.getErrorCode().intValue());
865 // get resource with original name. original metadata should be returned
866 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
867 resourceDetails.getUniqueId());
869 assertNotNull("check response object is not null after get resource", getRestResponse);
870 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
871 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
872 // parse updated response to javaObject
873 Resource getResourceRespJavaObject = ResponseParser
874 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
875 // validate that metadata was not changed
876 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
881 public void UpdateResourceName_negativeFlow() throws Exception {
882 // The validation are done in Tag's validation
883 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
885 RestResponse updatedRestResponse;
886 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
887 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
888 String uniqueId = resourceDetails.getUniqueId();
889 String resourceName = resourceDetails.getName();
890 // check InValid Characters
891 char[] notValidCharsArray = new char[59];
892 notValidCharsArray = getInValidChars();
893 ArrayList<String> resource_Name = new ArrayList<String>();
894 List<String> resourceList = new ArrayList<String>();
896 ArrayList<String> resourceTags = new ArrayList<String>();
897 resourceList.add(0, "Resource");
899 // update metadata details
900 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
901 for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
902 if (i != 1 && i != 46
904 * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
905 */ i != 31) // space ("") and dot(.)
907 // change resourceName parameter
908 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
909 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
910 updatedResourceDetails.setTags(resource_Name);
911 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
912 sdncAdminModifierDetails, uniqueId, "");
914 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
915 // Empty_List, updatedRestResponse.getResponse());
916 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList,
917 updatedRestResponse.getResponse());
922 // resourceName length more then 50 characters
923 // Duplicate tags are allowed and should be de-duplicated by server side
924 resource_Name.add(resourceName);
925 resource_Name.add("tag1");
926 resource_Name.add("tag1");
927 resource_Name.add("tag2");
928 resource_Name.add("tag2");
930 resourceList.add(1, "1024");
931 // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
932 updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
933 // resource_Name.add("123456789012345678901234567890123456789012345678901");
934 updatedResourceDetails.setTags(resource_Name);
935 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
938 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList,
939 updatedRestResponse.getResponse());
941 // get resource with original name. original metadata should be returned
942 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
943 resourceDetails.getUniqueId());
945 assertNotNull("check response object is not null after get resource", getRestResponse);
946 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
947 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
948 // parse updated response to javaObject
949 Resource getResourceRespJavaObject = ResponseParser
950 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
951 // validate that metadata was not changed
952 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
955 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails,
956 updatedResourceDetails.getName(), "0.1");
957 BaseRestUtils.checkDeleteResponse(response);
961 public void UpdateResourceInformation_NotCheckedOut() throws Exception {
963 String resourceBaseVersion = "0.1";
964 List<String> resourceList = new ArrayList<String>();
966 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
967 String resourceName = resourceDetails.getName();
970 logger.debug("Changing resource life cycle ");
971 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
972 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
973 assertNotNull("check response object is not null after checkout resource", checkoutResource);
974 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
975 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
977 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
979 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
980 sdncModifierDetails, resourceDetails.getUniqueId(), "");
981 assertNotNull("check response object is not null after update resource", updatedRestResponse);
982 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
983 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
984 updatedRestResponse.getResponse());
985 assertEquals("Check response code after updating resource icon", 409,
986 updatedRestResponse.getErrorCode().intValue());
988 // get resource with original name. original metadata should be returned
989 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
990 resourceDetails.getUniqueId());
992 assertNotNull("check response object is not null after get resource", getRestResponse);
993 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
994 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
996 // parse updated response to javaObject
997 Resource getResourceRespJavaObject = ResponseParser
998 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
999 // validate that metadata was not changed
1000 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1005 public void UpdateResourceInformation_resourceVersion_11() throws Exception {
1007 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1008 String resourceBaseVersion = "0.1";
1011 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1012 String resourceName = resourceDetails.getName();
1014 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1018 logger.debug("Changing resource life cycle ");
1019 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1020 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1021 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1023 logger.debug("Changing resource life cycle ");
1024 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1025 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1026 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1028 logger.debug("Changing resource life cycle ");
1029 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1030 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1031 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1033 logger.debug("Changing resource life cycle ");
1034 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1035 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1036 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1038 String resourceCertifyVersion = "1.0";
1039 logger.debug("Changing resource life cycle ");
1040 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1041 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
1042 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1044 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1046 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1047 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1048 // validate response
1049 List<String> resourceList = new ArrayList<String>();
1050 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1051 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1052 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
1053 updatedRestResponse.getResponse());
1054 // assertEquals("Check response code after updating resource icon", 409,
1055 // updatedRestResponse.getErrorCode().intValue());
1057 // get resource with original name. original metadata should be returned
1058 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1059 resourceDetails.getUniqueId());
1060 // validate response
1061 assertNotNull("check response object is not null after get resource", getRestResponse);
1063 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1065 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1066 // parse updated response to javaObject
1067 Resource getResourceRespJavaObject = ResponseParser
1068 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1069 // validate that metadata was not changed
1070 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1075 public void UpdateResourceInformation_resourceVersion_02() throws Exception {
1077 String resourceBaseVersion = "0.1";
1080 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1081 String resourceName = resourceDetails.getName();
1083 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1087 logger.debug("Changing resource life cycle ");
1088 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1089 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1090 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1092 // String resourceCertifyVersion = "0.1";
1093 logger.debug("Changing resource life cycle ");
1094 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1095 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
1096 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1098 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1100 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1101 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1102 // validate response
1103 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1104 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1105 assertEquals("Check response code after updating resource icon", 200,
1106 updatedRestResponse.getErrorCode().intValue());
1108 // get resource with original name. original metadata should be returned
1109 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1110 resourceDetails.getUniqueId());
1111 // validate response
1112 assertNotNull("check response object is not null after get resource", getRestResponse);
1113 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1114 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1116 // parse updated response to javaObject
1117 Resource getResourceRespJavaObject = ResponseParser
1118 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1119 // validate that metadata was not changed
1120 ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
1123 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1124 updatedResourceDetails.getName(), "0.1");
1125 BaseRestUtils.checkDeleteResponse(response);
1126 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1127 updatedResourceDetails.getName(), "0.2");
1128 BaseRestUtils.checkDeleteResponse(response);
1133 public void UpdateResourceIcon_resourceVersion_11() throws Exception {
1134 // Can be changed only if major version is "0".
1136 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1137 String resourceBaseVersion = "0.1";
1140 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1141 String resourceName = resourceDetails.getName();
1143 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1147 logger.debug("Changing resource life cycle ");
1148 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1149 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1150 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1152 logger.debug("Changing resource life cycle ");
1153 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1154 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1155 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1157 logger.debug("Changing resource life cycle ");
1158 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1159 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1160 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1162 logger.debug("Changing resource life cycle ");
1163 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1164 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1165 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1167 String resourceCertifyVersion = "1.0";
1168 logger.debug("Changing resource life cycle ");
1169 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1170 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1171 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1173 // ResourceReqDetails updatedResourceDetails =
1174 // defineUpdatedResourse(resourceName);
1175 ResourceReqDetails updatedResourceDetails = defineResourse();
1176 // updatedResourceDetails.setVendorName("updatedVandorName");
1177 updatedResourceDetails.setIcon("updatedIcon");
1179 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1180 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1181 // validate response
1182 List<String> resourceList = new ArrayList<String>();
1183 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList,
1184 updatedRestResponse.getResponse());
1186 // get resource with original name. original metadata should be returned
1187 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1188 resourceDetails.getUniqueId());
1189 // validate response
1190 assertNotNull("check response object is not null after get resource", getRestResponse);
1191 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1192 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1193 // parse updated response to javaObject
1194 Resource getResourceRespJavaObject = ResponseParser
1195 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1196 // validate that metadata was not changed
1197 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1202 public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1203 // Can be changed only if the major resource version is "0".
1204 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1205 String resourceBaseVersion = "0.1";
1208 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1209 String resourceName = resourceDetails.getName();
1211 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1215 logger.debug("Changing resource life cycle ");
1216 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1217 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1218 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1220 logger.debug("Changing resource life cycle ");
1221 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1222 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1223 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1225 logger.debug("Changing resource life cycle ");
1226 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1227 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1228 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1230 logger.debug("Changing resource life cycle ");
1231 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1232 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1233 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1235 String resourceCertifyVersion = "1.0";
1236 logger.debug("Changing resource life cycle ");
1237 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1238 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1239 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1241 // ResourceReqDetails updatedResourceDetails =
1242 // defineUpdatedResourse(resourceName);
1243 ResourceReqDetails updatedResourceDetails = defineResourse();
1245 updatedResourceDetails.setVendorName("updatedVandorName");
1247 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1248 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1249 // validate response
1250 List<String> resourceList = new ArrayList<String>();
1251 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1252 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1253 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(),
1254 resourceList, updatedRestResponse.getResponse());
1255 assertEquals("Check response code after updating resource icon", 400,
1256 updatedRestResponse.getErrorCode().intValue());
1258 // get resource with original name. original metadata should be returned
1259 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1260 resourceDetails.getUniqueId());
1261 // validate response
1262 assertNotNull("check response object is not null after get resource", getRestResponse);
1263 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1264 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1265 // parse updated response to javaObject
1266 Resource getResourceRespJavaObject = ResponseParser
1267 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1268 // validate that metadata was not changed
1269 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1274 public void UpdateResourceName_resourceVersion_11() throws Exception {
1275 // Can be changed only if the major resource version is "0".
1276 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1277 String resourceBaseVersion = "0.1";
1280 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1281 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1282 String resourceName = resourceDetails.getName();
1284 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1288 logger.debug("Changing resource life cycle ");
1289 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1290 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1291 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1293 logger.debug("Changing resource life cycle ");
1294 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1295 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1296 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1298 logger.debug("Changing resource life cycle ");
1299 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1300 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1301 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1303 logger.debug("Changing resource life cycle ");
1304 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1305 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1306 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1308 String resourceCertifyVersion = "1.0";
1309 logger.debug("Changing resource life cycle ");
1310 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1311 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1312 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1315 * //ResourceReqDetails updatedResourceDetails =
1316 * defineUpdatedResourse(resourceName); ResourceReqDetails
1317 * updatedResourceDetails = defineResourse();
1319 * updatedResourceDetails.setResourceName("updatedResourceName");
1320 * updatedResourceDetails.setIcon("updatedResourceName");
1322 resourceDetails.setName("updatedResourceName");
1323 List<String> tagList = new ArrayList<String>();
1324 tagList.add(0, "updatedResourceName");
1325 resourceDetails.setTags(tagList);
1327 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1328 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1329 // validate response
1330 List<String> resourceList = new ArrayList<String>();
1331 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1332 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1333 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList,
1334 updatedRestResponse.getResponse());
1339 public void UpdateResourceTag_resourceVersion_11() throws Exception {
1340 // Tag Can be updated when major version is "0".
1341 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1342 String resourceBaseVersion = "0.1";
1345 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1346 String resourceName = resourceDetails.getName();
1348 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1352 logger.debug("Changing resource life cycle ");
1353 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1354 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1355 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1357 logger.debug("Changing resource life cycle ");
1358 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1359 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1360 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1362 logger.debug("Changing resource life cycle ");
1363 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1364 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1365 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1367 logger.debug("Changing resource life cycle ");
1368 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1369 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1370 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1372 String resourceCertifyVersion = "1.0";
1373 logger.debug("Changing resource life cycle ");
1374 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1375 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1376 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1378 // ResourceReqDetails updatedResourceDetails =
1379 // defineUpdatedResourse(resourceName);
1380 ResourceReqDetails updatedResourceDetails = defineResourse();
1381 // updatedResourceDetails.setVendorName("updatedVandorName");
1383 ArrayList<String> resourceTags = new ArrayList<String>();
1384 resourceTags.add("NewTag");
1385 resourceTags.add(resourceDetails.getName());
1387 updatedResourceDetails.setTags(resourceTags);
1389 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1390 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1391 // validate response
1392 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1393 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1394 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1396 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1397 resourceDetails.getUniqueId());
1398 assertNotNull("check response object is not null after update resource", getRestResponse);
1399 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1404 public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1406 // Tag, contactId, vendorRelease,tags And description - Can be also
1407 // updated when major version is NOT "0".
1408 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1409 String resourceBaseVersion = "0.1";
1412 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1414 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1418 logger.debug("Changing resource life cycle ");
1419 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1420 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1421 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1423 logger.debug("Changing resource life cycle ");
1424 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1425 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1426 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1428 logger.debug("Changing resource life cycle ");
1429 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1430 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1431 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1433 logger.debug("Changing resource life cycle ");
1434 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1435 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1436 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1438 String resourceCertifyVersion = "1.0";
1439 logger.debug("Changing resource life cycle ");
1440 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1441 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1442 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1444 // ResourceReqDetails updatedResourceDetails =
1445 // defineUpdatedResourse(resourceName);
1446 ResourceReqDetails updatedResourceDetails = defineResourse();
1447 // updatedResourceDetails.setVendorName("updatedVandorName");
1449 // updated allowed parameters when major resource version is NOT "0"
1450 ArrayList<String> resourceTags = new ArrayList<String>();
1451 resourceTags.add("NewTag");
1452 resourceTags.add(resourceDetails.getName());
1453 updatedResourceDetails.setTags(resourceTags);
1454 updatedResourceDetails.setDescription("UpdatedDescription");
1455 updatedResourceDetails.setVendorRelease("5.1");
1456 updatedResourceDetails.setContactId("bt750h");
1458 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1459 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1460 // validate response
1461 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1462 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1463 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1465 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1466 resourceDetails.getUniqueId());
1467 assertNotNull("check response object is not null after update resource", getRestResponse);
1468 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1473 public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1474 // DerivedFrom parameter - Can be updated when major version is "0".
1475 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1476 String resourceBaseVersion = "0.1";
1479 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1480 String resourceName = resourceDetails.getName();
1482 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1486 logger.debug("Changing resource life cycle ");
1487 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1488 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1489 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1491 logger.debug("Changing resource life cycle ");
1492 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1493 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1494 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1496 logger.debug("Changing resource life cycle ");
1497 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1498 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1499 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1501 logger.debug("Changing resource life cycle ");
1502 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1503 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1504 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1506 String resourceCertifyVersion = "1.0";
1507 logger.debug("Changing resource life cycle ");
1508 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1509 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1510 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1512 // ResourceReqDetails updatedResourceDetails =
1513 // defineUpdatedResourse(resourceName);
1514 ResourceReqDetails updatedResourceDetails = defineResourse();
1515 ArrayList<String> drivenFrom = new ArrayList<String>();
1516 drivenFrom.add(0, "tosca.nodes.Container.Application");
1517 updatedResourceDetails.setDerivedFrom(drivenFrom);
1519 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1520 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1521 // validate response
1522 List<String> resourceList = new ArrayList<String>();
1523 ResourceRestUtils.checkSuccess(updatedRestResponse);
1525 // get resource with original name. original metadata should be returned
1526 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1527 resourceDetails.getUniqueId());
1528 // validate response
1529 assertNotNull("check response object is not null after get resource", getRestResponse);
1530 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1531 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1532 // parse updated response to javaObject
1533 Resource getResourceRespJavaObject = ResponseParser
1534 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1535 // validate that metadata was not changed
1536 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1541 public void UpdateResource_vendorNameValidation() throws Exception {
1543 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1544 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1545 String updatedVendorName = "";
1546 String uniqueId = resourceDetails.getUniqueId();
1547 resourceDetails.setVendorName(updatedVendorName);
1548 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1549 sdncModifierDetails, uniqueId, "");
1550 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1551 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1552 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1553 updatedRestResponse.getResponse());
1555 // update resource vendorName metadata: 1 characters
1556 updatedVendorName = " ";
1558 resourceDetails.setVendorName(updatedVendorName);
1559 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1561 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1562 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1563 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1564 updatedRestResponse.getResponse());
1566 // update resource vendorName metadata: 25 characters
1567 updatedVendorName = "Verification and validati";
1569 resourceDetails.setVendorName(updatedVendorName);
1570 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1572 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1573 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1574 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1575 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1577 // update resource vendorName metadata: 26 characters
1578 updatedVendorName = "Verification and validatii";
1580 List<String> myList = new ArrayList<String>();
1581 myList.add(0, "25");
1582 resourceDetails.setVendorName(updatedVendorName);
1583 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1585 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1586 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList,
1587 updatedRestResponse.getResponse());
1589 // update resource VendorRelease metadata: forbidden characters
1590 updatedVendorName = "A1<";
1592 resourceDetails.setVendorName(updatedVendorName);
1593 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1595 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1596 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1597 updatedRestResponse.getResponse());
1599 updatedVendorName = "A1>";
1601 resourceDetails.setVendorName(updatedVendorName);
1602 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1604 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1605 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1606 updatedRestResponse.getResponse());
1608 updatedVendorName = "A1:";
1610 resourceDetails.setVendorName(updatedVendorName);
1611 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1613 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1614 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1615 updatedRestResponse.getResponse());
1617 updatedVendorName = "A1\"";
1619 resourceDetails.setVendorName(updatedVendorName);
1620 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1622 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1623 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1624 updatedRestResponse.getResponse());
1626 updatedVendorName = "A1/";
1628 resourceDetails.setVendorName(updatedVendorName);
1629 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1631 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1632 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1633 updatedRestResponse.getResponse());
1635 updatedVendorName = "A1\\";
1637 resourceDetails.setVendorName(updatedVendorName);
1638 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1640 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1641 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1642 updatedRestResponse.getResponse());
1644 updatedVendorName = "A1|";
1646 resourceDetails.setVendorName(updatedVendorName);
1647 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1649 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1650 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1651 updatedRestResponse.getResponse());
1653 updatedVendorName = "A1?";
1655 resourceDetails.setVendorName(updatedVendorName);
1656 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1658 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1659 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1660 updatedRestResponse.getResponse());
1662 updatedVendorName = "A1*";
1664 resourceDetails.setVendorName(updatedVendorName);
1665 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1667 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1668 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1669 updatedRestResponse.getResponse());
1671 // update resource vendorName metadata: null
1672 updatedVendorName = null;
1674 resourceDetails.setVendorName(updatedVendorName);
1675 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1677 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1678 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1679 updatedRestResponse.getResponse());
1684 public void UpdateResource_vendorReleaseValidation() throws Exception {
1686 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1687 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1688 RestResponse updatedRestResponse;
1689 String uniqueId = resourceDetails.getUniqueId();
1690 String updatedVendorRelease;
1691 // set VendorRelease
1693 // update resource VendorRelease metadata: 1 characters
1694 updatedVendorRelease = "1";
1695 // set VendorRelease
1696 resourceDetails.setVendorRelease(updatedVendorRelease);
1697 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1699 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1700 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1701 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1702 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1704 // update resource VendorRelease metadata: 25 characters
1705 updatedVendorRelease = "(!#1.00000000000000000000";
1706 // set VendorRelease
1707 resourceDetails.setVendorRelease(updatedVendorRelease);
1708 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1710 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1711 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1712 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1713 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1715 // update resource VendorRelease metadata: 26 characters
1716 updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1717 resourceDetails.setVendorRelease(updatedVendorRelease);
1718 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1720 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1721 Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1723 // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1724 // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1725 // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1727 // update resource VendorRelease metadata: forbidden characters
1728 updatedVendorRelease = "A1<";
1729 // set VendorRelease
1730 resourceDetails.setVendorRelease(updatedVendorRelease);
1731 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1733 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1734 updatedRestResponse.getResponse());
1736 updatedVendorRelease = "A1>";
1737 // set VendorRelease
1738 resourceDetails.setVendorRelease(updatedVendorRelease);
1739 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1741 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1742 updatedRestResponse.getResponse());
1744 updatedVendorRelease = "A1:";
1745 // set VendorRelease
1746 resourceDetails.setVendorRelease(updatedVendorRelease);
1747 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1749 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1750 updatedRestResponse.getResponse());
1752 updatedVendorRelease = "A1\"";
1753 // set VendorRelease
1754 resourceDetails.setVendorRelease(updatedVendorRelease);
1755 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1757 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1758 updatedRestResponse.getResponse());
1760 updatedVendorRelease = "A1/";
1761 // set VendorRelease
1762 resourceDetails.setVendorRelease(updatedVendorRelease);
1763 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1765 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1766 updatedRestResponse.getResponse());
1768 updatedVendorRelease = "A1\\";
1769 // set VendorRelease
1770 resourceDetails.setVendorRelease(updatedVendorRelease);
1771 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1773 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1774 updatedRestResponse.getResponse());
1776 updatedVendorRelease = "A1|";
1777 // set VendorRelease
1778 resourceDetails.setVendorRelease(updatedVendorRelease);
1779 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1781 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1782 updatedRestResponse.getResponse());
1784 updatedVendorRelease = "A1?";
1785 // set VendorRelease
1786 resourceDetails.setVendorRelease(updatedVendorRelease);
1787 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1789 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1790 updatedRestResponse.getResponse());
1792 updatedVendorRelease = "A1*";
1793 // set VendorRelease
1794 resourceDetails.setVendorRelease(updatedVendorRelease);
1795 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1797 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1798 updatedRestResponse.getResponse());
1800 // update resource VendorRelease metadata: null
1801 updatedVendorRelease = null;
1802 // set VendorRelease
1803 resourceDetails.setVendorRelease(updatedVendorRelease);
1804 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1806 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1807 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List,
1808 updatedRestResponse.getResponse());
1813 public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1834 RestResponse updatedRestResponse;
1836 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1837 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1838 String uniqueId = resourceDetails.getUniqueId();
1840 List<String> myList = new ArrayList<String>();
1841 myList.add(0, "Resource");
1842 String updatedcontactId = "";
1843 resourceDetails.setContactId(updatedcontactId);
1845 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1847 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1848 updatedRestResponse.getResponse());
1850 updatedcontactId = "ab12345";
1851 resourceDetails.setContactId(updatedcontactId);
1852 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1854 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1855 updatedRestResponse.getResponse());
1857 updatedcontactId = " ";
1858 resourceDetails.setContactId(updatedcontactId);
1859 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1861 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1862 updatedRestResponse.getResponse());
1864 updatedcontactId = "ab 50h";
1865 resourceDetails.setContactId(updatedcontactId);
1866 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1868 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1869 updatedRestResponse.getResponse());
1871 updatedcontactId = "ab123c";
1872 resourceDetails.setContactId(updatedcontactId);
1873 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1875 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1876 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1877 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1879 updatedcontactId = "cd789E";
1880 resourceDetails.setContactId(updatedcontactId);
1881 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1883 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1884 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1886 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1887 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1889 updatedcontactId = "ef4567";
1890 resourceDetails.setContactId(updatedcontactId);
1891 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1893 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1894 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1895 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1896 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1898 updatedcontactId = "AA012A";
1899 resourceDetails.setContactId(updatedcontactId);
1900 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1902 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1903 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1904 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1906 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1907 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1909 updatedcontactId = "CD012c";
1910 resourceDetails.setContactId(updatedcontactId);
1911 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1913 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1914 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1915 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1917 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1918 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1920 updatedcontactId = "EF0123";
1921 resourceDetails.setContactId(updatedcontactId);
1922 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1924 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1925 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1926 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1928 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1929 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1931 ////////////////////////////// **************//////////////////////////////
1932 List<String> resource = Arrays.asList("Resource");
1933 updatedcontactId = "01345a";
1934 resourceDetails.setContactId(updatedcontactId);
1935 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1937 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1938 updatedRestResponse.getResponse());
1940 updatedcontactId = "0y000B";
1941 resourceDetails.setContactId(updatedcontactId);
1942 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1944 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1945 updatedRestResponse.getResponse());
1947 updatedcontactId = "Y1000b";
1948 resourceDetails.setContactId(updatedcontactId);
1949 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1951 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1952 updatedRestResponse.getResponse());
1954 updatedcontactId = "abxyzC";
1955 resourceDetails.setContactId(updatedcontactId);
1956 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1958 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1959 updatedRestResponse.getResponse());
1961 updatedcontactId = "cdXYZc";
1962 resourceDetails.setContactId(updatedcontactId);
1963 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1965 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1966 updatedRestResponse.getResponse());
1968 updatedcontactId = "efXY1D";
1969 resourceDetails.setContactId(updatedcontactId);
1970 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1972 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1973 updatedRestResponse.getResponse());
1975 updatedcontactId = "EFabcD";
1976 resourceDetails.setContactId(updatedcontactId);
1977 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1979 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1980 updatedRestResponse.getResponse());
1982 updatedcontactId = "EFABCD";
1983 resourceDetails.setContactId(updatedcontactId);
1984 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1986 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1987 updatedRestResponse.getResponse());
1989 updatedcontactId = "EFABC1";
1990 resourceDetails.setContactId(updatedcontactId);
1991 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1993 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1994 updatedRestResponse.getResponse());
1996 updatedcontactId = "efui1D";
1997 resourceDetails.setContactId(updatedcontactId);
1998 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2000 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2001 updatedRestResponse.getResponse());
2003 updatedcontactId = "efui1!";
2004 resourceDetails.setContactId(updatedcontactId);
2005 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2007 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2008 updatedRestResponse.getResponse());
2010 updatedcontactId = "ef555!";
2011 resourceDetails.setContactId(updatedcontactId);
2012 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2014 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2015 updatedRestResponse.getResponse());
2017 updatedcontactId = ",f555";
2018 resourceDetails.setContactId(updatedcontactId);
2019 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2021 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2022 updatedRestResponse.getResponse());
2024 updatedcontactId = "EF55.5";
2025 resourceDetails.setContactId(updatedcontactId);
2026 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2028 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2029 updatedRestResponse.getResponse());
2031 // update resource contactId metadata: extended character set (128–255)
2032 resourceDetails.setContactId(extendedCharsStringBuilder());
2033 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2035 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2036 updatedRestResponse.getResponse());
2038 // update resource contactId metadata: null
2039 updatedcontactId = null;
2040 resourceDetails.setContactId(updatedcontactId);
2041 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2043 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
2044 updatedRestResponse.getResponse());
2049 public void UpdateResource_TagsFieldValidation() throws Exception {
2050 RestResponse updatedRestResponse;
2051 // define and create resource
2053 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2054 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2055 String uniqueId = resourceDetails.getUniqueId();
2057 String updatedTagField = "";
2058 ArrayList<String> resourceTags = new ArrayList<String>();
2059 resourceTags.add(updatedTagField);
2061 resourceDetails.setTags(resourceTags);
2062 List<String> variables = Arrays.asList("Resource", "tag");
2063 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2065 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2066 updatedRestResponse.getResponse());
2068 // update resource tags metadata: empty
2069 resourceTags = new ArrayList<String>();
2071 resourceDetails.setTags(resourceTags);
2072 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2074 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List,
2075 updatedRestResponse.getResponse());
2077 // update resource description metadata: 1 characters
2078 updatedTagField = "A";
2079 resourceTags = new ArrayList<String>();
2080 resourceTags.add(updatedTagField);
2081 resourceTags.add(resourceDetails.getName());
2083 resourceDetails.setTags(resourceTags);
2084 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2086 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2087 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2088 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2089 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2091 // OK - tag up to 50 chars
2092 updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
2093 resourceTags.add(updatedTagField);
2094 resourceDetails.setTags(resourceTags);
2095 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2097 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2098 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2099 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2100 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2102 // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
2103 String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
2104 String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
2105 String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
2106 String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
2107 String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
2108 String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
2109 String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
2110 String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
2111 String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
2112 String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
2113 String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
2114 String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
2115 String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
2116 String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
2117 String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
2118 String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
2119 String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
2120 String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
2121 String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
2123 resourceTags = new ArrayList<String>();
2124 resourceTags.add(updatedTagField);
2125 resourceTags.add(updatedTagField1);
2126 resourceTags.add(updatedTagField2);
2127 resourceTags.add(updatedTagField3);
2128 resourceTags.add(updatedTagField4);
2129 resourceTags.add(updatedTagField5);
2130 resourceTags.add(updatedTagField6);
2131 resourceTags.add(updatedTagField7);
2132 resourceTags.add(updatedTagField8);
2133 resourceTags.add(updatedTagField9);
2134 resourceTags.add(updatedTagField10);
2135 resourceTags.add(updatedTagField11);
2136 resourceTags.add(updatedTagField12);
2137 resourceTags.add(updatedTagField13);
2138 resourceTags.add(updatedTagField14);
2139 resourceTags.add(updatedTagField15);
2140 resourceTags.add(updatedTagField16);
2141 resourceTags.add(updatedTagField17);
2142 resourceTags.add(updatedTagField18);
2143 resourceTags.add(updatedTagField19);
2144 resourceTags.add(resourceDetails.getName());
2146 resourceDetails.setTags(resourceTags);
2147 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2149 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2150 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2151 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2152 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2154 // Add another tag-exceeds limit
2155 resourceTags.add("d");
2156 resourceDetails.setTags(resourceTags);
2157 ArrayList<String> myArray = new ArrayList<String>();
2158 myArray.add(0, "1024");
2159 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2161 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray,
2162 updatedRestResponse.getResponse());
2164 // Tag exceeds limit - 51
2165 resourceTags = new ArrayList<String>();
2166 updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
2167 resourceTags.add(updatedTagField);
2168 resourceTags.add(resourceDetails.getName());
2170 resourceDetails.setTags(resourceTags);
2172 myArray.add(0, "50");
2173 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2175 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray,
2176 updatedRestResponse.getResponse());
2181 public void UpdateResource_DesriptionFieldValidation() throws Exception {
2182 // define and create resource
2183 RestResponse updatedRestResponse;
2185 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2186 String uniqueId = resourceDetails.getUniqueId();
2187 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2188 List<String> resource = new ArrayList<>();
2189 resource.add("Resource");
2190 // update resource description metadata: 0 characters
2191 String updatedDescription = "";
2193 resourceDetails.setDescription(updatedDescription);
2194 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2196 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2197 updatedRestResponse.getResponse());
2199 // update resource description metadata: null
2200 updatedDescription = null;
2202 resourceDetails.setDescription(updatedDescription);
2203 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2205 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2206 updatedRestResponse.getResponse());
2208 // update resource description metadata: 1 characters
2209 updatedDescription = "A";
2211 resourceDetails.setDescription(updatedDescription);
2212 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2214 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2215 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2216 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2217 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2219 // update resource description metadata: 1024 characters
2220 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2221 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2222 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2223 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2224 + "The longest quills grow from its shoulders to about a third of the animal's length."
2225 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2226 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2227 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2228 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
2230 resourceDetails.setDescription(updatedDescription);
2231 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2233 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2234 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2235 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2236 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2238 // update resource description metadata: 1025 characters
2239 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2240 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2241 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2242 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2243 + "The longest quills grow from its shoulders to about a third of the animal's length."
2244 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2245 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2246 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2247 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
2249 resourceDetails.setDescription(updatedDescription);
2250 resource.add(1, "1024");
2251 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2253 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource,
2254 updatedRestResponse.getResponse());
2259 public void UpdateResource_TagsFormatValidation() throws Exception {
2260 char[] notValidCharsArray = getTagInValidFormatChars();
2262 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2263 assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
2264 String resourceName = resourceDetails.getName();
2266 // update tag details
2267 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2268 ArrayList<String> resourceTags = new ArrayList<String>();
2270 String updatedTagField;
2271 RestResponse updatedRestResponse;
2272 List<String> variables = Arrays.asList("Resource", "tag");
2274 for (int i = 0; i < notValidCharsArray.length; i++) {
2275 updatedTagField = "UpdatedTag" + notValidCharsArray[i];
2276 resourceTags = new ArrayList<String>();
2277 resourceTags.add(updatedTagField);
2278 resourceTags.add(resourceDetails.getName());
2280 updatedResourceDetails.setTags(resourceTags);
2282 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2283 resourceDetails.getUniqueId(), "");
2284 // validate response
2285 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2286 assertNotNull("check error code exists in response after update resource",
2287 updatedRestResponse.getErrorCode());
2288 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2289 updatedRestResponse.getResponse());
2290 assertEquals("Check response code after updating resource icon", 400,
2291 updatedRestResponse.getErrorCode().intValue());
2292 assertEquals("Check response code after updating resource icon", "Bad Request",
2293 updatedRestResponse.getResponseMessage().toString());
2300 public void UpdateResourceCategory_negativeFlow() throws Exception {
2302 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2303 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2304 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2305 String uniqueID = resourceDetails.getUniqueId();
2307 // Update resource Category Successfully
2308 ResourceReqDetails updatedResourceDetails = resourceDetails;
2310 updatedResourceDetails.removeAllCategories();
2311 updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(),
2312 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2313 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2314 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2316 // validate response
2317 List<String> resourceList = new ArrayList<String>();
2318 resourceList.add(0, "Resource");
2319 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2320 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2321 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2322 updatedRestResponse.getResponse());
2323 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2325 // Updating resource category
2326 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2327 updatedResourceDetails.addCategory("");
2328 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2329 resourceDetails.getUniqueId(), "");
2330 // validate response
2331 resourceList = new ArrayList<String>();
2332 resourceList.add(0, "Resource");
2333 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2334 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2335 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList,
2336 updatedRestResponse.getResponse());
2337 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2339 // Updating resource category
2340 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2341 updatedResourceDetails.addCategory("XXXXXX");
2342 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2343 resourceDetails.getUniqueId(), "");
2344 // validate response
2345 resourceList = new ArrayList<String>();
2346 resourceList.add(0, "Resource");
2347 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2348 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2349 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2350 updatedRestResponse.getResponse());
2351 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2354 logger.debug("Changing resource life cycle ");
2355 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2356 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2357 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2359 // Update resource Category
2360 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2361 updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2362 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2363 resourceDetails.getUniqueId(), "");
2365 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2366 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2367 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List,
2368 updatedRestResponse.getResponse());
2369 assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2372 logger.debug("Changing resource life cycle ");
2373 RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2374 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2375 assertNotNull("check response object is not null after checkout resource", checkoutResource);
2376 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2377 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2379 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2380 assertNotNull("check response object is not null after update resource", getRestResponse);
2381 parseResponseAndValidate(resourceDetails, getRestResponse);
2386 public void UpdateResourceCategorySuccessfully() throws Exception {
2388 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2389 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2390 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2392 // Update resource Category Successfully
2393 ResourceReqDetails updatedResourceDetails = resourceDetails;
2395 updatedResourceDetails.removeAllCategories();
2396 updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(),
2397 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2398 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2399 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2401 // validate response
2402 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2403 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2404 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2405 // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2406 // updatedRestResponse);
2407 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2409 // validate category updated
2410 assertTrue(updatedResourceDetails.getCategories().get(0).getName()
2411 .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2413 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
2414 resourceDetails.getUniqueId());
2415 assertNotNull("check response object is not null after update resource", getRestResponse);
2416 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2418 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2424 public void Validation_UpdateIcon() throws Exception {
2425 // Fields to update (Forbidden)
2426 String _updatedIcon = "mySecondIcon.Jpg";
2428 // administrator permissions
2429 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2431 // define and create resource
2432 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2434 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2435 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2436 String resourceName = resourceDetails.getName();
2438 // update metadata details
2439 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2440 // change icon of metadata
2441 updatedResourceDetails.setIcon(_updatedIcon);
2443 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2444 sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2446 // validate response
2447 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2448 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2449 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(),
2450 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2454 updatedResourceDetails.setIcon(_updatedIcon);
2455 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
2456 resourceDetails.getUniqueId(), "");
2457 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2458 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2459 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(),
2460 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2462 // get resource with original name. original metadata should be returned
2463 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
2464 resourceDetails.getUniqueId());
2465 // validate response
2466 assertNotNull("check response object is not null after get resource", getRestResponse);
2467 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2468 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2470 // parse updated response to javaObject
2471 Resource getResourceRespJavaObject = ResponseParser
2472 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
2473 // validate that metadata was not changed
2474 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2476 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(),
2482 public void UpdateResourceTypeSuccess() throws Exception {
2484 String newResourceType = ResourceTypeEnum.VL.toString();
2485 String currentResourceType = resourceDetails.getResourceType();
2486 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2487 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2488 Resource currentResourceJavaObject = ResponseParser
2489 .convertResourceResponseToJavaObject(restResponse.getResponse());
2491 resourceDetails.setResourceType(newResourceType);
2492 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2493 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2494 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2495 Resource updatedResourceJavaObject = ResponseParser
2496 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2497 // assertTrue("Check resource type after update resource",
2498 // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2499 assertTrue("Check resource type after update resource",
2500 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2505 public void UpdateResourceTypeAndNameSuccess() throws Exception {
2507 String newResourceType = ResourceTypeEnum.VL.toString();
2508 String currentResourceType = resourceDetails.getResourceType();
2509 String newResourceName = "new Name";
2511 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2512 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2513 Resource currentResourceJavaObject = ResponseParser
2514 .convertResourceResponseToJavaObject(restResponse.getResponse());
2516 resourceDetails.setResourceType(newResourceType);
2517 resourceDetails.setName(newResourceName);
2518 List<String> tags = resourceDetails.getTags();
2519 tags.add(newResourceName);
2520 resourceDetails.setTags(tags);
2522 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2523 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2524 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2525 Resource updatedResourceJavaObject = ResponseParser
2526 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2527 assertTrue("Check resource type after update resource",
2528 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2529 assertTrue("Check resource name after update resource",
2530 updatedResourceJavaObject.getName().equals(newResourceName));
2535 public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2537 String newResourceType = ResourceTypeEnum.VF.toString();
2538 String currentResourceType = resourceDetails.getResourceType();
2539 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2540 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2541 Resource currentResourceJavaObject = ResponseParser
2542 .convertResourceResponseToJavaObject(restResponse.getResponse());
2544 resourceDetails.setResourceType(newResourceType);
2545 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2546 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2547 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2548 LifeCycleStatesEnum.CHECKOUT);
2549 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2550 currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2552 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2553 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2554 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2555 Resource updatedResourceJavaObject = ResponseParser
2556 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2557 // assertTrue("Check resource type after update resource",
2558 // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2559 assertTrue("Check resource type after update resource",
2560 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2565 public void UpdateResourceTypeCheckInLCS() throws Exception {
2567 String resourceType = ResourceTypeEnum.VL.toString();
2568 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2569 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2570 Resource currentResourceJavaObject = ResponseParser
2571 .convertResourceResponseToJavaObject(restResponse.getResponse());
2573 resourceDetails.setResourceType(resourceType);
2574 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2575 LifeCycleStatesEnum.CHECKIN);
2576 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2578 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2579 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2581 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2583 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2584 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2585 assertEquals("Check response code after create resource", errorInfo.getCode(),
2586 updatedRestResponse.getErrorCode());
2588 List<String> variables = new ArrayList<>();
2589 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2590 updatedRestResponse.getResponse());
2595 public void UpdateResourceTypeCertifiedLCS() throws Exception {
2597 String resourceType = ResourceTypeEnum.VL.toString();
2598 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2599 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2600 Resource currentResourceJavaObject = ResponseParser
2601 .convertResourceResponseToJavaObject(restResponse.getResponse());
2603 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2604 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2606 resourceDetails.setResourceType(resourceType);
2607 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2608 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2610 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2612 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2613 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2614 assertEquals("Check response code after create resource", errorInfo.getCode(),
2615 updatedRestResponse.getErrorCode());
2617 List<String> variables = new ArrayList<>();
2618 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2619 updatedRestResponse.getResponse());
2624 public void UpdateResourceTypeInvalidType() throws Exception {
2626 String resourceType = "INVALID TYPE";
2627 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2628 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2629 Resource currentResourceJavaObject = ResponseParser
2630 .convertResourceResponseToJavaObject(restResponse.getResponse());
2632 resourceDetails.setResourceType(resourceType);
2633 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2634 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2636 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2638 assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2639 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2640 assertEquals("Check response code after update resource", errorInfo.getCode(),
2641 updatedRestResponse.getErrorCode());
2643 List<String> variables = new ArrayList<>();
2644 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
2645 updatedRestResponse.getResponse());