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.be.model.category.CategoryDefinition;
44 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
45 import org.openecomp.sdc.ci.tests.api.Urls;
46 import org.openecomp.sdc.ci.tests.config.Config;
47 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
48 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
49 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
50 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
53 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
54 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
55 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
56 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
57 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
58 import org.openecomp.sdc.ci.tests.utils.DbUtils;
59 import org.openecomp.sdc.ci.tests.utils.Utils;
60 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
61 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
63 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
64 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
65 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
66 import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
67 import org.openecomp.sdc.common.util.ValidationUtils;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
70 import org.testng.AssertJUnit;
71 import org.testng.annotations.BeforeMethod;
72 import org.testng.annotations.Test;
74 import com.google.gson.Gson;
76 public class UpdateResourceMetadataTest extends ComponentBaseTest {
77 private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
78 protected List<String> Empty_List = new ArrayList<String>();
79 protected String extendedChars;
81 protected final String contentTypeHeaderData = "application/json";
82 protected final String acceptHeaderDate = "application/json";
83 protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
85 public static TestName name = new TestName();
86 protected User sdncModifierDetails;
87 protected ResourceReqDetails resourceDetails;
89 public UpdateResourceMetadataTest() {
90 super(name, UpdateResourceMetadataTest.class.getName());
94 public String extendedCharsStringBuilder() throws Exception {
95 char[] extendedCharsArray = new char[128];
97 for (int i = 0; i < extendedCharsArray.length - 1; i++) {
98 extendedCharsArray[i] = ch;
101 extendedChars = new String(extendedCharsArray);
102 return extendedChars;
107 public void setup() throws Exception {
108 sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
109 resourceDetails = defineResourse();
115 public void UpdateDerivedFromSuccess() throws Exception {
117 String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
118 String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
120 // Getting both derived from resources for validation
122 * RestResponse resourceByNameAndVersion =
123 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
124 * oldDerivedFromName, "1.0");
125 * assertEquals("Check response code after get database normative", 200,
126 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
127 * databaseNormative =
128 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
130 * resourceByNameAndVersion =
131 * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
132 * newDerivedFromName, "1.0");
133 * assertEquals("Check response code after get database normative", 200,
134 * resourceByNameAndVersion.getErrorCode().intValue()); Resource
136 * resourceUtils.parseResourceResp(resourceByNameAndVersion);
139 // Derived from set to Database
140 List<String> derivedFrom = new ArrayList<>();
141 derivedFrom.add(oldDerivedFromName);
142 resourceDetails.setDerivedFrom(derivedFrom);
144 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
145 AssertJUnit.assertEquals("Check response code after create resource", 201,
146 restResponse.getErrorCode().intValue());
147 Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
150 derivedFrom.add(newDerivedFromName);
151 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
152 sdncModifierDetails, currentResource.getUniqueId(), "");
153 AssertJUnit.assertEquals("Check response code after create resource", 200,
154 updatedRestResponse.getErrorCode().intValue());
158 protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
159 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
161 updatedResourceDetails.setVersion("mumu");
162 updatedResourceDetails.setIsAbstract(true);
163 updatedResourceDetails.setIsHighestVersion(true);
164 updatedResourceDetails.setCreatorUserId("df4444");
165 updatedResourceDetails.setCreatorFullName("John Doe");
166 updatedResourceDetails.setLastUpdaterUserId("gf5646");
167 updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
168 updatedResourceDetails.setCreationDate(new Long(4444));
169 updatedResourceDetails.setLastUpdateDate(new Long("534535"));
170 updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
171 updatedResourceDetails.setCost("6.1");
172 updatedResourceDetails.setLicenseType("Installation");
173 updatedResourceDetails.setUUID("dfsfsdf");
174 return updatedResourceDetails;
177 public void UpdateResourceNotFoundTest() throws Exception {
179 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
181 String resourceName = "cisco4";
183 String description = "updatedDescription";
184 ArrayList<String> resourceTags = new ArrayList<String>();
185 resourceTags.add("tag2");
186 String category = ServiceCategoriesEnum.MOBILITY.getValue();
187 ArrayList<String> derivedFrom = new ArrayList<String>();
188 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
189 String vendorName = "newOracle";
190 String vendorRelease = "2.5";
191 String contactId = "jh0003";
192 String icon = "myICON";
194 ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags,
195 category, derivedFrom, vendorName, vendorRelease, contactId, icon);
196 updatedResourceDetails.setUniqueId("dummyId");
197 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
198 sdncModifierDetails, "0.1");
201 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
202 AssertJUnit.assertNotNull("check error code exists in response after update resource",
203 updatedRestResponse.getErrorCode());
204 AssertJUnit.assertEquals("Check response code after update resource", 404,
205 updatedRestResponse.getErrorCode().intValue());
206 // String resourceId =
207 // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
208 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
209 updatedRestResponse.getResponse());
212 // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
214 updatedResourceDetails = defineUpdatedResourse(resourceName);
215 updatedResourceDetails.setUniqueId("dummyId");
216 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
218 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
219 AssertJUnit.assertNotNull("check error code exists in response after update resource",
220 updatedRestResponse.getErrorCode());
221 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
222 updatedRestResponse.getResponse());
226 public char[] getInValidChars() throws Exception {
228 char[] extendedCharsArray = new char[59];
230 for (int i = 0; i < 44; i++) {
231 extendedCharsArray[i] = ch;
235 for (int i = 44; i < 51; i++) {
236 extendedCharsArray[i] = ch;
240 for (int i = 51; i < 55; i++) {
241 extendedCharsArray[i] = ch;
245 for (int i = 55; i < 59; i++) {
246 extendedCharsArray[i] = ch;
249 return extendedCharsArray;
252 public char[] getTagInValidFormatChars() throws Exception {
253 // Tag format is the same as defined for "Resource Name" :
254 // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
255 // ('_'), dash ('-'), dot ('.')
256 char[] notValidCharsArray = new char[30];
258 for (int i = 0; i < 12; i++) {
259 notValidCharsArray[i] = ch;
262 notValidCharsArray[13] = 47;
264 for (int i = 14; i < 21; i++) {
265 notValidCharsArray[i] = ch;
269 for (int i = 21; i < 24; i++) {
270 notValidCharsArray[i] = ch;
273 notValidCharsArray[24] = 96;
275 for (int i = 25; i < 30; i++) {
276 notValidCharsArray[i] = ch;
279 return notValidCharsArray;
282 public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
284 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
286 // define and create resource
287 ResourceReqDetails resourceDetails = defineResourse();
288 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
289 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
290 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
292 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
293 String resourceId = resourceDetails.getUniqueId();
294 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
297 JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
299 List<String> resource = new ArrayList<>();
300 resource.add("Resource");
302 // remove Description
303 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description",
304 ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
306 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags",
307 ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
309 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category",
310 ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
312 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName",
313 ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
314 // remove VendorRelease
315 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease",
316 ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
317 // remove AT&T Contact
318 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId",
319 ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
321 // get resource with original name. original metadata should be returned
322 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
324 AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
325 AssertJUnit.assertNotNull("check error code exists in response after get resource",
326 getRestResponse.getErrorCode());
327 AssertJUnit.assertEquals("Check response code after update resource", 200,
328 getRestResponse.getErrorCode().intValue());
330 // parse updated response to javaObject
331 Resource getResourceRespJavaObject = ResponseParser
332 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
333 // validate that metadata was not changed
334 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
336 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
337 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
338 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
341 // End of validation tests
342 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
344 protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
345 String description = "updatedDescription";
346 ArrayList<String> resourceTags = new ArrayList<String>();
347 // Duplicate tags are allowed and should be de-duplicated by server side
348 resourceTags.add(resourceName);
349 resourceTags.add("tag1");
350 resourceTags.add("tag1");
351 resourceTags.add("tag2");
352 resourceTags.add("tag2");
353 String category = ServiceCategoriesEnum.VOIP.getValue();
354 ArrayList<String> derivedFrom = new ArrayList<String>();
355 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
356 String vendorName = "updatedOracle";
357 String vendorRelease = "3.5";
358 String contactId = "jh0001";
359 String icon = "myUpdatedICON";
361 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
362 derivedFrom, vendorName, vendorRelease, contactId, icon);
363 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
364 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
366 return resourceDetails;
369 protected ResourceReqDetails defineResourse() {
370 String resourceName = "cisco4";
371 String description = "description";
372 ArrayList<String> resourceTags = new ArrayList<String>();
373 resourceTags.add(resourceName);
374 ArrayList<String> derivedFrom = new ArrayList<String>();
375 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
376 String vendorName = "Oracle";
377 String vendorRelease = "1.5";
378 String contactId = "jh0003";
379 String icon = "objectStorage";
381 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null,
382 derivedFrom, vendorName, vendorRelease, contactId, icon);
383 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
384 ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
386 return resourceDetails;
389 protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails)
392 DbUtils.cleanAllAudits();
395 RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
398 AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
399 AssertJUnit.assertNotNull("check error code exists in response after create resource",
400 restResponse.getErrorCode());
401 AssertJUnit.assertEquals("Check response code after create resource", 201,
402 restResponse.getErrorCode().intValue());
407 protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails,
408 String uri) throws Exception {
411 RestResponse ResourceResponse;
413 config = Utils.getConfig();
414 Map<String, String> headersMap = new HashMap<String, String>();
415 headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
416 headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
417 headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
418 HttpRequest http = new HttpRequest();
419 String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(),
420 config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
423 ResourceResponse = http.httpSendGet(url, headersMap);
424 } else if (uri == "POST") {
425 Gson gson = new Gson();
426 String userBodyJson = gson.toJson(updatedResourceDetails);
427 ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
428 } else if (uri == "DELETE") {
429 ResourceResponse = http.httpSendDelete(url, headersMap);
433 return ResourceResponse;
434 } catch (FileNotFoundException e) {
435 // TODO Auto-generated catch block
443 protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
444 // json object: resourceName and icon are must
445 JSONObject jObject = new JSONObject();
447 List<String> tagsList = Arrays.asList(resourceDetails.getName());
448 List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
450 jObject.put("name", resourceDetails.getName());
451 jObject.put("description", "updatedDescription");
452 jObject.put("tags", tagsList);
453 jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
454 jObject.put("derivedFrom", derivedFromList);
455 jObject.put("vendorName", "newOracle");
456 jObject.put("vendorRelease", "1.5");
457 jObject.put("contactId", "jh0003");
458 jObject.put("icon", resourceDetails.getIcon());
463 protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
464 jObject.remove(removedPropery);
469 // purpose: function for controlling json body fields and validating
471 protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject,
472 String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
474 JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
475 // remove description from jsonObject
476 jObject = RemoveFromJsonObject(jObject, removedField);
477 // update with incomplete body.
478 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(),
479 sdncModifierDetails, resourceId);
481 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
482 AssertJUnit.assertNotNull("check error code exists in response after update resource",
483 updatedRestResponse.getErrorCode());
484 ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
488 // purpose: function for validating error response
489 protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails,
490 String recievedMessage, List<String> variables) throws Exception {
491 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
492 sdncModifierDetails, "0.1");
494 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
495 AssertJUnit.assertNotNull("check error code exists in response after update resource",
496 updatedRestResponse.getErrorCode());
497 ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
501 protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse)
503 // parse response to javaObject
504 Resource updatedResourceRespJavaObject = ResponseParser
505 .convertResourceResponseToJavaObject(restResponse.getResponse());
506 AssertJUnit.assertTrue(
507 !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
508 AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
509 AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
510 AssertJUnit.assertTrue(
511 !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
512 AssertJUnit.assertTrue(
513 !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
514 AssertJUnit.assertTrue(
515 !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
517 .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
518 AssertJUnit.assertTrue(
519 !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
520 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName()
521 .equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
522 AssertJUnit.assertTrue(
523 !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
524 AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
526 .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
527 AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
531 protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse)
533 // parse response to javaObject
534 Resource updatedResourceRespJavaObject = ResponseParser
535 .convertResourceResponseToJavaObject(restResponse.getResponse());
536 // validate request vs response
537 ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
540 public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails,
541 String resourceVersion) {
543 ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
545 expectedResourceAuditJavaObject.setAction("Checkout");
546 expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
547 expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
548 expectedResourceAuditJavaObject.setStatus("200.0");
549 expectedResourceAuditJavaObject.setDesc("OK");
550 expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
551 expectedResourceAuditJavaObject.setResourceType("Resource");
552 expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
553 expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
554 expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
555 expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
557 return expectedResourceAuditJavaObject;
561 public enum FieldToValidate {
562 contactId, Tags, VendorName, VendorRelease, Description
566 public void UpdateBy_postTest() throws Exception {
568 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
569 String resourceName = resourceDetails.getName();
571 // update resource - without changing resourceName
572 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
574 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
577 assertNotNull("check response object is not null after update resource", updatedRestResponse);
578 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
579 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
580 updatedRestResponse.getResponse());
582 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
583 resourceDetails.getUniqueId());
584 assertNotNull("check response object is not null after update resource", getRestResponse);
585 parseResponseAndValidate(resourceDetails, getRestResponse);
590 public void UpdateBy_getTest() throws Exception {
592 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
593 String resourceName = resourceDetails.getName();
595 // update resource - without changing resourceName
596 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
597 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
600 assertNotNull("check response object is not null after update resource", updatedRestResponse);
601 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
602 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
603 updatedRestResponse.getResponse());
605 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
606 resourceDetails.getUniqueId());
607 assertNotNull("check response object is not null after update resource", getRestResponse);
608 parseResponseAndValidate(resourceDetails, getRestResponse);
613 public void UpdateBy_deleteTest() throws Exception {
615 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
616 String resourceName = resourceDetails.getName();
618 // update resource - without changing resourceName
619 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
620 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails,
624 assertNotNull("check response object is not null after update resource", updatedRestResponse);
625 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
626 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
627 updatedRestResponse.getResponse());
629 RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails,
630 resourceDetails.getUniqueId(), "");
631 assertNotNull("check response object is not null after update resource", getRestResponse);
632 parseResponseAndValidate(resourceDetails, getRestResponse);
639 public void UpdateWithInvaldJsonBodyTest() throws Exception {
641 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
642 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
643 String resourceId = resourceDetails.getUniqueId();
645 // update Descirption value
646 String description = "updatedDescription";
648 // send update with incompleted json, only description string
649 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails,
653 assertNotNull("check response object is not null after update resource", updatedRestResponse);
654 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
655 assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
657 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
658 resourceDetails.getUniqueId());
659 assertNotNull("check response object is not null after update resource", getRestResponse);
660 parseResponseAndValidate(resourceDetails, getRestResponse);
665 // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
668 // RestResponse restResponse = createResource(sdncModifierDetails,
670 // String resourceName = resourceDetails.getName();
672 // // new user parameters
673 // String userFirstName = "Kot";
674 // String userLastName = "Matroskin";
675 // String role = "ADMIN";
676 // User sdncUserDetails = new User(userFirstName, userLastName,
677 // httpCspUserId, email, role,null);
678 // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
679 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
681 // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
682 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
684 // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
685 // httpCspUserId, email,role,null);
686 // ResourceReqDetails updatedResourceDetails =
687 // defineUpdatedResourse(resourceName);
688 // RestResponse updatedRestResponse =
689 // ResourceRestUtils.updateResource(updatedResourceDetails,
690 // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
692 // // validate response
693 // assertNotNull("check response object is not null after update resource",
694 // updatedRestResponse);
695 // assertNotNull("check error code exists in response after update
696 // resource", updatedRestResponse.getErrorCode());
697 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
698 // Empty_List, updatedRestResponse.getResponse());
700 // RestResponse getRestResponse =
701 // ResourceRestUtils.getResource(sdncModifierDetails,
702 // resourceDetails.getUniqueId());
703 // assertNotNull("check response object is not null after update resource",
705 // parseResponseAndValidate(resourceDetails, getRestResponse);
711 public void UpdateResourceNameSensitiveTest() throws Exception {
712 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
713 String resourceBaseVersion = "0.1";
714 String resourceName = "Ab";
715 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
717 RestResponse response = null;
718 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
719 updatedResourceDetails.getName(), "0.1");
720 BaseRestUtils.checkDeleteResponse(response);
721 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
722 updatedResourceDetails.getName(), "0.2");
723 BaseRestUtils.checkDeleteResponse(response);
725 RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
726 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
729 logger.debug("Changing resource life cycle ");
730 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails,
731 sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
732 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
734 // String resourceCertifyVersion = "0.1";
735 logger.debug("Changing resource life cycle ");
736 checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails,
737 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
738 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
740 updatedResourceDetails.setName("ABC_-bt.aT");
741 ArrayList<String> resourceTag = new ArrayList<String>();
742 resourceTag.add(0, "ABC_-bt.aT");
743 updatedResourceDetails.setTags(resourceTag);
744 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
745 sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
746 assertNotNull("check response object is not null after update resource", updatedRestResponse);
747 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
748 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
749 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
752 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
753 updatedResourceDetails.getName(), "0.1");
754 BaseRestUtils.checkDeleteResponse(response);
755 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
756 updatedResourceDetails.getName(), "0.2");
757 BaseRestUtils.checkDeleteResponse(response);
762 public void UpdateIcon_InegativeFlow() throws Exception {
764 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
765 String resourceName = resourceDetails.getName();
767 List<String> resourceList = new ArrayList<String>();
768 resourceList.add(0, "Resource");
769 // check InValid Characters
770 char[] notValidCharsArray = new char[59];
771 notValidCharsArray = getInValidChars();
772 // update metadata details
773 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
774 RestResponse updatedRestResponse;
776 for (int i = 0; i < notValidCharsArray.length; i++) {
777 // change icon of metadata
778 updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
780 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
781 resourceDetails.getUniqueId(), "");
783 assertNotNull("check response object is not null after update resource", updatedRestResponse);
784 assertNotNull("check error code exists in response after update resource",
785 updatedRestResponse.getErrorCode());
786 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList,
787 updatedRestResponse.getResponse());
788 assertEquals("Check response code after updating resource icon", 400,
789 updatedRestResponse.getErrorCode().intValue());
790 assertEquals("Check response code after updating resource icon", "Bad Request",
791 updatedRestResponse.getResponseMessage().toString());
796 String updateIcon = "";
797 updatedResourceDetails.setIcon(updateIcon);
798 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
799 resourceDetails.getUniqueId(), "");
800 assertNotNull("check response object is not null after update resource", updatedRestResponse);
801 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
802 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList,
803 updatedRestResponse.getResponse());
805 // Icon length more then 25 characters
806 resourceList.add(1, "25");
807 updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
808 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
809 resourceDetails.getUniqueId(), "");
811 assertNotNull("check response object is not null after update resource", updatedRestResponse);
812 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
813 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList,
814 updatedRestResponse.getResponse());
815 assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
816 assertEquals("Check response code after updating resource icon", "Bad Request",
817 updatedRestResponse.getResponseMessage().toString());
819 // get resource with original name. original metadata should be returned
820 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
821 resourceDetails.getUniqueId());
823 assertNotNull("check response object is not null after get resource", getRestResponse);
824 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
825 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
827 // parse updated response to javaObject
828 Resource getResourceRespJavaObject = ResponseParser
829 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
830 // validate that metadata was not changed
831 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
836 public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
838 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
839 String resourceBaseVersion = "0.1";
842 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
843 String resourceName = resourceDetails.getName();
845 ResourceReqDetails updatedResourceDetails = defineResourse();
846 updatedResourceDetails.setName("updatedResourceName");
847 List<String> tags = updatedResourceDetails.getTags();
849 for (Iterator<String> iter = tags.listIterator(); iter.hasNext();) {
850 String a = iter.next();
851 if (a.equals("updatedResourceName")) {
856 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
857 sdncModifierDetails, resourceDetails.getUniqueId(), "");
859 List<String> resourceList = new ArrayList<String>();
860 assertNotNull("check response object is not null after update resource", updatedRestResponse);
861 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
862 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
863 resourceList, updatedRestResponse.getResponse());
864 assertEquals("Check response code after updating resource icon", 400,
865 updatedRestResponse.getErrorCode().intValue());
867 // get resource with original name. original metadata should be returned
868 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
869 resourceDetails.getUniqueId());
871 assertNotNull("check response object is not null after get resource", getRestResponse);
872 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
873 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
874 // parse updated response to javaObject
875 Resource getResourceRespJavaObject = ResponseParser
876 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
877 // validate that metadata was not changed
878 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
883 public void UpdateResourceName_negativeFlow() throws Exception {
884 // The validation are done in Tag's validation
885 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
887 RestResponse updatedRestResponse;
888 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
889 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
890 String uniqueId = resourceDetails.getUniqueId();
891 String resourceName = resourceDetails.getName();
892 // check InValid Characters
893 char[] notValidCharsArray = new char[59];
894 notValidCharsArray = getInValidChars();
895 ArrayList<String> resource_Name = new ArrayList<String>();
896 List<String> resourceList = new ArrayList<String>();
898 ArrayList<String> resourceTags = new ArrayList<String>();
899 resourceList.add(0, "Resource");
901 // update metadata details
902 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
903 for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
904 if (i != 1 && i != 46
906 * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
907 */ i != 31) // space ("") and dot(.)
909 // change resourceName parameter
910 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
911 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
912 updatedResourceDetails.setTags(resource_Name);
913 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
914 sdncAdminModifierDetails, uniqueId, "");
916 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
917 // Empty_List, updatedRestResponse.getResponse());
918 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList,
919 updatedRestResponse.getResponse());
924 // resourceName length more then 50 characters
925 // Duplicate tags are allowed and should be de-duplicated by server side
926 resource_Name.add(resourceName);
927 resource_Name.add("tag1");
928 resource_Name.add("tag1");
929 resource_Name.add("tag2");
930 resource_Name.add("tag2");
932 resourceList.add(1, "1024");
933 // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
934 updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
935 // resource_Name.add("123456789012345678901234567890123456789012345678901");
936 updatedResourceDetails.setTags(resource_Name);
937 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
940 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList,
941 updatedRestResponse.getResponse());
943 // get resource with original name. original metadata should be returned
944 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
945 resourceDetails.getUniqueId());
947 assertNotNull("check response object is not null after get resource", getRestResponse);
948 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
949 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
950 // parse updated response to javaObject
951 Resource getResourceRespJavaObject = ResponseParser
952 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
953 // validate that metadata was not changed
954 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
957 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails,
958 updatedResourceDetails.getName(), "0.1");
959 BaseRestUtils.checkDeleteResponse(response);
963 public void UpdateResourceInformation_NotCheckedOut() throws Exception {
965 String resourceBaseVersion = "0.1";
966 List<String> resourceList = new ArrayList<String>();
968 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
969 String resourceName = resourceDetails.getName();
972 logger.debug("Changing resource life cycle ");
973 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
974 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
975 assertNotNull("check response object is not null after checkout resource", checkoutResource);
976 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
977 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
979 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
981 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
982 sdncModifierDetails, resourceDetails.getUniqueId(), "");
983 assertNotNull("check response object is not null after update resource", updatedRestResponse);
984 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
985 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
986 updatedRestResponse.getResponse());
987 assertEquals("Check response code after updating resource icon", 409,
988 updatedRestResponse.getErrorCode().intValue());
990 // get resource with original name. original metadata should be returned
991 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
992 resourceDetails.getUniqueId());
994 assertNotNull("check response object is not null after get resource", getRestResponse);
995 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
996 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
998 // parse updated response to javaObject
999 Resource getResourceRespJavaObject = ResponseParser
1000 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1001 // validate that metadata was not changed
1002 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1007 public void UpdateResourceInformation_resourceVersion_11() throws Exception {
1009 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1010 String resourceBaseVersion = "0.1";
1013 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1014 String resourceName = resourceDetails.getName();
1016 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1020 logger.debug("Changing resource life cycle ");
1021 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1022 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1023 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1025 logger.debug("Changing resource life cycle ");
1026 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1027 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1028 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1030 logger.debug("Changing resource life cycle ");
1031 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1032 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1033 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1035 logger.debug("Changing resource life cycle ");
1036 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1037 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1038 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1040 String resourceCertifyVersion = "1.0";
1041 logger.debug("Changing resource life cycle ");
1042 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1043 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
1044 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1046 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1048 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1049 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1050 // validate response
1051 List<String> resourceList = new ArrayList<String>();
1052 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1053 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1054 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
1055 updatedRestResponse.getResponse());
1056 // assertEquals("Check response code after updating resource icon", 409,
1057 // updatedRestResponse.getErrorCode().intValue());
1059 // get resource with original name. original metadata should be returned
1060 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1061 resourceDetails.getUniqueId());
1062 // validate response
1063 assertNotNull("check response object is not null after get resource", getRestResponse);
1065 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1067 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1068 // parse updated response to javaObject
1069 Resource getResourceRespJavaObject = ResponseParser
1070 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1071 // validate that metadata was not changed
1072 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1077 public void UpdateResourceInformation_resourceVersion_02() throws Exception {
1079 String resourceBaseVersion = "0.1";
1082 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1083 String resourceName = resourceDetails.getName();
1085 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1089 logger.debug("Changing resource life cycle ");
1090 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1091 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1092 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1094 // String resourceCertifyVersion = "0.1";
1095 logger.debug("Changing resource life cycle ");
1096 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1097 resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
1098 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1100 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1102 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1103 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1104 // validate response
1105 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1106 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1107 assertEquals("Check response code after updating resource icon", 200,
1108 updatedRestResponse.getErrorCode().intValue());
1110 // get resource with original name. original metadata should be returned
1111 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1112 resourceDetails.getUniqueId());
1113 // validate response
1114 assertNotNull("check response object is not null after get resource", getRestResponse);
1115 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1116 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1118 // parse updated response to javaObject
1119 Resource getResourceRespJavaObject = ResponseParser
1120 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1121 // validate that metadata was not changed
1122 ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
1125 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1126 updatedResourceDetails.getName(), "0.1");
1127 BaseRestUtils.checkDeleteResponse(response);
1128 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
1129 updatedResourceDetails.getName(), "0.2");
1130 BaseRestUtils.checkDeleteResponse(response);
1135 public void UpdateResourceIcon_resourceVersion_11() throws Exception {
1136 // Can be changed only if major version is "0".
1138 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1139 String resourceBaseVersion = "0.1";
1142 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1143 String resourceName = resourceDetails.getName();
1145 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1149 logger.debug("Changing resource life cycle ");
1150 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1151 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1152 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1154 logger.debug("Changing resource life cycle ");
1155 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1156 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1157 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1159 logger.debug("Changing resource life cycle ");
1160 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1161 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1162 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1164 logger.debug("Changing resource life cycle ");
1165 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1166 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1167 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1169 String resourceCertifyVersion = "1.0";
1170 logger.debug("Changing resource life cycle ");
1171 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1172 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1173 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1175 // ResourceReqDetails updatedResourceDetails =
1176 // defineUpdatedResourse(resourceName);
1177 ResourceReqDetails updatedResourceDetails = defineResourse();
1178 // updatedResourceDetails.setVendorName("updatedVandorName");
1179 updatedResourceDetails.setIcon("updatedIcon");
1181 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1182 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1183 // validate response
1184 List<String> resourceList = new ArrayList<String>();
1185 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList,
1186 updatedRestResponse.getResponse());
1188 // get resource with original name. original metadata should be returned
1189 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1190 resourceDetails.getUniqueId());
1191 // validate response
1192 assertNotNull("check response object is not null after get resource", getRestResponse);
1193 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1194 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1195 // parse updated response to javaObject
1196 Resource getResourceRespJavaObject = ResponseParser
1197 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1198 // validate that metadata was not changed
1199 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1204 public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1205 // Can be changed only if the major resource version is "0".
1206 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1207 String resourceBaseVersion = "0.1";
1210 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1211 String resourceName = resourceDetails.getName();
1213 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1217 logger.debug("Changing resource life cycle ");
1218 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1219 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1220 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1222 logger.debug("Changing resource life cycle ");
1223 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1224 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1225 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1227 logger.debug("Changing resource life cycle ");
1228 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1229 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1230 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1232 logger.debug("Changing resource life cycle ");
1233 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1234 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1235 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1237 String resourceCertifyVersion = "1.0";
1238 logger.debug("Changing resource life cycle ");
1239 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1240 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1241 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1243 // ResourceReqDetails updatedResourceDetails =
1244 // defineUpdatedResourse(resourceName);
1245 ResourceReqDetails updatedResourceDetails = defineResourse();
1247 updatedResourceDetails.setVendorName("updatedVandorName");
1249 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1250 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1251 // validate response
1252 List<String> resourceList = new ArrayList<String>();
1253 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1254 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1255 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(),
1256 resourceList, updatedRestResponse.getResponse());
1257 assertEquals("Check response code after updating resource icon", 400,
1258 updatedRestResponse.getErrorCode().intValue());
1260 // get resource with original name. original metadata should be returned
1261 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1262 resourceDetails.getUniqueId());
1263 // validate response
1264 assertNotNull("check response object is not null after get resource", getRestResponse);
1265 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1266 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1267 // parse updated response to javaObject
1268 Resource getResourceRespJavaObject = ResponseParser
1269 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1270 // validate that metadata was not changed
1271 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1276 public void UpdateResourceName_resourceVersion_11() throws Exception {
1277 // Can be changed only if the major resource version is "0".
1278 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1279 String resourceBaseVersion = "0.1";
1282 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1283 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1284 String resourceName = resourceDetails.getName();
1286 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1290 logger.debug("Changing resource life cycle ");
1291 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1292 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1293 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1295 logger.debug("Changing resource life cycle ");
1296 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1297 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1298 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1300 logger.debug("Changing resource life cycle ");
1301 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1302 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1303 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1305 logger.debug("Changing resource life cycle ");
1306 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1307 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1308 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1310 String resourceCertifyVersion = "1.0";
1311 logger.debug("Changing resource life cycle ");
1312 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1313 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1314 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1317 * //ResourceReqDetails updatedResourceDetails =
1318 * defineUpdatedResourse(resourceName); ResourceReqDetails
1319 * updatedResourceDetails = defineResourse();
1321 * updatedResourceDetails.setResourceName("updatedResourceName");
1322 * updatedResourceDetails.setIcon("updatedResourceName");
1324 resourceDetails.setName("updatedResourceName");
1325 List<String> tagList = new ArrayList<String>();
1326 tagList.add(0, "updatedResourceName");
1327 resourceDetails.setTags(tagList);
1329 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1330 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1331 // validate response
1332 List<String> resourceList = new ArrayList<String>();
1333 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1334 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1335 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList,
1336 updatedRestResponse.getResponse());
1341 public void UpdateResourceTag_resourceVersion_11() throws Exception {
1342 // Tag Can be updated when major version is "0".
1343 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1344 String resourceBaseVersion = "0.1";
1347 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1348 String resourceName = resourceDetails.getName();
1350 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1354 logger.debug("Changing resource life cycle ");
1355 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1356 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1357 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1359 logger.debug("Changing resource life cycle ");
1360 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1361 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1362 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1364 logger.debug("Changing resource life cycle ");
1365 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1366 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1367 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1369 logger.debug("Changing resource life cycle ");
1370 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1371 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1372 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1374 String resourceCertifyVersion = "1.0";
1375 logger.debug("Changing resource life cycle ");
1376 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1377 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1378 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1380 // ResourceReqDetails updatedResourceDetails =
1381 // defineUpdatedResourse(resourceName);
1382 ResourceReqDetails updatedResourceDetails = defineResourse();
1383 // updatedResourceDetails.setVendorName("updatedVandorName");
1385 ArrayList<String> resourceTags = new ArrayList<String>();
1386 resourceTags.add("NewTag");
1387 resourceTags.add(resourceDetails.getName());
1389 updatedResourceDetails.setTags(resourceTags);
1391 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1392 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1393 // validate response
1394 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1395 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1396 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1398 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1399 resourceDetails.getUniqueId());
1400 assertNotNull("check response object is not null after update resource", getRestResponse);
1401 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1406 public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1408 // Tag, contactId, vendorRelease,tags And description - Can be also
1409 // updated when major version is NOT "0".
1410 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1411 String resourceBaseVersion = "0.1";
1414 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1416 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1420 logger.debug("Changing resource life cycle ");
1421 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1422 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1423 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1425 logger.debug("Changing resource life cycle ");
1426 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1427 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1428 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1430 logger.debug("Changing resource life cycle ");
1431 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1432 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1433 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1435 logger.debug("Changing resource life cycle ");
1436 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1437 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1438 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1440 String resourceCertifyVersion = "1.0";
1441 logger.debug("Changing resource life cycle ");
1442 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1443 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1444 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1446 // ResourceReqDetails updatedResourceDetails =
1447 // defineUpdatedResourse(resourceName);
1448 ResourceReqDetails updatedResourceDetails = defineResourse();
1449 // updatedResourceDetails.setVendorName("updatedVandorName");
1451 // updated allowed parameters when major resource version is NOT "0"
1452 ArrayList<String> resourceTags = new ArrayList<String>();
1453 resourceTags.add("NewTag");
1454 resourceTags.add(resourceDetails.getName());
1455 updatedResourceDetails.setTags(resourceTags);
1456 updatedResourceDetails.setDescription("UpdatedDescription");
1457 updatedResourceDetails.setVendorRelease("5.1");
1458 updatedResourceDetails.setContactId("bt750h");
1460 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1461 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1462 // validate response
1463 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1464 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1465 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1467 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1468 resourceDetails.getUniqueId());
1469 assertNotNull("check response object is not null after update resource", getRestResponse);
1470 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1475 public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1476 // DerivedFrom parameter - Can be updated when major version is "0".
1477 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1478 String resourceBaseVersion = "0.1";
1481 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1482 String resourceName = resourceDetails.getName();
1484 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1488 logger.debug("Changing resource life cycle ");
1489 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1490 resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1491 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1493 logger.debug("Changing resource life cycle ");
1494 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1495 resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1496 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1498 logger.debug("Changing resource life cycle ");
1499 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1500 resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1501 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1503 logger.debug("Changing resource life cycle ");
1504 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
1505 resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1506 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1508 String resourceCertifyVersion = "1.0";
1509 logger.debug("Changing resource life cycle ");
1510 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
1511 resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1512 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1514 // ResourceReqDetails updatedResourceDetails =
1515 // defineUpdatedResourse(resourceName);
1516 ResourceReqDetails updatedResourceDetails = defineResourse();
1517 ArrayList<String> drivenFrom = new ArrayList<String>();
1518 drivenFrom.add(0, "tosca.nodes.Container.Application");
1519 updatedResourceDetails.setDerivedFrom(drivenFrom);
1521 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
1522 sdncModifierDetails, resourceDetails.getUniqueId(), "");
1523 // validate response
1524 List<String> resourceList = new ArrayList<String>();
1525 ResourceRestUtils.checkSuccess(updatedRestResponse);
1527 // get resource with original name. original metadata should be returned
1528 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
1529 resourceDetails.getUniqueId());
1530 // validate response
1531 assertNotNull("check response object is not null after get resource", getRestResponse);
1532 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1533 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1534 // parse updated response to javaObject
1535 Resource getResourceRespJavaObject = ResponseParser
1536 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
1537 // validate that metadata was not changed
1538 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1543 public void UpdateResource_vendorNameValidation() throws Exception {
1545 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1546 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1547 String updatedVendorName = "";
1548 String uniqueId = resourceDetails.getUniqueId();
1549 resourceDetails.setVendorName(updatedVendorName);
1550 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
1551 sdncModifierDetails, uniqueId, "");
1552 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1553 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1554 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1555 updatedRestResponse.getResponse());
1557 // update resource vendorName metadata: 1 characters
1558 updatedVendorName = " ";
1560 resourceDetails.setVendorName(updatedVendorName);
1561 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1563 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1564 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1565 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1566 updatedRestResponse.getResponse());
1568 // update resource vendorName metadata: 25 characters
1569 updatedVendorName = "Verification and validati";
1571 resourceDetails.setVendorName(updatedVendorName);
1572 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1574 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1575 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1576 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1577 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1579 // update resource vendorName metadata: 26 characters
1580 updatedVendorName = "Verification and validatii";
1582 List<String> myList = new ArrayList<String>();
1583 myList.add(0, "25");
1584 resourceDetails.setVendorName(updatedVendorName);
1585 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1587 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1588 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList,
1589 updatedRestResponse.getResponse());
1591 // update resource VendorRelease metadata: forbidden characters
1592 updatedVendorName = "A1<";
1594 resourceDetails.setVendorName(updatedVendorName);
1595 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1597 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1598 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1599 updatedRestResponse.getResponse());
1601 updatedVendorName = "A1>";
1603 resourceDetails.setVendorName(updatedVendorName);
1604 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1606 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1607 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1608 updatedRestResponse.getResponse());
1610 updatedVendorName = "A1:";
1612 resourceDetails.setVendorName(updatedVendorName);
1613 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1615 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1616 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1617 updatedRestResponse.getResponse());
1619 updatedVendorName = "A1\"";
1621 resourceDetails.setVendorName(updatedVendorName);
1622 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1624 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1625 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1626 updatedRestResponse.getResponse());
1628 updatedVendorName = "A1/";
1630 resourceDetails.setVendorName(updatedVendorName);
1631 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1633 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1634 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1635 updatedRestResponse.getResponse());
1637 updatedVendorName = "A1\\";
1639 resourceDetails.setVendorName(updatedVendorName);
1640 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1642 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1643 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1644 updatedRestResponse.getResponse());
1646 updatedVendorName = "A1|";
1648 resourceDetails.setVendorName(updatedVendorName);
1649 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1651 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1652 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1653 updatedRestResponse.getResponse());
1655 updatedVendorName = "A1?";
1657 resourceDetails.setVendorName(updatedVendorName);
1658 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1660 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1661 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1662 updatedRestResponse.getResponse());
1664 updatedVendorName = "A1*";
1666 resourceDetails.setVendorName(updatedVendorName);
1667 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1669 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1670 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
1671 updatedRestResponse.getResponse());
1673 // update resource vendorName metadata: null
1674 updatedVendorName = null;
1676 resourceDetails.setVendorName(updatedVendorName);
1677 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1679 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1680 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
1681 updatedRestResponse.getResponse());
1686 public void UpdateResource_vendorReleaseValidation() throws Exception {
1688 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1689 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1690 RestResponse updatedRestResponse;
1691 String uniqueId = resourceDetails.getUniqueId();
1692 String updatedVendorRelease;
1693 // set VendorRelease
1695 // update resource VendorRelease metadata: 1 characters
1696 updatedVendorRelease = "1";
1697 // set VendorRelease
1698 resourceDetails.setVendorRelease(updatedVendorRelease);
1699 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1701 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1702 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1703 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1704 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1706 // update resource VendorRelease metadata: 25 characters
1707 updatedVendorRelease = "(!#1.00000000000000000000";
1708 // set VendorRelease
1709 resourceDetails.setVendorRelease(updatedVendorRelease);
1710 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1712 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1713 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1714 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1715 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1717 // update resource VendorRelease metadata: 26 characters
1718 updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1719 resourceDetails.setVendorRelease(updatedVendorRelease);
1720 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1722 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1723 Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1725 // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1726 // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1727 // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1729 // update resource VendorRelease metadata: forbidden characters
1730 updatedVendorRelease = "A1<";
1731 // set VendorRelease
1732 resourceDetails.setVendorRelease(updatedVendorRelease);
1733 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1735 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1736 updatedRestResponse.getResponse());
1738 updatedVendorRelease = "A1>";
1739 // set VendorRelease
1740 resourceDetails.setVendorRelease(updatedVendorRelease);
1741 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1743 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1744 updatedRestResponse.getResponse());
1746 updatedVendorRelease = "A1:";
1747 // set VendorRelease
1748 resourceDetails.setVendorRelease(updatedVendorRelease);
1749 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1751 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1752 updatedRestResponse.getResponse());
1754 updatedVendorRelease = "A1\"";
1755 // set VendorRelease
1756 resourceDetails.setVendorRelease(updatedVendorRelease);
1757 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1759 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1760 updatedRestResponse.getResponse());
1762 updatedVendorRelease = "A1/";
1763 // set VendorRelease
1764 resourceDetails.setVendorRelease(updatedVendorRelease);
1765 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1767 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1768 updatedRestResponse.getResponse());
1770 updatedVendorRelease = "A1\\";
1771 // set VendorRelease
1772 resourceDetails.setVendorRelease(updatedVendorRelease);
1773 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1775 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1776 updatedRestResponse.getResponse());
1778 updatedVendorRelease = "A1|";
1779 // set VendorRelease
1780 resourceDetails.setVendorRelease(updatedVendorRelease);
1781 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1783 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1784 updatedRestResponse.getResponse());
1786 updatedVendorRelease = "A1?";
1787 // set VendorRelease
1788 resourceDetails.setVendorRelease(updatedVendorRelease);
1789 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1791 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1792 updatedRestResponse.getResponse());
1794 updatedVendorRelease = "A1*";
1795 // set VendorRelease
1796 resourceDetails.setVendorRelease(updatedVendorRelease);
1797 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1799 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
1800 updatedRestResponse.getResponse());
1802 // update resource VendorRelease metadata: null
1803 updatedVendorRelease = null;
1804 // set VendorRelease
1805 resourceDetails.setVendorRelease(updatedVendorRelease);
1806 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1808 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1809 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List,
1810 updatedRestResponse.getResponse());
1815 public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1836 RestResponse updatedRestResponse;
1838 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1839 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1840 String uniqueId = resourceDetails.getUniqueId();
1842 List<String> myList = new ArrayList<String>();
1843 myList.add(0, "Resource");
1844 String updatedcontactId = "";
1845 resourceDetails.setContactId(updatedcontactId);
1847 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1849 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1850 updatedRestResponse.getResponse());
1852 updatedcontactId = "ab12345";
1853 resourceDetails.setContactId(updatedcontactId);
1854 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1856 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1857 updatedRestResponse.getResponse());
1859 updatedcontactId = " ";
1860 resourceDetails.setContactId(updatedcontactId);
1861 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1863 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
1864 updatedRestResponse.getResponse());
1866 updatedcontactId = "ab 50h";
1867 resourceDetails.setContactId(updatedcontactId);
1868 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1870 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1871 updatedRestResponse.getResponse());
1873 updatedcontactId = "ab123c";
1874 resourceDetails.setContactId(updatedcontactId);
1875 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1877 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1878 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1879 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1881 updatedcontactId = "cd789E";
1882 resourceDetails.setContactId(updatedcontactId);
1883 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1885 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1886 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1888 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1889 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1891 updatedcontactId = "ef4567";
1892 resourceDetails.setContactId(updatedcontactId);
1893 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1895 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1896 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1897 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1898 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1900 updatedcontactId = "AA012A";
1901 resourceDetails.setContactId(updatedcontactId);
1902 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1904 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1905 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1906 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1908 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1909 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1911 updatedcontactId = "CD012c";
1912 resourceDetails.setContactId(updatedcontactId);
1913 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1915 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1916 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1917 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1919 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1920 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1922 updatedcontactId = "EF0123";
1923 resourceDetails.setContactId(updatedcontactId);
1924 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1926 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1927 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1928 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1930 resourceDetails.setContactId(updatedcontactId.toLowerCase());
1931 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1933 ////////////////////////////// **************//////////////////////////////
1934 List<String> resource = Arrays.asList("Resource");
1935 updatedcontactId = "01345a";
1936 resourceDetails.setContactId(updatedcontactId);
1937 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1939 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1940 updatedRestResponse.getResponse());
1942 updatedcontactId = "0y000B";
1943 resourceDetails.setContactId(updatedcontactId);
1944 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1946 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1947 updatedRestResponse.getResponse());
1949 updatedcontactId = "Y1000b";
1950 resourceDetails.setContactId(updatedcontactId);
1951 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1953 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1954 updatedRestResponse.getResponse());
1956 updatedcontactId = "abxyzC";
1957 resourceDetails.setContactId(updatedcontactId);
1958 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1960 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1961 updatedRestResponse.getResponse());
1963 updatedcontactId = "cdXYZc";
1964 resourceDetails.setContactId(updatedcontactId);
1965 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1967 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1968 updatedRestResponse.getResponse());
1970 updatedcontactId = "efXY1D";
1971 resourceDetails.setContactId(updatedcontactId);
1972 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1974 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1975 updatedRestResponse.getResponse());
1977 updatedcontactId = "EFabcD";
1978 resourceDetails.setContactId(updatedcontactId);
1979 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1981 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1982 updatedRestResponse.getResponse());
1984 updatedcontactId = "EFABCD";
1985 resourceDetails.setContactId(updatedcontactId);
1986 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1988 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1989 updatedRestResponse.getResponse());
1991 updatedcontactId = "EFABC1";
1992 resourceDetails.setContactId(updatedcontactId);
1993 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
1995 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
1996 updatedRestResponse.getResponse());
1998 updatedcontactId = "efui1D";
1999 resourceDetails.setContactId(updatedcontactId);
2000 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2002 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2003 updatedRestResponse.getResponse());
2005 updatedcontactId = "efui1!";
2006 resourceDetails.setContactId(updatedcontactId);
2007 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2009 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2010 updatedRestResponse.getResponse());
2012 updatedcontactId = "ef555!";
2013 resourceDetails.setContactId(updatedcontactId);
2014 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2016 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2017 updatedRestResponse.getResponse());
2019 updatedcontactId = ",f555";
2020 resourceDetails.setContactId(updatedcontactId);
2021 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2023 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2024 updatedRestResponse.getResponse());
2026 updatedcontactId = "EF55.5";
2027 resourceDetails.setContactId(updatedcontactId);
2028 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2030 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2031 updatedRestResponse.getResponse());
2033 // update resource contactId metadata: extended character set (128–255)
2034 resourceDetails.setContactId(extendedCharsStringBuilder());
2035 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2037 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
2038 updatedRestResponse.getResponse());
2040 // update resource contactId metadata: null
2041 updatedcontactId = null;
2042 resourceDetails.setContactId(updatedcontactId);
2043 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2045 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
2046 updatedRestResponse.getResponse());
2051 public void UpdateResource_TagsFieldValidation() throws Exception {
2052 RestResponse updatedRestResponse;
2053 // define and create resource
2055 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2056 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2057 String uniqueId = resourceDetails.getUniqueId();
2059 String updatedTagField = "";
2060 ArrayList<String> resourceTags = new ArrayList<String>();
2061 resourceTags.add(updatedTagField);
2063 resourceDetails.setTags(resourceTags);
2064 List<String> variables = Arrays.asList("Resource", "tag");
2065 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2067 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2068 updatedRestResponse.getResponse());
2070 // update resource tags metadata: empty
2071 resourceTags = new ArrayList<String>();
2073 resourceDetails.setTags(resourceTags);
2074 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2076 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List,
2077 updatedRestResponse.getResponse());
2079 // update resource description metadata: 1 characters
2080 updatedTagField = "A";
2081 resourceTags = new ArrayList<String>();
2082 resourceTags.add(updatedTagField);
2083 resourceTags.add(resourceDetails.getName());
2085 resourceDetails.setTags(resourceTags);
2086 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2088 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2089 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2090 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2091 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2093 // OK - tag up to 50 chars
2094 updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
2095 resourceTags.add(updatedTagField);
2096 resourceDetails.setTags(resourceTags);
2097 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2099 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2100 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2101 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2102 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2104 // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
2105 String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
2106 String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
2107 String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
2108 String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
2109 String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
2110 String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
2111 String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
2112 String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
2113 String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
2114 String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
2115 String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
2116 String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
2117 String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
2118 String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
2119 String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
2120 String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
2121 String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
2122 String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
2123 String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
2125 resourceTags = new ArrayList<String>();
2126 resourceTags.add(updatedTagField);
2127 resourceTags.add(updatedTagField1);
2128 resourceTags.add(updatedTagField2);
2129 resourceTags.add(updatedTagField3);
2130 resourceTags.add(updatedTagField4);
2131 resourceTags.add(updatedTagField5);
2132 resourceTags.add(updatedTagField6);
2133 resourceTags.add(updatedTagField7);
2134 resourceTags.add(updatedTagField8);
2135 resourceTags.add(updatedTagField9);
2136 resourceTags.add(updatedTagField10);
2137 resourceTags.add(updatedTagField11);
2138 resourceTags.add(updatedTagField12);
2139 resourceTags.add(updatedTagField13);
2140 resourceTags.add(updatedTagField14);
2141 resourceTags.add(updatedTagField15);
2142 resourceTags.add(updatedTagField16);
2143 resourceTags.add(updatedTagField17);
2144 resourceTags.add(updatedTagField18);
2145 resourceTags.add(updatedTagField19);
2146 resourceTags.add(resourceDetails.getName());
2148 resourceDetails.setTags(resourceTags);
2149 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2151 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2152 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2153 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2154 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2156 // Add another tag-exceeds limit
2157 resourceTags.add("d");
2158 resourceDetails.setTags(resourceTags);
2159 ArrayList<String> myArray = new ArrayList<String>();
2160 myArray.add(0, "1024");
2161 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2163 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray,
2164 updatedRestResponse.getResponse());
2166 // Tag exceeds limit - 51
2167 resourceTags = new ArrayList<String>();
2168 updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
2169 resourceTags.add(updatedTagField);
2170 resourceTags.add(resourceDetails.getName());
2172 resourceDetails.setTags(resourceTags);
2174 myArray.add(0, "50");
2175 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2177 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray,
2178 updatedRestResponse.getResponse());
2183 public void UpdateResource_DesriptionFieldValidation() throws Exception {
2184 // define and create resource
2185 RestResponse updatedRestResponse;
2187 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2188 String uniqueId = resourceDetails.getUniqueId();
2189 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2190 List<String> resource = new ArrayList<>();
2191 resource.add("Resource");
2192 // update resource description metadata: 0 characters
2193 String updatedDescription = "";
2195 resourceDetails.setDescription(updatedDescription);
2196 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2198 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2199 updatedRestResponse.getResponse());
2201 // update resource description metadata: null
2202 updatedDescription = null;
2204 resourceDetails.setDescription(updatedDescription);
2205 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2207 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
2208 updatedRestResponse.getResponse());
2210 // update resource description metadata: 1 characters
2211 updatedDescription = "A";
2213 resourceDetails.setDescription(updatedDescription);
2214 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2216 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2217 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2218 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2219 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2221 // update resource description metadata: 1024 characters
2222 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2223 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2224 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2225 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2226 + "The longest quills grow from its shoulders to about a third of the animal's length."
2227 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2228 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2229 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2230 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
2232 resourceDetails.setDescription(updatedDescription);
2233 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2235 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2236 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2237 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2238 parseResponseAndValidate(resourceDetails, updatedRestResponse);
2240 // update resource description metadata: 1025 characters
2241 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
2242 + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
2243 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
2244 + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
2245 + "The longest quills grow from its shoulders to about a third of the animal's length."
2246 + "Its tail is covered in short, hollow quills that can rattle when threatened."
2247 + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
2248 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
2249 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
2251 resourceDetails.setDescription(updatedDescription);
2252 resource.add(1, "1024");
2253 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
2255 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource,
2256 updatedRestResponse.getResponse());
2261 public void UpdateResource_TagsFormatValidation() throws Exception {
2262 char[] notValidCharsArray = getTagInValidFormatChars();
2264 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2265 assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
2266 String resourceName = resourceDetails.getName();
2268 // update tag details
2269 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2270 ArrayList<String> resourceTags = new ArrayList<String>();
2272 String updatedTagField;
2273 RestResponse updatedRestResponse;
2274 List<String> variables = Arrays.asList("Resource", "tag");
2276 for (int i = 0; i < notValidCharsArray.length; i++) {
2277 updatedTagField = "UpdatedTag" + notValidCharsArray[i];
2278 resourceTags = new ArrayList<String>();
2279 resourceTags.add(updatedTagField);
2280 resourceTags.add(resourceDetails.getName());
2282 updatedResourceDetails.setTags(resourceTags);
2284 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2285 resourceDetails.getUniqueId(), "");
2286 // validate response
2287 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2288 assertNotNull("check error code exists in response after update resource",
2289 updatedRestResponse.getErrorCode());
2290 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
2291 updatedRestResponse.getResponse());
2292 assertEquals("Check response code after updating resource icon", 400,
2293 updatedRestResponse.getErrorCode().intValue());
2294 assertEquals("Check response code after updating resource icon", "Bad Request",
2295 updatedRestResponse.getResponseMessage().toString());
2302 public void UpdateResourceCategory_negativeFlow() throws Exception {
2304 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2305 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2306 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2307 String uniqueID = resourceDetails.getUniqueId();
2309 // Update resource Category Successfully
2310 ResourceReqDetails updatedResourceDetails = resourceDetails;
2312 updatedResourceDetails.removeAllCategories();
2313 updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(),
2314 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2315 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2316 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2318 // validate response
2319 List<String> resourceList = new ArrayList<String>();
2320 resourceList.add(0, "Resource");
2321 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2322 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2323 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2324 updatedRestResponse.getResponse());
2325 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2327 // Updating resource category
2328 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2329 updatedResourceDetails.addCategory("");
2330 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2331 resourceDetails.getUniqueId(), "");
2332 // validate response
2333 resourceList = new ArrayList<String>();
2334 resourceList.add(0, "Resource");
2335 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2336 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2337 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList,
2338 updatedRestResponse.getResponse());
2339 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2341 // Updating resource category
2342 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2343 updatedResourceDetails.addCategory("XXXXXX");
2344 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2345 resourceDetails.getUniqueId(), "");
2346 // validate response
2347 resourceList = new ArrayList<String>();
2348 resourceList.add(0, "Resource");
2349 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2350 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2351 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
2352 updatedRestResponse.getResponse());
2353 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2356 logger.debug("Changing resource life cycle ");
2357 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2358 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2359 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2361 // Update resource Category
2362 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2363 updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2364 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
2365 resourceDetails.getUniqueId(), "");
2367 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2368 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2369 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List,
2370 updatedRestResponse.getResponse());
2371 assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2374 logger.debug("Changing resource life cycle ");
2375 RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2376 resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2377 assertNotNull("check response object is not null after checkout resource", checkoutResource);
2378 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2379 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2381 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2382 assertNotNull("check response object is not null after update resource", getRestResponse);
2383 parseResponseAndValidate(resourceDetails, getRestResponse);
2388 public void UpdateResourceCategorySuccessfully() throws Exception {
2390 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2391 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2392 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2394 // Update resource Category Successfully
2395 ResourceReqDetails updatedResourceDetails = resourceDetails;
2397 updatedResourceDetails.removeAllCategories();
2398 updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(),
2399 ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2400 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2401 sdncModifierDetails, resourceDetails.getUniqueId(), "");
2403 // validate response
2404 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2405 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2406 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2407 // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2408 // updatedRestResponse);
2409 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2411 // validate category updated
2412 assertTrue(updatedResourceDetails.getCategories().get(0).getName()
2413 .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2415 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
2416 resourceDetails.getUniqueId());
2417 assertNotNull("check response object is not null after update resource", getRestResponse);
2418 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2420 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2426 public void Validation_UpdateIcon() throws Exception {
2427 // Fields to update (Forbidden)
2428 String _updatedIcon = "mySecondIcon.Jpg";
2430 // administrator permissions
2431 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2433 // define and create resource
2434 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2436 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2437 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2438 String resourceName = resourceDetails.getName();
2440 // update metadata details
2441 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2442 // change icon of metadata
2443 updatedResourceDetails.setIcon(_updatedIcon);
2445 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
2446 sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2448 // validate response
2449 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2450 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2451 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(),
2452 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2456 updatedResourceDetails.setIcon(_updatedIcon);
2457 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
2458 resourceDetails.getUniqueId(), "");
2459 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2460 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2461 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(),
2462 Arrays.asList("Resource"), updatedRestResponse.getResponse());
2464 // get resource with original name. original metadata should be returned
2465 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
2466 resourceDetails.getUniqueId());
2467 // validate response
2468 assertNotNull("check response object is not null after get resource", getRestResponse);
2469 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2470 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2472 // parse updated response to javaObject
2473 Resource getResourceRespJavaObject = ResponseParser
2474 .convertResourceResponseToJavaObject(getRestResponse.getResponse());
2475 // validate that metadata was not changed
2476 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2478 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(),
2484 public void UpdateResourceTypeSuccess() throws Exception {
2486 String newResourceType = ResourceTypeEnum.VL.toString();
2487 String currentResourceType = resourceDetails.getResourceType();
2488 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2489 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2490 Resource currentResourceJavaObject = ResponseParser
2491 .convertResourceResponseToJavaObject(restResponse.getResponse());
2493 resourceDetails.setResourceType(newResourceType);
2494 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2495 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2496 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2497 Resource updatedResourceJavaObject = ResponseParser
2498 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2499 // assertTrue("Check resource type after update resource",
2500 // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2501 assertTrue("Check resource type after update resource",
2502 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2507 public void UpdateResourceTypeAndNameSuccess() throws Exception {
2509 String newResourceType = ResourceTypeEnum.VL.toString();
2510 String currentResourceType = resourceDetails.getResourceType();
2511 String newResourceName = "new Name";
2513 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2514 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2515 Resource currentResourceJavaObject = ResponseParser
2516 .convertResourceResponseToJavaObject(restResponse.getResponse());
2518 resourceDetails.setResourceType(newResourceType);
2519 resourceDetails.setName(newResourceName);
2520 List<String> tags = resourceDetails.getTags();
2521 tags.add(newResourceName);
2522 resourceDetails.setTags(tags);
2524 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2525 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2526 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2527 Resource updatedResourceJavaObject = ResponseParser
2528 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2529 assertTrue("Check resource type after update resource",
2530 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2531 assertTrue("Check resource name after update resource",
2532 updatedResourceJavaObject.getName().equals(newResourceName));
2537 public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2539 String newResourceType = ResourceTypeEnum.VF.toString();
2540 String currentResourceType = resourceDetails.getResourceType();
2541 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2542 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2543 Resource currentResourceJavaObject = ResponseParser
2544 .convertResourceResponseToJavaObject(restResponse.getResponse());
2546 resourceDetails.setResourceType(newResourceType);
2547 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2548 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2549 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2550 LifeCycleStatesEnum.CHECKOUT);
2551 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2552 currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2554 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2555 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2556 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2557 Resource updatedResourceJavaObject = ResponseParser
2558 .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2559 // assertTrue("Check resource type after update resource",
2560 // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2561 assertTrue("Check resource type after update resource",
2562 updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2567 public void UpdateResourceTypeCheckInLCS() throws Exception {
2569 String resourceType = ResourceTypeEnum.VL.toString();
2570 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2571 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2572 Resource currentResourceJavaObject = ResponseParser
2573 .convertResourceResponseToJavaObject(restResponse.getResponse());
2575 resourceDetails.setResourceType(resourceType);
2576 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
2577 LifeCycleStatesEnum.CHECKIN);
2578 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2580 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2581 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2583 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2585 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2586 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2587 assertEquals("Check response code after create resource", errorInfo.getCode(),
2588 updatedRestResponse.getErrorCode());
2590 List<String> variables = new ArrayList<>();
2591 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2592 updatedRestResponse.getResponse());
2597 public void UpdateResourceTypeCertifiedLCS() throws Exception {
2599 String resourceType = ResourceTypeEnum.VL.toString();
2600 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2601 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2602 Resource currentResourceJavaObject = ResponseParser
2603 .convertResourceResponseToJavaObject(restResponse.getResponse());
2605 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2606 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2608 resourceDetails.setResourceType(resourceType);
2609 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2610 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2612 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2614 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2615 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2616 assertEquals("Check response code after create resource", errorInfo.getCode(),
2617 updatedRestResponse.getErrorCode());
2619 List<String> variables = new ArrayList<>();
2620 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
2621 updatedRestResponse.getResponse());
2626 public void UpdateResourceTypeInvalidType() throws Exception {
2628 String resourceType = "INVALID TYPE";
2629 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2630 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2631 Resource currentResourceJavaObject = ResponseParser
2632 .convertResourceResponseToJavaObject(restResponse.getResponse());
2634 resourceDetails.setResourceType(resourceType);
2635 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
2636 sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2638 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2640 assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2641 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2642 assertEquals("Check response code after update resource", errorInfo.getCode(),
2643 updatedRestResponse.getErrorCode());
2645 List<String> variables = new ArrayList<>();
2646 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
2647 updatedRestResponse.getResponse());