2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.resource;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertNotNull;
25 import static org.testng.AssertJUnit.assertTrue;
27 import java.io.FileNotFoundException;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.HashMap;
31 import java.util.Iterator;
32 import java.util.List;
35 import org.json.JSONException;
36 import org.json.JSONObject;
37 import org.junit.rules.TestName;
38 import org.openecomp.sdc.be.dao.api.ActionStatus;
39 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
40 import org.openecomp.sdc.be.model.LifecycleStateEnum;
41 import org.openecomp.sdc.be.model.Resource;
42 import org.openecomp.sdc.be.model.User;
43 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
44 import org.openecomp.sdc.ci.tests.api.Urls;
45 import org.openecomp.sdc.ci.tests.config.Config;
46 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
47 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
48 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
49 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
50 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
53 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
54 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
55 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
56 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
57 import org.openecomp.sdc.ci.tests.utils.DbUtils;
58 import org.openecomp.sdc.ci.tests.utils.Utils;
59 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
60 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
61 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
63 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
64 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
65 import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
66 import org.openecomp.sdc.common.util.ValidationUtils;
67 import org.slf4j.Logger;
68 import org.slf4j.LoggerFactory;
69 import org.testng.AssertJUnit;
70 import org.testng.annotations.BeforeMethod;
71 import org.testng.annotations.Test;
73 import com.google.gson.Gson;
75 public class UpdateResourceMetadataTest extends ComponentBaseTest {
76 private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
77 protected List<String> Empty_List = new ArrayList<String>();
78 protected String extendedChars;
80 protected final String contentTypeHeaderData = "application/json";
81 protected final String acceptHeaderDate = "application/json";
82 protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
84 public static TestName name = new TestName();
85 protected User sdncModifierDetails;
86 protected ResourceReqDetails resourceDetails;
88 public UpdateResourceMetadataTest() {
89 super(name, UpdateResourceMetadataTest.class.getName());
93 public String extendedCharsStringBuilder() throws Exception {
94 char[] extendedCharsArray = new char[128];
96 for (int i = 0; i < extendedCharsArray.length - 1; i++) {
97 extendedCharsArray[i] = ch;
100 extendedChars = new String(extendedCharsArray);
101 return extendedChars;
106 public void setup() throws Exception {
107 sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
108 resourceDetails = defineResourse();
114 public void UpdateDerivedFromSuccess() throws Exception {
116 String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
117 String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
119 // Getting both derived from resources for validation
121 * RestResponse resourceByNameAndVersion = resourceUtils.getResourceByNameAndVersion(sdncModifierDetails, oldDerivedFromName, "1.0"); assertEquals("Check response code after get database normative", 200,
122 * resourceByNameAndVersion.getErrorCode().intValue()); Resource databaseNormative = resourceUtils.parseResourceResp(resourceByNameAndVersion);
124 * resourceByNameAndVersion = resourceUtils.getResourceByNameAndVersion(sdncModifierDetails, newDerivedFromName, "1.0"); assertEquals("Check response code after get database normative", 200,
125 * resourceByNameAndVersion.getErrorCode().intValue()); Resource lbNormative = resourceUtils.parseResourceResp(resourceByNameAndVersion);
128 // Derived from set to Database
129 List<String> derivedFrom = new ArrayList<>();
130 derivedFrom.add(oldDerivedFromName);
131 resourceDetails.setDerivedFrom(derivedFrom);
133 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
134 AssertJUnit.assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
135 Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
138 derivedFrom.add(newDerivedFromName);
139 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResource.getUniqueId(), "");
140 AssertJUnit.assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
144 protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
145 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
147 updatedResourceDetails.setVersion("mumu");
148 updatedResourceDetails.setIsAbstract(true);
149 updatedResourceDetails.setIsHighestVersion(true);
150 updatedResourceDetails.setCreatorUserId("df4444");
151 updatedResourceDetails.setCreatorFullName("John Doe");
152 updatedResourceDetails.setLastUpdaterUserId("gf5646");
153 updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
154 updatedResourceDetails.setCreationDate(new Long(4444));
155 updatedResourceDetails.setLastUpdateDate(new Long("534535"));
156 updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
157 updatedResourceDetails.setCost("6.1");
158 updatedResourceDetails.setLicenseType("Installation");
159 updatedResourceDetails.setUUID("dfsfsdf");
160 return updatedResourceDetails;
163 public void UpdateResourceNotFoundTest() throws Exception {
165 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
167 String resourceName = "cisco4";
169 String description = "updatedDescription";
170 ArrayList<String> resourceTags = new ArrayList<String>();
171 resourceTags.add("tag2");
172 String category = ServiceCategoriesEnum.MOBILITY.getValue();
173 ArrayList<String> derivedFrom = new ArrayList<String>();
174 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
175 String vendorName = "newOracle";
176 String vendorRelease = "2.5";
177 String contactId = "jh0003";
178 String icon = "myICON";
180 ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category, derivedFrom, vendorName, vendorRelease, contactId, icon);
181 updatedResourceDetails.setUniqueId("dummyId");
182 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, "0.1");
185 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
186 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
187 AssertJUnit.assertEquals("Check response code after update resource", 404, updatedRestResponse.getErrorCode().intValue());
188 // String resourceId =
189 // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
190 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), updatedRestResponse.getResponse());
193 // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
195 updatedResourceDetails = defineUpdatedResourse(resourceName);
196 updatedResourceDetails.setUniqueId("dummyId");
197 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, "0.1");
198 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
199 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
200 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), updatedRestResponse.getResponse());
204 public char[] getInValidChars() throws Exception {
206 char[] extendedCharsArray = new char[59];
208 for (int i = 0; i < 44; i++) {
209 extendedCharsArray[i] = ch;
213 for (int i = 44; i < 51; i++) {
214 extendedCharsArray[i] = ch;
218 for (int i = 51; i < 55; i++) {
219 extendedCharsArray[i] = ch;
223 for (int i = 55; i < 59; i++) {
224 extendedCharsArray[i] = ch;
227 return extendedCharsArray;
230 public char[] getTagInValidFormatChars() throws Exception {
231 // Tag format is the same as defined for Resource Name :
232 // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
233 // ('_'), dash ('-'), dot ('.')
234 char[] notValidCharsArray = new char[30];
236 for (int i = 0; i < 12; i++) {
237 notValidCharsArray[i] = ch;
240 notValidCharsArray[13] = 47;
242 for (int i = 14; i < 21; i++) {
243 notValidCharsArray[i] = ch;
247 for (int i = 21; i < 24; i++) {
248 notValidCharsArray[i] = ch;
251 notValidCharsArray[24] = 96;
253 for (int i = 25; i < 30; i++) {
254 notValidCharsArray[i] = ch;
257 return notValidCharsArray;
260 public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
262 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
264 // define and create resource
265 ResourceReqDetails resourceDetails = defineResourse();
266 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
267 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
268 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
270 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
271 String resourceId = resourceDetails.getUniqueId();
272 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
275 JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
277 List<String> resource = new ArrayList<>();
278 resource.add("Resource");
280 // remove Description
281 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description", ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
283 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags", ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
285 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category", ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
287 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName", ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
288 // remove VendorRelease
289 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease", ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
290 // remove AT&T Contact
291 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId", ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
293 // get resource with original name. original metadata should be returned
294 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
296 AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
297 AssertJUnit.assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
298 AssertJUnit.assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
300 // parse updated response to javaObject
301 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
302 // validate that metadata was not changed
303 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
305 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
306 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
307 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
310 // End of validation tests
311 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
313 protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
314 String description = "updatedDescription";
315 ArrayList<String> resourceTags = new ArrayList<String>();
316 // Duplicate tags are allowed and should be de-duplicated by server side
317 resourceTags.add(resourceName);
318 resourceTags.add("tag1");
319 resourceTags.add("tag1");
320 resourceTags.add("tag2");
321 resourceTags.add("tag2");
322 String category = ServiceCategoriesEnum.VOIP.getValue();
323 ArrayList<String> derivedFrom = new ArrayList<String>();
324 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
325 String vendorName = "updatedOracle";
326 String vendorRelease = "3.5";
327 String contactId = "jh0001";
328 String icon = "myUpdatedICON";
330 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category, derivedFrom, vendorName, vendorRelease, contactId, icon);
331 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
333 return resourceDetails;
336 protected ResourceReqDetails defineResourse() {
337 String resourceName = "cisco4";
338 String description = "description";
339 ArrayList<String> resourceTags = new ArrayList<String>();
340 resourceTags.add(resourceName);
341 ArrayList<String> derivedFrom = new ArrayList<String>();
342 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
343 String vendorName = "Oracle";
344 String vendorRelease = "1.5";
345 String contactId = "jh0003";
346 String icon = "objectStorage";
348 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null, derivedFrom, vendorName, vendorRelease, contactId, icon);
349 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
351 return resourceDetails;
354 protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails) throws Exception {
356 DbUtils.cleanAllAudits();
359 RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
362 AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
363 AssertJUnit.assertNotNull("check error code exists in response after create resource", restResponse.getErrorCode());
364 AssertJUnit.assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
369 protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails, String uri) throws Exception {
372 RestResponse ResourceResponse;
374 config = Utils.getConfig();
375 Map<String, String> headersMap = new HashMap<String, String>();
376 headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
377 headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
378 headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
379 HttpRequest http = new HttpRequest();
380 String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(), config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
383 ResourceResponse = http.httpSendGet(url, headersMap);
384 } else if (uri == "POST") {
385 Gson gson = new Gson();
386 String userBodyJson = gson.toJson(updatedResourceDetails);
387 ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
388 } else if (uri == "DELETE") {
389 ResourceResponse = http.httpSendDelete(url, headersMap);
393 return ResourceResponse;
394 } catch (FileNotFoundException e) {
395 // TODO Auto-generated catch block
403 protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
404 // json object: resourceName and icon are must
405 JSONObject jObject = new JSONObject();
407 List<String> tagsList = Arrays.asList(resourceDetails.getName());
408 List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
410 jObject.put("name", resourceDetails.getName());
411 jObject.put("description", "updatedDescription");
412 jObject.put("tags", tagsList);
413 jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
414 jObject.put("derivedFrom", derivedFromList);
415 jObject.put("vendorName", "newOracle");
416 jObject.put("vendorRelease", "1.5");
417 jObject.put("contactId", "jh0003");
418 jObject.put("icon", resourceDetails.getIcon());
423 protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
424 jObject.remove(removedPropery);
429 // purpose: function for controlling json body fields and validating
431 protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject, String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
433 JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
434 // remove description from jsonObject
435 jObject = RemoveFromJsonObject(jObject, removedField);
436 // update with incomplete body.
437 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(), sdncModifierDetails, resourceId);
439 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
440 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
441 ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
445 // purpose: function for validating error response
446 protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails, String recievedMessage, List<String> variables) throws Exception {
447 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, "0.1");
449 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
450 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
451 ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
455 protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse) throws Exception {
456 // parse response to javaObject
457 Resource updatedResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
458 AssertJUnit.assertTrue(!resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
459 AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
460 AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
461 AssertJUnit.assertTrue(!resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
462 AssertJUnit.assertTrue(!resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
463 AssertJUnit.assertTrue(!resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
464 AssertJUnit.assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
465 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
466 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName().equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
467 AssertJUnit.assertTrue(!resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
468 AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
469 AssertJUnit.assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
470 AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
473 protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse) throws Exception {
474 // parse response to javaObject
475 Resource updatedResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
476 // validate request vs response
477 ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
480 public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails, String resourceVersion) {
482 ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
484 expectedResourceAuditJavaObject.setAction("Checkout");
485 expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
486 expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
487 expectedResourceAuditJavaObject.setStatus("200.0");
488 expectedResourceAuditJavaObject.setDesc("OK");
489 expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
490 expectedResourceAuditJavaObject.setResourceType("Resource");
491 expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
492 expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
493 expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
494 expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
496 return expectedResourceAuditJavaObject;
500 public enum FieldToValidate {
501 ContactId, Tags, VendorName, VendorRelease, Description
505 public void UpdateBy_postTest() throws Exception {
507 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
508 String resourceName = resourceDetails.getName();
510 // update resource - without changing resourceName
511 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
513 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
516 assertNotNull("check response object is not null after update resource", updatedRestResponse);
517 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
518 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
520 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
521 assertNotNull("check response object is not null after update resource", getRestResponse);
522 parseResponseAndValidate(resourceDetails, getRestResponse);
527 public void UpdateBy_getTest() throws Exception {
529 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
530 String resourceName = resourceDetails.getName();
532 // update resource - without changing resourceName
533 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
534 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
537 assertNotNull("check response object is not null after update resource", updatedRestResponse);
538 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
539 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
541 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
542 assertNotNull("check response object is not null after update resource", getRestResponse);
543 parseResponseAndValidate(resourceDetails, getRestResponse);
548 public void UpdateBy_deleteTest() throws Exception {
550 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
551 String resourceName = resourceDetails.getName();
553 // update resource - without changing resourceName
554 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
555 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "DELETE");
558 assertNotNull("check response object is not null after update resource", updatedRestResponse);
559 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
560 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
562 RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
563 assertNotNull("check response object is not null after update resource", getRestResponse);
564 parseResponseAndValidate(resourceDetails, getRestResponse);
571 public void UpdateWithInvaldJsonBodyTest() throws Exception {
573 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
574 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
575 String resourceId = resourceDetails.getUniqueId();
577 // update Descirption value
578 String description = "updatedDescription";
580 // send update with incompleted json, only description string
581 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails, resourceId);
584 assertNotNull("check response object is not null after update resource", updatedRestResponse);
585 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
586 assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
588 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
589 assertNotNull("check response object is not null after update resource", getRestResponse);
590 parseResponseAndValidate(resourceDetails, getRestResponse);
595 public void UpdateResourceNameSensitiveTest() throws Exception {
596 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
597 String resourceBaseVersion = "0.1";
598 String resourceName = "Ab";
599 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
601 RestResponse response = null;
602 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
603 BaseRestUtils.checkDeleteResponse(response);
604 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
605 BaseRestUtils.checkDeleteResponse(response);
607 RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
608 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
611 logger.debug("Changing resource life cycle ");
612 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
613 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
615 // String resourceCertifyVersion = "0.1";
616 logger.debug("Changing resource life cycle ");
617 checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
618 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
620 updatedResourceDetails.setName("ABC_-bt.aT");
621 ArrayList<String> resourceTag = new ArrayList<String>();
622 resourceTag.add(0, "ABC_-bt.aT");
623 updatedResourceDetails.setTags(resourceTag);
624 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
625 assertNotNull("check response object is not null after update resource", updatedRestResponse);
626 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
627 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
628 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
631 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
632 BaseRestUtils.checkDeleteResponse(response);
633 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
634 BaseRestUtils.checkDeleteResponse(response);
639 public void UpdateIcon_InegativeFlow() throws Exception {
641 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
642 String resourceName = resourceDetails.getName();
644 List<String> resourceList = new ArrayList<String>();
645 resourceList.add(0, "Resource");
646 // check InValid Characters
647 char[] notValidCharsArray = new char[59];
648 notValidCharsArray = getInValidChars();
649 // update metadata details
650 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
651 RestResponse updatedRestResponse;
653 for (int i = 0; i < notValidCharsArray.length; i++) {
654 // change icon of metadata
655 updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
657 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
659 assertNotNull("check response object is not null after update resource", updatedRestResponse);
660 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
661 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList, updatedRestResponse.getResponse());
662 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
663 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
668 String updateIcon = "";
669 updatedResourceDetails.setIcon(updateIcon);
670 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
671 assertNotNull("check response object is not null after update resource", updatedRestResponse);
672 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
673 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList, updatedRestResponse.getResponse());
675 // Icon length more then 25 characters
676 resourceList.add(1, "25");
677 updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
678 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
680 assertNotNull("check response object is not null after update resource", updatedRestResponse);
681 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
682 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList, updatedRestResponse.getResponse());
683 assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
684 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
686 // get resource with original name. original metadata should be returned
687 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
689 assertNotNull("check response object is not null after get resource", getRestResponse);
690 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
691 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
693 // parse updated response to javaObject
694 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
695 // validate that metadata was not changed
696 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
701 public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
703 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
704 String resourceBaseVersion = "0.1";
707 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
708 String resourceName = resourceDetails.getName();
710 ResourceReqDetails updatedResourceDetails = defineResourse();
711 updatedResourceDetails.setName("updatedResourceName");
712 List<String> tags = updatedResourceDetails.getTags();
714 for (Iterator<String> iter = tags.listIterator(); iter.hasNext();) {
715 String a = iter.next();
716 if (a.equals("updatedResourceName")) {
721 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
723 List<String> resourceList = new ArrayList<String>();
724 assertNotNull("check response object is not null after update resource", updatedRestResponse);
725 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
726 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(), resourceList, updatedRestResponse.getResponse());
727 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
729 // get resource with original name. original metadata should be returned
730 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
732 assertNotNull("check response object is not null after get resource", getRestResponse);
733 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
734 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
735 // parse updated response to javaObject
736 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
737 // validate that metadata was not changed
738 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
743 public void UpdateResourceName_negativeFlow() throws Exception {
744 // The validation are done in Tag's validation
745 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
747 RestResponse updatedRestResponse;
748 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
749 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
750 String uniqueId = resourceDetails.getUniqueId();
751 String resourceName = resourceDetails.getName();
752 // check InValid Characters
753 char[] notValidCharsArray = new char[59];
754 notValidCharsArray = getInValidChars();
755 ArrayList<String> resource_Name = new ArrayList<String>();
756 List<String> resourceList = new ArrayList<String>();
758 ArrayList<String> resourceTags = new ArrayList<String>();
759 resourceList.add(0, "Resource");
761 // update metadata details
762 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
763 for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
764 if (i != 1 && i != 46 && /*
765 * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
766 */ i != 31) // space ("") and dot(.)
768 // change resourceName parameter
769 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
770 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
771 updatedResourceDetails.setTags(resource_Name);
772 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, uniqueId, "");
774 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
775 // Empty_List, updatedRestResponse.getResponse());
776 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList, updatedRestResponse.getResponse());
781 // resourceName length more then 50 characters
782 // Duplicate tags are allowed and should be de-duplicated by server side
783 resource_Name.add(resourceName);
784 resource_Name.add("tag1");
785 resource_Name.add("tag1");
786 resource_Name.add("tag2");
787 resource_Name.add("tag2");
789 resourceList.add(1, "1024");
790 // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
791 updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
792 // resource_Name.add("123456789012345678901234567890123456789012345678901");
793 updatedResourceDetails.setTags(resource_Name);
794 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, uniqueId, "");
796 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList, updatedRestResponse.getResponse());
798 // get resource with original name. original metadata should be returned
799 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, resourceDetails.getUniqueId());
801 assertNotNull("check response object is not null after get resource", getRestResponse);
802 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
803 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
804 // parse updated response to javaObject
805 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
806 // validate that metadata was not changed
807 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
810 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), "0.1");
811 BaseRestUtils.checkDeleteResponse(response);
815 public void UpdateResourceInformation_NotCheckedOut() throws Exception {
817 String resourceBaseVersion = "0.1";
818 List<String> resourceList = new ArrayList<String>();
820 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
821 String resourceName = resourceDetails.getName();
824 logger.debug("Changing resource life cycle ");
825 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
826 assertNotNull("check response object is not null after checkout resource", checkoutResource);
827 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
828 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
830 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
832 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
833 assertNotNull("check response object is not null after update resource", updatedRestResponse);
834 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
835 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, updatedRestResponse.getResponse());
836 assertEquals("Check response code after updating resource icon", 409, updatedRestResponse.getErrorCode().intValue());
838 // get resource with original name. original metadata should be returned
839 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
841 assertNotNull("check response object is not null after get resource", getRestResponse);
842 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
843 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
845 // parse updated response to javaObject
846 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
847 // validate that metadata was not changed
848 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
853 public void UpdateResourceInformation_resourceVersion_11() throws Exception {
855 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
856 String resourceBaseVersion = "0.1";
859 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
860 String resourceName = resourceDetails.getName();
862 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
866 logger.debug("Changing resource life cycle ");
867 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
868 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
870 logger.debug("Changing resource life cycle ");
871 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
872 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
874 logger.debug("Changing resource life cycle ");
875 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
876 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
878 logger.debug("Changing resource life cycle ");
879 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
880 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
882 String resourceCertifyVersion = "1.0";
883 logger.debug("Changing resource life cycle ");
884 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
885 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
887 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
889 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
891 List<String> resourceList = new ArrayList<String>();
892 assertNotNull("check response object is not null after update resource", updatedRestResponse);
893 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
894 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, updatedRestResponse.getResponse());
895 // assertEquals("Check response code after updating resource icon", 409,
896 // updatedRestResponse.getErrorCode().intValue());
898 // get resource with original name. original metadata should be returned
899 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
901 assertNotNull("check response object is not null after get resource", getRestResponse);
903 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
905 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
906 // parse updated response to javaObject
907 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
908 // validate that metadata was not changed
909 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
914 public void UpdateResourceInformation_resourceVersion_02() throws Exception {
916 String resourceBaseVersion = "0.1";
919 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
920 String resourceName = resourceDetails.getName();
922 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
926 logger.debug("Changing resource life cycle ");
927 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
928 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
930 // String resourceCertifyVersion = "0.1";
931 logger.debug("Changing resource life cycle ");
932 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
933 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
935 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
937 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
939 assertNotNull("check response object is not null after update resource", updatedRestResponse);
940 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
941 assertEquals("Check response code after updating resource icon", 200, updatedRestResponse.getErrorCode().intValue());
943 // get resource with original name. original metadata should be returned
944 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
946 assertNotNull("check response object is not null after get resource", getRestResponse);
947 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
948 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
950 // parse updated response to javaObject
951 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
952 // validate that metadata was not changed
953 ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
956 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
957 BaseRestUtils.checkDeleteResponse(response);
958 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
959 BaseRestUtils.checkDeleteResponse(response);
964 public void UpdateResourceIcon_resourceVersion_11() throws Exception {
965 // Can be changed only if major version is 0.
967 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
968 String resourceBaseVersion = "0.1";
971 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
972 String resourceName = resourceDetails.getName();
974 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
978 logger.debug("Changing resource life cycle ");
979 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
980 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
982 logger.debug("Changing resource life cycle ");
983 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
984 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
986 logger.debug("Changing resource life cycle ");
987 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
988 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
990 logger.debug("Changing resource life cycle ");
991 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
992 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
994 String resourceCertifyVersion = "1.0";
995 logger.debug("Changing resource life cycle ");
996 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
997 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
999 // ResourceReqDetails updatedResourceDetails =
1000 // defineUpdatedResourse(resourceName);
1001 ResourceReqDetails updatedResourceDetails = defineResourse();
1002 // updatedResourceDetails.setVendorName("updatedVandorName");
1003 updatedResourceDetails.setIcon("updatedIcon");
1005 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1006 // validate response
1007 List<String> resourceList = new ArrayList<String>();
1008 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1010 // get resource with original name. original metadata should be returned
1011 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1012 // validate response
1013 assertNotNull("check response object is not null after get resource", getRestResponse);
1014 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1015 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1016 // parse updated response to javaObject
1017 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1018 // validate that metadata was not changed
1019 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1024 public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1025 // Can be changed only if the major resource version is 0.
1026 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1027 String resourceBaseVersion = "0.1";
1030 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1031 String resourceName = resourceDetails.getName();
1033 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1037 logger.debug("Changing resource life cycle ");
1038 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1039 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1041 logger.debug("Changing resource life cycle ");
1042 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1043 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1045 logger.debug("Changing resource life cycle ");
1046 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1047 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1049 logger.debug("Changing resource life cycle ");
1050 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1051 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1053 String resourceCertifyVersion = "1.0";
1054 logger.debug("Changing resource life cycle ");
1055 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1056 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1058 // ResourceReqDetails updatedResourceDetails =
1059 // defineUpdatedResourse(resourceName);
1060 ResourceReqDetails updatedResourceDetails = defineResourse();
1062 updatedResourceDetails.setVendorName("updatedVandorName");
1064 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1065 // validate response
1066 List<String> resourceList = new ArrayList<String>();
1067 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1068 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1069 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1070 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
1072 // get resource with original name. original metadata should be returned
1073 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1074 // validate response
1075 assertNotNull("check response object is not null after get resource", getRestResponse);
1076 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1077 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1078 // parse updated response to javaObject
1079 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1080 // validate that metadata was not changed
1081 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1086 public void UpdateResourceName_resourceVersion_11() throws Exception {
1087 // Can be changed only if the major resource version is 0.
1088 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1089 String resourceBaseVersion = "0.1";
1092 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1093 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1094 String resourceName = resourceDetails.getName();
1096 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1100 logger.debug("Changing resource life cycle ");
1101 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1102 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1104 logger.debug("Changing resource life cycle ");
1105 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1106 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1108 logger.debug("Changing resource life cycle ");
1109 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1110 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1112 logger.debug("Changing resource life cycle ");
1113 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1114 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1116 String resourceCertifyVersion = "1.0";
1117 logger.debug("Changing resource life cycle ");
1118 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1119 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1122 * //ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); ResourceReqDetails updatedResourceDetails = defineResourse();
1124 * updatedResourceDetails.setResourceName("updatedResourceName"); updatedResourceDetails.setIcon("updatedResourceName");
1126 resourceDetails.setName("updatedResourceName");
1127 List<String> tagList = new ArrayList<String>();
1128 tagList.add(0, "updatedResourceName");
1129 resourceDetails.setTags(tagList);
1131 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1132 // validate response
1133 List<String> resourceList = new ArrayList<String>();
1134 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1135 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1136 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1141 public void UpdateResourceTag_resourceVersion_11() throws Exception {
1142 // Tag Can be updated when major version is 0.
1143 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1144 String resourceBaseVersion = "0.1";
1147 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1148 String resourceName = resourceDetails.getName();
1150 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1154 logger.debug("Changing resource life cycle ");
1155 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1156 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1158 logger.debug("Changing resource life cycle ");
1159 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1160 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1162 logger.debug("Changing resource life cycle ");
1163 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1164 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1166 logger.debug("Changing resource life cycle ");
1167 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1168 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1170 String resourceCertifyVersion = "1.0";
1171 logger.debug("Changing resource life cycle ");
1172 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, 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");
1180 ArrayList<String> resourceTags = new ArrayList<String>();
1181 resourceTags.add("NewTag");
1182 resourceTags.add(resourceDetails.getName());
1184 updatedResourceDetails.setTags(resourceTags);
1186 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1187 // validate response
1188 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1189 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1190 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1192 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1193 assertNotNull("check response object is not null after update resource", getRestResponse);
1194 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1199 public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1201 // Tag, contactId, vendorRelease,tags And description - Can be also
1202 // updated when major version is NOT 0.
1203 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1204 String resourceBaseVersion = "0.1";
1207 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1209 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1213 logger.debug("Changing resource life cycle ");
1214 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1215 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1217 logger.debug("Changing resource life cycle ");
1218 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1219 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1221 logger.debug("Changing resource life cycle ");
1222 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1223 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1225 logger.debug("Changing resource life cycle ");
1226 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1227 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1229 String resourceCertifyVersion = "1.0";
1230 logger.debug("Changing resource life cycle ");
1231 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1232 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1234 // ResourceReqDetails updatedResourceDetails =
1235 // defineUpdatedResourse(resourceName);
1236 ResourceReqDetails updatedResourceDetails = defineResourse();
1237 // updatedResourceDetails.setVendorName("updatedVandorName");
1239 // updated allowed parameters when major resource version is NOT "0"
1240 ArrayList<String> resourceTags = new ArrayList<String>();
1241 resourceTags.add("NewTag");
1242 resourceTags.add(resourceDetails.getName());
1243 updatedResourceDetails.setTags(resourceTags);
1244 updatedResourceDetails.setDescription("UpdatedDescription");
1245 updatedResourceDetails.setVendorRelease("5.1");
1246 updatedResourceDetails.setContactId("bt750h");
1248 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1249 // validate response
1250 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1251 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1252 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1254 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1255 assertNotNull("check response object is not null after update resource", getRestResponse);
1256 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1261 public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1262 // DerivedFrom parameter - Can be updated when major version is 0.
1263 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1264 String resourceBaseVersion = "0.1";
1267 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1268 String resourceName = resourceDetails.getName();
1270 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1274 logger.debug("Changing resource life cycle ");
1275 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1276 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1278 logger.debug("Changing resource life cycle ");
1279 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1280 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1282 logger.debug("Changing resource life cycle ");
1283 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1284 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1286 logger.debug("Changing resource life cycle ");
1287 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1288 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1290 String resourceCertifyVersion = "1.0";
1291 logger.debug("Changing resource life cycle ");
1292 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1293 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1295 // ResourceReqDetails updatedResourceDetails =
1296 // defineUpdatedResourse(resourceName);
1297 ResourceReqDetails updatedResourceDetails = defineResourse();
1298 ArrayList<String> drivenFrom = new ArrayList<String>();
1299 drivenFrom.add(0, "tosca.nodes.Container.Application");
1300 updatedResourceDetails.setDerivedFrom(drivenFrom);
1302 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1303 // validate response
1304 List<String> resourceList = new ArrayList<String>();
1305 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_DERIVED_FROM_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1307 // get resource with original name. original metadata should be returned
1308 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1309 // validate response
1310 assertNotNull("check response object is not null after get resource", getRestResponse);
1311 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1312 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1313 // parse updated response to javaObject
1314 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1315 // validate that metadata was not changed
1316 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1321 public void UpdateResource_vendorNameValidation() throws Exception {
1323 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1324 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1325 String updatedVendorName = "";
1326 String uniqueId = resourceDetails.getUniqueId();
1327 resourceDetails.setVendorName(updatedVendorName);
1328 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1329 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1330 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1331 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1333 // update resource vendorName metadata: 1 characters
1334 updatedVendorName = " ";
1336 resourceDetails.setVendorName(updatedVendorName);
1337 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1338 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1339 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1340 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1342 // update resource vendorName metadata: 25 characters
1343 updatedVendorName = "Verification and validati";
1345 resourceDetails.setVendorName(updatedVendorName);
1346 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1347 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1348 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1349 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1350 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1352 // update resource vendorName metadata: 26 characters
1353 updatedVendorName = "Verification and validatii";
1355 List<String> myList = new ArrayList<String>();
1356 myList.add(0, "25");
1357 resourceDetails.setVendorName(updatedVendorName);
1358 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1359 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1360 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList, updatedRestResponse.getResponse());
1362 // update resource VendorRelease metadata: forbidden characters
1363 updatedVendorName = "A1<";
1365 resourceDetails.setVendorName(updatedVendorName);
1366 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1367 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1368 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1370 updatedVendorName = "A1>";
1372 resourceDetails.setVendorName(updatedVendorName);
1373 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1374 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1375 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1377 updatedVendorName = "A1:";
1379 resourceDetails.setVendorName(updatedVendorName);
1380 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1381 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1382 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1384 updatedVendorName = "A1\"";
1386 resourceDetails.setVendorName(updatedVendorName);
1387 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1388 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1389 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1391 updatedVendorName = "A1/";
1393 resourceDetails.setVendorName(updatedVendorName);
1394 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1395 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1396 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1398 updatedVendorName = "A1\\";
1400 resourceDetails.setVendorName(updatedVendorName);
1401 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1402 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1403 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1405 updatedVendorName = "A1|";
1407 resourceDetails.setVendorName(updatedVendorName);
1408 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1409 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1410 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1412 updatedVendorName = "A1?";
1414 resourceDetails.setVendorName(updatedVendorName);
1415 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1416 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1417 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1419 updatedVendorName = "A1*";
1421 resourceDetails.setVendorName(updatedVendorName);
1422 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1423 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1424 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1426 // update resource vendorName metadata: null
1427 updatedVendorName = null;
1429 resourceDetails.setVendorName(updatedVendorName);
1430 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1431 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1432 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1437 public void UpdateResource_vendorReleaseValidation() throws Exception {
1439 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1440 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1441 RestResponse updatedRestResponse;
1442 String uniqueId = resourceDetails.getUniqueId();
1443 String updatedVendorRelease;
1444 // set VendorRelease
1446 // update resource VendorRelease metadata: 1 characters
1447 updatedVendorRelease = "1";
1448 // set VendorRelease
1449 resourceDetails.setVendorRelease(updatedVendorRelease);
1450 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1451 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1452 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1453 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1454 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1456 // update resource VendorRelease metadata: 25 characters
1457 updatedVendorRelease = "(!#1.00000000000000000000";
1458 // set VendorRelease
1459 resourceDetails.setVendorRelease(updatedVendorRelease);
1460 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1461 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1462 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1463 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1464 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1466 // update resource VendorRelease metadata: 26 characters
1467 updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1468 resourceDetails.setVendorRelease(updatedVendorRelease);
1469 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1470 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(), Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1472 // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1473 // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1474 // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1476 // update resource VendorRelease metadata: forbidden characters
1477 updatedVendorRelease = "A1<";
1478 // set VendorRelease
1479 resourceDetails.setVendorRelease(updatedVendorRelease);
1480 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1481 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1483 updatedVendorRelease = "A1>";
1484 // set VendorRelease
1485 resourceDetails.setVendorRelease(updatedVendorRelease);
1486 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1487 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1489 updatedVendorRelease = "A1:";
1490 // set VendorRelease
1491 resourceDetails.setVendorRelease(updatedVendorRelease);
1492 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1493 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1495 updatedVendorRelease = "A1\"";
1496 // set VendorRelease
1497 resourceDetails.setVendorRelease(updatedVendorRelease);
1498 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1499 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1501 updatedVendorRelease = "A1/";
1502 // set VendorRelease
1503 resourceDetails.setVendorRelease(updatedVendorRelease);
1504 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1505 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1507 updatedVendorRelease = "A1\\";
1508 // set VendorRelease
1509 resourceDetails.setVendorRelease(updatedVendorRelease);
1510 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1511 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1513 updatedVendorRelease = "A1|";
1514 // set VendorRelease
1515 resourceDetails.setVendorRelease(updatedVendorRelease);
1516 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1517 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1519 updatedVendorRelease = "A1?";
1520 // set VendorRelease
1521 resourceDetails.setVendorRelease(updatedVendorRelease);
1522 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1523 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1525 updatedVendorRelease = "A1*";
1526 // set VendorRelease
1527 resourceDetails.setVendorRelease(updatedVendorRelease);
1528 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1529 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1531 // update resource VendorRelease metadata: null
1532 updatedVendorRelease = null;
1533 // set VendorRelease
1534 resourceDetails.setVendorRelease(updatedVendorRelease);
1535 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1536 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1537 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1542 public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1563 RestResponse updatedRestResponse;
1565 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1566 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1567 String uniqueId = resourceDetails.getUniqueId();
1569 List<String> myList = new ArrayList<String>();
1570 myList.add(0, "Resource");
1571 String updatedContactId = "";
1572 resourceDetails.setContactId(updatedContactId);
1574 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1575 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1577 updatedContactId = "ab12345";
1578 resourceDetails.setContactId(updatedContactId);
1579 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1580 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1582 updatedContactId = " ";
1583 resourceDetails.setContactId(updatedContactId);
1584 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1585 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1587 updatedContactId = "ab 50h";
1588 resourceDetails.setContactId(updatedContactId);
1589 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1590 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1592 updatedContactId = "ab123c";
1593 resourceDetails.setContactId(updatedContactId);
1594 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1595 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1596 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1597 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1599 updatedContactId = "cd789E";
1600 resourceDetails.setContactId(updatedContactId);
1601 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1602 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1603 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1605 resourceDetails.setContactId(updatedContactId.toLowerCase());
1606 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1608 updatedContactId = "ef4567";
1609 resourceDetails.setContactId(updatedContactId);
1610 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1611 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1612 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1613 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1614 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1616 updatedContactId = "AA012A";
1617 resourceDetails.setContactId(updatedContactId);
1618 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1619 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1620 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1621 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1623 resourceDetails.setContactId(updatedContactId.toLowerCase());
1624 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1626 updatedContactId = "CD012c";
1627 resourceDetails.setContactId(updatedContactId);
1628 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1629 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1630 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1631 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1633 resourceDetails.setContactId(updatedContactId.toLowerCase());
1634 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1636 updatedContactId = "EF0123";
1637 resourceDetails.setContactId(updatedContactId);
1638 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1639 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1640 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1641 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1643 resourceDetails.setContactId(updatedContactId.toLowerCase());
1644 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1646 ////////////////////////////// **************//////////////////////////////
1647 List<String> resource = Arrays.asList("Resource");
1648 updatedContactId = "01345a";
1649 resourceDetails.setContactId(updatedContactId);
1650 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1651 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1653 updatedContactId = "0y000B";
1654 resourceDetails.setContactId(updatedContactId);
1655 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1656 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1658 updatedContactId = "Y1000b";
1659 resourceDetails.setContactId(updatedContactId);
1660 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1661 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1663 updatedContactId = "abxyzC";
1664 resourceDetails.setContactId(updatedContactId);
1665 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1666 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1668 updatedContactId = "cdXYZc";
1669 resourceDetails.setContactId(updatedContactId);
1670 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1671 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1673 updatedContactId = "efXY1D";
1674 resourceDetails.setContactId(updatedContactId);
1675 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1676 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1678 updatedContactId = "EFabcD";
1679 resourceDetails.setContactId(updatedContactId);
1680 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1681 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1683 updatedContactId = "EFABCD";
1684 resourceDetails.setContactId(updatedContactId);
1685 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1686 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1688 updatedContactId = "EFABC1";
1689 resourceDetails.setContactId(updatedContactId);
1690 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1691 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1693 updatedContactId = "efui1D";
1694 resourceDetails.setContactId(updatedContactId);
1695 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1696 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1698 updatedContactId = "efui1!";
1699 resourceDetails.setContactId(updatedContactId);
1700 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1701 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1703 updatedContactId = "ef555!";
1704 resourceDetails.setContactId(updatedContactId);
1705 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1706 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1708 updatedContactId = ",f555";
1709 resourceDetails.setContactId(updatedContactId);
1710 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1711 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1713 updatedContactId = "EF55.5";
1714 resourceDetails.setContactId(updatedContactId);
1715 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1716 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1718 // update resource contactId metadata: extended character set (128–255)
1719 resourceDetails.setContactId(extendedCharsStringBuilder());
1720 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1721 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1723 // update resource contactId metadata: null
1724 updatedContactId = null;
1725 resourceDetails.setContactId(updatedContactId);
1726 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1727 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1732 public void UpdateResource_TagsFieldValidation() throws Exception {
1733 RestResponse updatedRestResponse;
1734 // define and create resource
1736 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1737 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1738 String uniqueId = resourceDetails.getUniqueId();
1740 String updatedTagField = "";
1741 ArrayList<String> resourceTags = new ArrayList<String>();
1742 resourceTags.add(updatedTagField);
1744 resourceDetails.setTags(resourceTags);
1745 List<String> variables = Arrays.asList("Resource", "tag");
1746 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1747 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, updatedRestResponse.getResponse());
1749 // update resource tags metadata: empty
1750 resourceTags = new ArrayList<String>();
1752 resourceDetails.setTags(resourceTags);
1753 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1754 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List, updatedRestResponse.getResponse());
1756 // update resource description metadata: 1 characters
1757 updatedTagField = "A";
1758 resourceTags = new ArrayList<String>();
1759 resourceTags.add(updatedTagField);
1760 resourceTags.add(resourceDetails.getName());
1762 resourceDetails.setTags(resourceTags);
1763 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1764 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1765 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1766 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1767 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1769 // OK - tag up to 50 chars
1770 updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
1771 resourceTags.add(updatedTagField);
1772 resourceDetails.setTags(resourceTags);
1773 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1774 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1775 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1776 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1777 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1779 // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
1780 String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
1781 String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
1782 String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
1783 String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
1784 String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
1785 String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
1786 String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
1787 String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
1788 String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
1789 String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
1790 String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
1791 String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
1792 String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
1793 String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
1794 String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
1795 String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
1796 String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
1797 String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
1798 String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
1800 resourceTags = new ArrayList<String>();
1801 resourceTags.add(updatedTagField);
1802 resourceTags.add(updatedTagField1);
1803 resourceTags.add(updatedTagField2);
1804 resourceTags.add(updatedTagField3);
1805 resourceTags.add(updatedTagField4);
1806 resourceTags.add(updatedTagField5);
1807 resourceTags.add(updatedTagField6);
1808 resourceTags.add(updatedTagField7);
1809 resourceTags.add(updatedTagField8);
1810 resourceTags.add(updatedTagField9);
1811 resourceTags.add(updatedTagField10);
1812 resourceTags.add(updatedTagField11);
1813 resourceTags.add(updatedTagField12);
1814 resourceTags.add(updatedTagField13);
1815 resourceTags.add(updatedTagField14);
1816 resourceTags.add(updatedTagField15);
1817 resourceTags.add(updatedTagField16);
1818 resourceTags.add(updatedTagField17);
1819 resourceTags.add(updatedTagField18);
1820 resourceTags.add(updatedTagField19);
1821 resourceTags.add(resourceDetails.getName());
1823 resourceDetails.setTags(resourceTags);
1824 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1825 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1826 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1827 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1828 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1830 // Add another tag-exceeds limit
1831 resourceTags.add("d");
1832 resourceDetails.setTags(resourceTags);
1833 ArrayList<String> myArray = new ArrayList<String>();
1834 myArray.add(0, "1024");
1835 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1836 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray, updatedRestResponse.getResponse());
1838 // Tag exceeds limit - 51
1839 resourceTags = new ArrayList<String>();
1840 updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
1841 resourceTags.add(updatedTagField);
1842 resourceTags.add(resourceDetails.getName());
1844 resourceDetails.setTags(resourceTags);
1846 myArray.add(0, "50");
1847 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1848 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray, updatedRestResponse.getResponse());
1853 public void UpdateResource_DesriptionFieldValidation() throws Exception {
1854 // define and create resource
1855 RestResponse updatedRestResponse;
1857 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1858 String uniqueId = resourceDetails.getUniqueId();
1859 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1860 List<String> resource = new ArrayList<>();
1861 resource.add("Resource");
1862 // update resource description metadata: 0 characters
1863 String updatedDescription = "";
1865 resourceDetails.setDescription(updatedDescription);
1866 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1867 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, updatedRestResponse.getResponse());
1869 // update resource description metadata: null
1870 updatedDescription = null;
1872 resourceDetails.setDescription(updatedDescription);
1873 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1874 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, updatedRestResponse.getResponse());
1876 // update resource description metadata: 1 characters
1877 updatedDescription = "A";
1879 resourceDetails.setDescription(updatedDescription);
1880 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1881 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1882 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1883 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1884 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1886 // update resource description metadata: 1024 characters
1887 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines." + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
1888 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
1889 + "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."
1890 + "The longest quills grow from its shoulders to about a third of the animal's length." + "Its tail is covered in short, hollow quills that can rattle when threatened."
1891 + "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."
1892 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
1893 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
1895 resourceDetails.setDescription(updatedDescription);
1896 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1897 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1898 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1899 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1900 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1902 // update resource description metadata: 1025 characters
1903 updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines." + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
1904 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
1905 + "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."
1906 + "The longest quills grow from its shoulders to about a third of the animal's length." + "Its tail is covered in short, hollow quills that can rattle when threatened."
1907 + "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."
1908 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
1909 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
1911 resourceDetails.setDescription(updatedDescription);
1912 resource.add(1, "1024");
1913 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1914 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource, updatedRestResponse.getResponse());
1919 public void UpdateResource_TagsFormatValidation() throws Exception {
1920 char[] notValidCharsArray = getTagInValidFormatChars();
1922 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1923 assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
1924 String resourceName = resourceDetails.getName();
1926 // update tag details
1927 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1928 ArrayList<String> resourceTags = new ArrayList<String>();
1930 String updatedTagField;
1931 RestResponse updatedRestResponse;
1932 List<String> variables = Arrays.asList("Resource", "tag");
1934 for (int i = 0; i < notValidCharsArray.length; i++) {
1935 updatedTagField = "UpdatedTag" + notValidCharsArray[i];
1936 resourceTags = new ArrayList<String>();
1937 resourceTags.add(updatedTagField);
1938 resourceTags.add(resourceDetails.getName());
1940 updatedResourceDetails.setTags(resourceTags);
1942 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1943 // validate response
1944 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1945 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1946 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, updatedRestResponse.getResponse());
1947 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
1948 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
1955 public void UpdateResourceCategory_negativeFlow() throws Exception {
1957 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1958 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
1959 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
1960 String uniqueID = resourceDetails.getUniqueId();
1962 // Update resource Category Successfully
1963 ResourceReqDetails updatedResourceDetails = resourceDetails;
1965 updatedResourceDetails.removeAllCategories();
1966 updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(), ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
1967 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1969 // validate response
1970 List<String> resourceList = new ArrayList<String>();
1971 resourceList.add(0, "Resource");
1972 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1973 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1974 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
1975 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
1977 // Updating resource category
1978 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
1979 updatedResourceDetails.addCategory("");
1980 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1981 // validate response
1982 resourceList = new ArrayList<String>();
1983 resourceList.add(0, "Resource");
1984 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1985 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1986 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
1987 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
1989 // Updating resource category
1990 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
1991 updatedResourceDetails.addCategory("XXXXXX");
1992 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1993 // validate response
1994 resourceList = new ArrayList<String>();
1995 resourceList.add(0, "Resource");
1996 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1997 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1998 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
1999 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2002 logger.debug("Changing resource life cycle ");
2003 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2004 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2006 // Update resource Category
2007 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2008 updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2009 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2011 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2012 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2013 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List, updatedRestResponse.getResponse());
2014 assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2017 logger.debug("Changing resource life cycle ");
2018 RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2019 assertNotNull("check response object is not null after checkout resource", checkoutResource);
2020 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2021 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2023 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2024 assertNotNull("check response object is not null after update resource", getRestResponse);
2025 parseResponseAndValidate(resourceDetails, getRestResponse);
2030 public void UpdateResourceCategorySuccessfully() throws Exception {
2032 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2033 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2034 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2036 // Update resource Category Successfully
2037 ResourceReqDetails updatedResourceDetails = resourceDetails;
2039 updatedResourceDetails.removeAllCategories();
2040 updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(), ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2041 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2043 // validate response
2044 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2045 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2046 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2047 // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2048 // updatedRestResponse);
2049 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2051 // validate category updated
2052 assertTrue(updatedResourceDetails.getCategories().get(0).getName().equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2054 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
2055 assertNotNull("check response object is not null after update resource", getRestResponse);
2056 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2058 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2064 public void Validation_UpdateIcon() throws Exception {
2065 // Fields to update (Forbidden)
2066 String _updatedIcon = "mySecondIcon.Jpg";
2068 // administrator permissions
2069 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2071 // define and create resource
2072 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2074 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2075 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2076 String resourceName = resourceDetails.getName();
2078 // update metadata details
2079 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2080 // change icon of metadata
2081 updatedResourceDetails.setIcon(_updatedIcon);
2083 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2085 // validate response
2086 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2087 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2088 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), Arrays.asList("Resource"), updatedRestResponse.getResponse());
2092 updatedResourceDetails.setIcon(_updatedIcon);
2093 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2094 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2095 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2096 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), Arrays.asList("Resource"), updatedRestResponse.getResponse());
2098 // get resource with original name. original metadata should be returned
2099 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, resourceDetails.getUniqueId());
2100 // validate response
2101 assertNotNull("check response object is not null after get resource", getRestResponse);
2102 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2103 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2105 // parse updated response to javaObject
2106 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
2107 // validate that metadata was not changed
2108 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2110 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), "0.1");
2115 public void UpdateResourceTypeSuccess() throws Exception {
2117 String newResourceType = ResourceTypeEnum.VL.toString();
2118 String currentResourceType = resourceDetails.getResourceType();
2119 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2120 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2121 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2123 resourceDetails.setResourceType(newResourceType);
2124 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2125 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2126 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2127 // assertTrue("Check resource type after update resource",
2128 // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2129 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2134 public void UpdateResourceTypeAndNameSuccess() throws Exception {
2136 String newResourceType = ResourceTypeEnum.VL.toString();
2137 String currentResourceType = resourceDetails.getResourceType();
2138 String newResourceName = "new Name";
2140 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2141 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2142 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2144 resourceDetails.setResourceType(newResourceType);
2145 resourceDetails.setName(newResourceName);
2146 List<String> tags = resourceDetails.getTags();
2147 tags.add(newResourceName);
2148 resourceDetails.setTags(tags);
2150 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2151 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2152 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2153 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2154 assertTrue("Check resource name after update resource", updatedResourceJavaObject.getName().equals(newResourceName));
2159 public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2161 String newResourceType = ResourceTypeEnum.VF.toString();
2162 String currentResourceType = resourceDetails.getResourceType();
2163 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2164 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2165 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2167 resourceDetails.setResourceType(newResourceType);
2168 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2169 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2170 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKOUT);
2171 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2172 currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2174 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2175 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2176 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2177 // assertTrue("Check resource type after update resource",
2178 // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2179 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2184 public void UpdateResourceTypeCheckInLCS() throws Exception {
2186 String resourceType = ResourceTypeEnum.VL.toString();
2187 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2188 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2189 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2191 resourceDetails.setResourceType(resourceType);
2192 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
2193 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2195 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2197 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2199 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2200 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2201 assertEquals("Check response code after create resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2203 List<String> variables = new ArrayList<>();
2204 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, updatedRestResponse.getResponse());
2209 public void UpdateResourceTypeCertifiedLCS() throws Exception {
2211 String resourceType = ResourceTypeEnum.VL.toString();
2212 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2213 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2214 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2216 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2217 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2219 resourceDetails.setResourceType(resourceType);
2220 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2222 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2224 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2225 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2226 assertEquals("Check response code after create resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2228 List<String> variables = new ArrayList<>();
2229 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, updatedRestResponse.getResponse());
2234 public void UpdateResourceTypeInvalidType() throws Exception {
2236 String resourceType = "INVALID TYPE";
2237 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2238 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2239 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2241 resourceDetails.setResourceType(resourceType);
2242 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2244 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2246 assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2247 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2248 assertEquals("Check response code after update resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2250 List<String> variables = new ArrayList<>();
2251 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables, updatedRestResponse.getResponse());