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()));
474 protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse) throws Exception {
475 // parse response to javaObject
476 Resource updatedResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
477 // validate request vs response
478 ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
481 public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails, String resourceVersion) {
483 ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
485 expectedResourceAuditJavaObject.setAction("Checkout");
486 expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
487 expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
488 expectedResourceAuditJavaObject.setStatus("200.0");
489 expectedResourceAuditJavaObject.setDesc("OK");
490 expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
491 expectedResourceAuditJavaObject.setResourceType("Resource");
492 expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
493 expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
494 expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
495 expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
497 return expectedResourceAuditJavaObject;
501 public enum FieldToValidate {
502 ContactId, Tags, VendorName, VendorRelease, Description
506 public void UpdateBy_postTest() throws Exception {
508 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
509 String resourceName = resourceDetails.getName();
511 // update resource - without changing resourceName
512 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
514 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
517 assertNotNull("check response object is not null after update resource", updatedRestResponse);
518 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
519 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
521 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
522 assertNotNull("check response object is not null after update resource", getRestResponse);
523 parseResponseAndValidate(resourceDetails, getRestResponse);
528 public void UpdateBy_getTest() throws Exception {
530 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
531 String resourceName = resourceDetails.getName();
533 // update resource - without changing resourceName
534 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
535 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
538 assertNotNull("check response object is not null after update resource", updatedRestResponse);
539 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
540 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
542 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
543 assertNotNull("check response object is not null after update resource", getRestResponse);
544 parseResponseAndValidate(resourceDetails, getRestResponse);
549 public void UpdateBy_deleteTest() throws Exception {
551 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
552 String resourceName = resourceDetails.getName();
554 // update resource - without changing resourceName
555 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
556 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "DELETE");
559 assertNotNull("check response object is not null after update resource", updatedRestResponse);
560 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
561 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
563 RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
564 assertNotNull("check response object is not null after update resource", getRestResponse);
565 parseResponseAndValidate(resourceDetails, getRestResponse);
572 public void UpdateWithInvaldJsonBodyTest() throws Exception {
574 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
575 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
576 String resourceId = resourceDetails.getUniqueId();
578 // update Descirption value
579 String description = "updatedDescription";
581 // send update with incompleted json, only description string
582 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails, resourceId);
585 assertNotNull("check response object is not null after update resource", updatedRestResponse);
586 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
587 assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
589 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
590 assertNotNull("check response object is not null after update resource", getRestResponse);
591 parseResponseAndValidate(resourceDetails, getRestResponse);
596 // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
599 // RestResponse restResponse = createResource(sdncModifierDetails,
601 // String resourceName = resourceDetails.getName();
603 // // new user parameters
604 // String userFirstName = "Kot";
605 // String userLastName = "Matroskin";
606 // String role = "ADMIN";
607 // User sdncUserDetails = new User(userFirstName, userLastName,
608 // httpCspUserId, email, role,null);
609 // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
610 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
612 // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
613 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
615 // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
616 // httpCspUserId, email,role,null);
617 // ResourceReqDetails updatedResourceDetails =
618 // defineUpdatedResourse(resourceName);
619 // RestResponse updatedRestResponse =
620 // ResourceRestUtils.updateResource(updatedResourceDetails,
621 // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
623 // // validate response
624 // assertNotNull("check response object is not null after update resource",
625 // updatedRestResponse);
626 // assertNotNull("check error code exists in response after update
627 // resource", updatedRestResponse.getErrorCode());
628 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
629 // Empty_List, updatedRestResponse.getResponse());
631 // RestResponse getRestResponse =
632 // ResourceRestUtils.getResource(sdncModifierDetails,
633 // resourceDetails.getUniqueId());
634 // assertNotNull("check response object is not null after update resource",
636 // parseResponseAndValidate(resourceDetails, getRestResponse);
642 public void UpdateResourceNameSensitiveTest() throws Exception {
643 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
644 String resourceBaseVersion = "0.1";
645 String resourceName = "Ab";
646 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
648 RestResponse response = null;
649 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
650 BaseRestUtils.checkDeleteResponse(response);
651 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
652 BaseRestUtils.checkDeleteResponse(response);
654 RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
655 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
658 logger.debug("Changing resource life cycle ");
659 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
660 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
662 // String resourceCertifyVersion = "0.1";
663 logger.debug("Changing resource life cycle ");
664 checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
665 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
667 updatedResourceDetails.setName("ABC_-bt.aT");
668 ArrayList<String> resourceTag = new ArrayList<String>();
669 resourceTag.add(0, "ABC_-bt.aT");
670 updatedResourceDetails.setTags(resourceTag);
671 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
672 assertNotNull("check response object is not null after update resource", updatedRestResponse);
673 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
674 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
675 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
678 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
679 BaseRestUtils.checkDeleteResponse(response);
680 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
681 BaseRestUtils.checkDeleteResponse(response);
686 public void UpdateIcon_InegativeFlow() throws Exception {
688 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
689 String resourceName = resourceDetails.getName();
691 List<String> resourceList = new ArrayList<String>();
692 resourceList.add(0, "Resource");
693 // check InValid Characters
694 char[] notValidCharsArray = new char[59];
695 notValidCharsArray = getInValidChars();
696 // update metadata details
697 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
698 RestResponse updatedRestResponse;
700 for (int i = 0; i < notValidCharsArray.length; i++) {
701 // change icon of metadata
702 updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
704 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
706 assertNotNull("check response object is not null after update resource", updatedRestResponse);
707 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
708 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList, updatedRestResponse.getResponse());
709 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
710 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
715 String updateIcon = "";
716 updatedResourceDetails.setIcon(updateIcon);
717 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
718 assertNotNull("check response object is not null after update resource", updatedRestResponse);
719 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
720 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList, updatedRestResponse.getResponse());
722 // Icon length more then 25 characters
723 resourceList.add(1, "25");
724 updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
725 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
727 assertNotNull("check response object is not null after update resource", updatedRestResponse);
728 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
729 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList, updatedRestResponse.getResponse());
730 assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
731 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
733 // get resource with original name. original metadata should be returned
734 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
736 assertNotNull("check response object is not null after get resource", getRestResponse);
737 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
738 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
740 // parse updated response to javaObject
741 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
742 // validate that metadata was not changed
743 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
748 public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
750 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
751 String resourceBaseVersion = "0.1";
754 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
755 String resourceName = resourceDetails.getName();
757 ResourceReqDetails updatedResourceDetails = defineResourse();
758 updatedResourceDetails.setName("updatedResourceName");
759 List<String> tags = updatedResourceDetails.getTags();
761 for (Iterator<String> iter = tags.listIterator(); iter.hasNext();) {
762 String a = iter.next();
763 if (a.equals("updatedResourceName")) {
768 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
770 List<String> resourceList = new ArrayList<String>();
771 assertNotNull("check response object is not null after update resource", updatedRestResponse);
772 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
773 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(), resourceList, updatedRestResponse.getResponse());
774 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
776 // get resource with original name. original metadata should be returned
777 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
779 assertNotNull("check response object is not null after get resource", getRestResponse);
780 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
781 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
782 // parse updated response to javaObject
783 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
784 // validate that metadata was not changed
785 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
790 public void UpdateResourceName_negativeFlow() throws Exception {
791 // The validation are done in Tag's validation
792 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
794 RestResponse updatedRestResponse;
795 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
796 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
797 String uniqueId = resourceDetails.getUniqueId();
798 String resourceName = resourceDetails.getName();
799 // check InValid Characters
800 char[] notValidCharsArray = new char[59];
801 notValidCharsArray = getInValidChars();
802 ArrayList<String> resource_Name = new ArrayList<String>();
803 List<String> resourceList = new ArrayList<String>();
805 ArrayList<String> resourceTags = new ArrayList<String>();
806 resourceList.add(0, "Resource");
808 // update metadata details
809 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
810 for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
811 if (i != 1 && i != 46 && /*
812 * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
813 */ i != 31) // space ("") and dot(.)
815 // change resourceName parameter
816 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
817 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
818 updatedResourceDetails.setTags(resource_Name);
819 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, uniqueId, "");
821 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
822 // Empty_List, updatedRestResponse.getResponse());
823 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList, updatedRestResponse.getResponse());
828 // resourceName length more then 50 characters
829 // Duplicate tags are allowed and should be de-duplicated by server side
830 resource_Name.add(resourceName);
831 resource_Name.add("tag1");
832 resource_Name.add("tag1");
833 resource_Name.add("tag2");
834 resource_Name.add("tag2");
836 resourceList.add(1, "1024");
837 // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
838 updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
839 // resource_Name.add("123456789012345678901234567890123456789012345678901");
840 updatedResourceDetails.setTags(resource_Name);
841 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, uniqueId, "");
843 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList, updatedRestResponse.getResponse());
845 // get resource with original name. original metadata should be returned
846 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, resourceDetails.getUniqueId());
848 assertNotNull("check response object is not null after get resource", getRestResponse);
849 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
850 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
851 // parse updated response to javaObject
852 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
853 // validate that metadata was not changed
854 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
857 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), "0.1");
858 BaseRestUtils.checkDeleteResponse(response);
862 public void UpdateResourceInformation_NotCheckedOut() throws Exception {
864 String resourceBaseVersion = "0.1";
865 List<String> resourceList = new ArrayList<String>();
867 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
868 String resourceName = resourceDetails.getName();
871 logger.debug("Changing resource life cycle ");
872 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
873 assertNotNull("check response object is not null after checkout resource", checkoutResource);
874 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
875 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
877 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
879 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
880 assertNotNull("check response object is not null after update resource", updatedRestResponse);
881 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
882 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, updatedRestResponse.getResponse());
883 assertEquals("Check response code after updating resource icon", 409, updatedRestResponse.getErrorCode().intValue());
885 // get resource with original name. original metadata should be returned
886 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
888 assertNotNull("check response object is not null after get resource", getRestResponse);
889 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
890 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
892 // parse updated response to javaObject
893 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
894 // validate that metadata was not changed
895 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
900 public void UpdateResourceInformation_resourceVersion_11() throws Exception {
902 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
903 String resourceBaseVersion = "0.1";
906 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
907 String resourceName = resourceDetails.getName();
909 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
913 logger.debug("Changing resource life cycle ");
914 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
915 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
917 logger.debug("Changing resource life cycle ");
918 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
919 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
921 logger.debug("Changing resource life cycle ");
922 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
923 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
925 logger.debug("Changing resource life cycle ");
926 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
927 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
929 String resourceCertifyVersion = "1.0";
930 logger.debug("Changing resource life cycle ");
931 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
932 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
934 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
936 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
938 List<String> resourceList = new ArrayList<String>();
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 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, updatedRestResponse.getResponse());
942 // assertEquals("Check response code after updating resource icon", 409,
943 // updatedRestResponse.getErrorCode().intValue());
945 // get resource with original name. original metadata should be returned
946 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
948 assertNotNull("check response object is not null after get resource", getRestResponse);
950 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
952 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
953 // parse updated response to javaObject
954 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
955 // validate that metadata was not changed
956 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
961 public void UpdateResourceInformation_resourceVersion_02() throws Exception {
963 String resourceBaseVersion = "0.1";
966 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
967 String resourceName = resourceDetails.getName();
969 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
973 logger.debug("Changing resource life cycle ");
974 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
975 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
977 // String resourceCertifyVersion = "0.1";
978 logger.debug("Changing resource life cycle ");
979 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
980 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
982 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
984 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
986 assertNotNull("check response object is not null after update resource", updatedRestResponse);
987 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
988 assertEquals("Check response code after updating resource icon", 200, updatedRestResponse.getErrorCode().intValue());
990 // get resource with original name. original metadata should be returned
991 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
993 assertNotNull("check response object is not null after get resource", getRestResponse);
994 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
995 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
997 // parse updated response to javaObject
998 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
999 // validate that metadata was not changed
1000 ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
1003 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
1004 BaseRestUtils.checkDeleteResponse(response);
1005 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
1006 BaseRestUtils.checkDeleteResponse(response);
1011 public void UpdateResourceIcon_resourceVersion_11() throws Exception {
1012 // Can be changed only if major version is "0".
1014 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1015 String resourceBaseVersion = "0.1";
1018 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1019 String resourceName = resourceDetails.getName();
1021 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1025 logger.debug("Changing resource life cycle ");
1026 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1027 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1029 logger.debug("Changing resource life cycle ");
1030 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1031 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1033 logger.debug("Changing resource life cycle ");
1034 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1035 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1037 logger.debug("Changing resource life cycle ");
1038 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1039 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1041 String resourceCertifyVersion = "1.0";
1042 logger.debug("Changing resource life cycle ");
1043 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1044 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1046 // ResourceReqDetails updatedResourceDetails =
1047 // defineUpdatedResourse(resourceName);
1048 ResourceReqDetails updatedResourceDetails = defineResourse();
1049 // updatedResourceDetails.setVendorName("updatedVandorName");
1050 updatedResourceDetails.setIcon("updatedIcon");
1052 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1053 // validate response
1054 List<String> resourceList = new ArrayList<String>();
1055 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1057 // get resource with original name. original metadata should be returned
1058 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1059 // validate response
1060 assertNotNull("check response object is not null after get resource", getRestResponse);
1061 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1062 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1063 // parse updated response to javaObject
1064 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1065 // validate that metadata was not changed
1066 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1071 public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1072 // Can be changed only if the major resource version is "0".
1073 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1074 String resourceBaseVersion = "0.1";
1077 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1078 String resourceName = resourceDetails.getName();
1080 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1084 logger.debug("Changing resource life cycle ");
1085 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1086 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1088 logger.debug("Changing resource life cycle ");
1089 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1090 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1092 logger.debug("Changing resource life cycle ");
1093 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1094 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1096 logger.debug("Changing resource life cycle ");
1097 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1098 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1100 String resourceCertifyVersion = "1.0";
1101 logger.debug("Changing resource life cycle ");
1102 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1103 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1105 // ResourceReqDetails updatedResourceDetails =
1106 // defineUpdatedResourse(resourceName);
1107 ResourceReqDetails updatedResourceDetails = defineResourse();
1109 updatedResourceDetails.setVendorName("updatedVandorName");
1111 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1112 // validate response
1113 List<String> resourceList = new ArrayList<String>();
1114 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1115 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1116 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1117 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
1119 // get resource with original name. original metadata should be returned
1120 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1121 // validate response
1122 assertNotNull("check response object is not null after get resource", getRestResponse);
1123 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1124 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1125 // parse updated response to javaObject
1126 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1127 // validate that metadata was not changed
1128 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1133 public void UpdateResourceName_resourceVersion_11() throws Exception {
1134 // Can be changed only if the major resource version is "0".
1135 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1136 String resourceBaseVersion = "0.1";
1139 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1140 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1141 String resourceName = resourceDetails.getName();
1143 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1147 logger.debug("Changing resource life cycle ");
1148 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1149 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1151 logger.debug("Changing resource life cycle ");
1152 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1153 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1155 logger.debug("Changing resource life cycle ");
1156 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1157 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1159 logger.debug("Changing resource life cycle ");
1160 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1161 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1163 String resourceCertifyVersion = "1.0";
1164 logger.debug("Changing resource life cycle ");
1165 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1166 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1169 * //ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); ResourceReqDetails updatedResourceDetails = defineResourse();
1171 * updatedResourceDetails.setResourceName("updatedResourceName"); updatedResourceDetails.setIcon("updatedResourceName");
1173 resourceDetails.setName("updatedResourceName");
1174 List<String> tagList = new ArrayList<String>();
1175 tagList.add(0, "updatedResourceName");
1176 resourceDetails.setTags(tagList);
1178 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1179 // validate response
1180 List<String> resourceList = new ArrayList<String>();
1181 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1182 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1183 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1188 public void UpdateResourceTag_resourceVersion_11() throws Exception {
1189 // Tag Can be updated when major version is "0".
1190 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1191 String resourceBaseVersion = "0.1";
1194 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1195 String resourceName = resourceDetails.getName();
1197 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1201 logger.debug("Changing resource life cycle ");
1202 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1203 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1205 logger.debug("Changing resource life cycle ");
1206 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1207 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1209 logger.debug("Changing resource life cycle ");
1210 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1211 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1213 logger.debug("Changing resource life cycle ");
1214 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1215 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1217 String resourceCertifyVersion = "1.0";
1218 logger.debug("Changing resource life cycle ");
1219 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1220 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1222 // ResourceReqDetails updatedResourceDetails =
1223 // defineUpdatedResourse(resourceName);
1224 ResourceReqDetails updatedResourceDetails = defineResourse();
1225 // updatedResourceDetails.setVendorName("updatedVandorName");
1227 ArrayList<String> resourceTags = new ArrayList<String>();
1228 resourceTags.add("NewTag");
1229 resourceTags.add(resourceDetails.getName());
1231 updatedResourceDetails.setTags(resourceTags);
1233 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1234 // validate response
1235 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1236 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1237 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1239 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1240 assertNotNull("check response object is not null after update resource", getRestResponse);
1241 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1246 public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1248 // Tag, contactId, vendorRelease,tags And description - Can be also
1249 // updated when major version is NOT "0".
1250 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1251 String resourceBaseVersion = "0.1";
1254 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1256 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1260 logger.debug("Changing resource life cycle ");
1261 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1262 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1264 logger.debug("Changing resource life cycle ");
1265 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1266 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1268 logger.debug("Changing resource life cycle ");
1269 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1270 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1272 logger.debug("Changing resource life cycle ");
1273 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1274 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1276 String resourceCertifyVersion = "1.0";
1277 logger.debug("Changing resource life cycle ");
1278 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1279 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1281 // ResourceReqDetails updatedResourceDetails =
1282 // defineUpdatedResourse(resourceName);
1283 ResourceReqDetails updatedResourceDetails = defineResourse();
1284 // updatedResourceDetails.setVendorName("updatedVandorName");
1286 // updated allowed parameters when major resource version is NOT "0"
1287 ArrayList<String> resourceTags = new ArrayList<String>();
1288 resourceTags.add("NewTag");
1289 resourceTags.add(resourceDetails.getName());
1290 updatedResourceDetails.setTags(resourceTags);
1291 updatedResourceDetails.setDescription("UpdatedDescription");
1292 updatedResourceDetails.setVendorRelease("5.1");
1293 updatedResourceDetails.setContactId("bt750h");
1295 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1296 // validate response
1297 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1298 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1299 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1301 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1302 assertNotNull("check response object is not null after update resource", getRestResponse);
1303 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1308 public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1309 // DerivedFrom parameter - Can be updated when major version is "0".
1310 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1311 String resourceBaseVersion = "0.1";
1314 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1315 String resourceName = resourceDetails.getName();
1317 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1321 logger.debug("Changing resource life cycle ");
1322 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1323 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1325 logger.debug("Changing resource life cycle ");
1326 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1327 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1329 logger.debug("Changing resource life cycle ");
1330 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1331 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1333 logger.debug("Changing resource life cycle ");
1334 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1335 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1337 String resourceCertifyVersion = "1.0";
1338 logger.debug("Changing resource life cycle ");
1339 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1340 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1342 // ResourceReqDetails updatedResourceDetails =
1343 // defineUpdatedResourse(resourceName);
1344 ResourceReqDetails updatedResourceDetails = defineResourse();
1345 ArrayList<String> drivenFrom = new ArrayList<String>();
1346 drivenFrom.add(0, "tosca.nodes.Container.Application");
1347 updatedResourceDetails.setDerivedFrom(drivenFrom);
1349 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1350 // validate response
1351 List<String> resourceList = new ArrayList<String>();
1352 ResourceRestUtils.checkSuccess(updatedRestResponse);
1354 // get resource with original name. original metadata should be returned
1355 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1356 // validate response
1357 assertNotNull("check response object is not null after get resource", getRestResponse);
1358 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1359 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1360 // parse updated response to javaObject
1361 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1362 // validate that metadata was not changed
1363 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1368 public void UpdateResource_vendorNameValidation() throws Exception {
1370 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1371 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1372 String updatedVendorName = "";
1373 String uniqueId = resourceDetails.getUniqueId();
1374 resourceDetails.setVendorName(updatedVendorName);
1375 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1376 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1377 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1378 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1380 // update resource vendorName metadata: 1 characters
1381 updatedVendorName = " ";
1383 resourceDetails.setVendorName(updatedVendorName);
1384 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1385 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1386 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1387 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1389 // update resource vendorName metadata: 25 characters
1390 updatedVendorName = "Verification and validati";
1392 resourceDetails.setVendorName(updatedVendorName);
1393 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1394 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1395 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1396 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1397 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1399 // update resource vendorName metadata: 26 characters
1400 updatedVendorName = "Verification and validatii";
1402 List<String> myList = new ArrayList<String>();
1403 myList.add(0, "25");
1404 resourceDetails.setVendorName(updatedVendorName);
1405 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1406 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1407 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList, updatedRestResponse.getResponse());
1409 // update resource VendorRelease metadata: forbidden characters
1410 updatedVendorName = "A1<";
1412 resourceDetails.setVendorName(updatedVendorName);
1413 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1414 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1415 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1417 updatedVendorName = "A1>";
1419 resourceDetails.setVendorName(updatedVendorName);
1420 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1421 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1422 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1424 updatedVendorName = "A1:";
1426 resourceDetails.setVendorName(updatedVendorName);
1427 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1428 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1429 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1431 updatedVendorName = "A1\"";
1433 resourceDetails.setVendorName(updatedVendorName);
1434 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1435 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1436 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1438 updatedVendorName = "A1/";
1440 resourceDetails.setVendorName(updatedVendorName);
1441 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1442 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1443 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1445 updatedVendorName = "A1\\";
1447 resourceDetails.setVendorName(updatedVendorName);
1448 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1449 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1450 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1452 updatedVendorName = "A1|";
1454 resourceDetails.setVendorName(updatedVendorName);
1455 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1456 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1457 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1459 updatedVendorName = "A1?";
1461 resourceDetails.setVendorName(updatedVendorName);
1462 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1463 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1464 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1466 updatedVendorName = "A1*";
1468 resourceDetails.setVendorName(updatedVendorName);
1469 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1470 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1471 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1473 // update resource vendorName metadata: null
1474 updatedVendorName = null;
1476 resourceDetails.setVendorName(updatedVendorName);
1477 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1478 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1479 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1484 public void UpdateResource_vendorReleaseValidation() throws Exception {
1486 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1487 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1488 RestResponse updatedRestResponse;
1489 String uniqueId = resourceDetails.getUniqueId();
1490 String updatedVendorRelease;
1491 // set VendorRelease
1493 // update resource VendorRelease metadata: 1 characters
1494 updatedVendorRelease = "1";
1495 // set VendorRelease
1496 resourceDetails.setVendorRelease(updatedVendorRelease);
1497 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1498 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1499 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1500 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1501 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1503 // update resource VendorRelease metadata: 25 characters
1504 updatedVendorRelease = "(!#1.00000000000000000000";
1505 // set VendorRelease
1506 resourceDetails.setVendorRelease(updatedVendorRelease);
1507 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1508 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1509 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1510 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1511 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1513 // update resource VendorRelease metadata: 26 characters
1514 updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1515 resourceDetails.setVendorRelease(updatedVendorRelease);
1516 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1517 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(), Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1519 // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1520 // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1521 // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1523 // update resource VendorRelease metadata: forbidden characters
1524 updatedVendorRelease = "A1<";
1525 // set VendorRelease
1526 resourceDetails.setVendorRelease(updatedVendorRelease);
1527 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1528 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1530 updatedVendorRelease = "A1>";
1531 // set VendorRelease
1532 resourceDetails.setVendorRelease(updatedVendorRelease);
1533 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1534 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1536 updatedVendorRelease = "A1:";
1537 // set VendorRelease
1538 resourceDetails.setVendorRelease(updatedVendorRelease);
1539 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1540 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1542 updatedVendorRelease = "A1\"";
1543 // set VendorRelease
1544 resourceDetails.setVendorRelease(updatedVendorRelease);
1545 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1546 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1548 updatedVendorRelease = "A1/";
1549 // set VendorRelease
1550 resourceDetails.setVendorRelease(updatedVendorRelease);
1551 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1552 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1554 updatedVendorRelease = "A1\\";
1555 // set VendorRelease
1556 resourceDetails.setVendorRelease(updatedVendorRelease);
1557 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1558 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1560 updatedVendorRelease = "A1|";
1561 // set VendorRelease
1562 resourceDetails.setVendorRelease(updatedVendorRelease);
1563 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1564 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1566 updatedVendorRelease = "A1?";
1567 // set VendorRelease
1568 resourceDetails.setVendorRelease(updatedVendorRelease);
1569 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1570 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1572 updatedVendorRelease = "A1*";
1573 // set VendorRelease
1574 resourceDetails.setVendorRelease(updatedVendorRelease);
1575 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1576 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1578 // update resource VendorRelease metadata: null
1579 updatedVendorRelease = null;
1580 // set VendorRelease
1581 resourceDetails.setVendorRelease(updatedVendorRelease);
1582 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1583 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1584 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1589 public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1610 RestResponse updatedRestResponse;
1612 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1613 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1614 String uniqueId = resourceDetails.getUniqueId();
1616 List<String> myList = new ArrayList<String>();
1617 myList.add(0, "Resource");
1618 String updatedContactId = "";
1619 resourceDetails.setContactId(updatedContactId);
1621 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1622 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1624 updatedContactId = "ab12345";
1625 resourceDetails.setContactId(updatedContactId);
1626 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1627 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1629 updatedContactId = " ";
1630 resourceDetails.setContactId(updatedContactId);
1631 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1632 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1634 updatedContactId = "ab 50h";
1635 resourceDetails.setContactId(updatedContactId);
1636 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1637 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1639 updatedContactId = "ab123c";
1640 resourceDetails.setContactId(updatedContactId);
1641 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1642 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1643 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1644 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1646 updatedContactId = "cd789E";
1647 resourceDetails.setContactId(updatedContactId);
1648 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1649 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1650 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1652 resourceDetails.setContactId(updatedContactId.toLowerCase());
1653 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1655 updatedContactId = "ef4567";
1656 resourceDetails.setContactId(updatedContactId);
1657 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1658 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1659 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1660 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1661 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1663 updatedContactId = "AA012A";
1664 resourceDetails.setContactId(updatedContactId);
1665 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1666 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1667 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1668 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1670 resourceDetails.setContactId(updatedContactId.toLowerCase());
1671 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1673 updatedContactId = "CD012c";
1674 resourceDetails.setContactId(updatedContactId);
1675 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1676 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1677 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1678 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1680 resourceDetails.setContactId(updatedContactId.toLowerCase());
1681 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1683 updatedContactId = "EF0123";
1684 resourceDetails.setContactId(updatedContactId);
1685 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1686 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1687 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1688 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1690 resourceDetails.setContactId(updatedContactId.toLowerCase());
1691 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1693 ////////////////////////////// **************//////////////////////////////
1694 List<String> resource = Arrays.asList("Resource");
1695 updatedContactId = "01345a";
1696 resourceDetails.setContactId(updatedContactId);
1697 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1698 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1700 updatedContactId = "0y000B";
1701 resourceDetails.setContactId(updatedContactId);
1702 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1703 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1705 updatedContactId = "Y1000b";
1706 resourceDetails.setContactId(updatedContactId);
1707 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1708 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1710 updatedContactId = "abxyzC";
1711 resourceDetails.setContactId(updatedContactId);
1712 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1713 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1715 updatedContactId = "cdXYZc";
1716 resourceDetails.setContactId(updatedContactId);
1717 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1718 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1720 updatedContactId = "efXY1D";
1721 resourceDetails.setContactId(updatedContactId);
1722 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1723 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1725 updatedContactId = "EFabcD";
1726 resourceDetails.setContactId(updatedContactId);
1727 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1728 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1730 updatedContactId = "EFABCD";
1731 resourceDetails.setContactId(updatedContactId);
1732 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1733 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1735 updatedContactId = "EFABC1";
1736 resourceDetails.setContactId(updatedContactId);
1737 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1738 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1740 updatedContactId = "efui1D";
1741 resourceDetails.setContactId(updatedContactId);
1742 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1743 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1745 updatedContactId = "efui1!";
1746 resourceDetails.setContactId(updatedContactId);
1747 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1748 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1750 updatedContactId = "ef555!";
1751 resourceDetails.setContactId(updatedContactId);
1752 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1753 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1755 updatedContactId = ",f555";
1756 resourceDetails.setContactId(updatedContactId);
1757 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1758 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1760 updatedContactId = "EF55.5";
1761 resourceDetails.setContactId(updatedContactId);
1762 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1763 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1765 // update resource contactId metadata: extended character set (128–255)
1766 resourceDetails.setContactId(extendedCharsStringBuilder());
1767 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1768 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1770 // update resource contactId metadata: null
1771 updatedContactId = null;
1772 resourceDetails.setContactId(updatedContactId);
1773 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1774 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1779 public void UpdateResource_TagsFieldValidation() throws Exception {
1780 RestResponse updatedRestResponse;
1781 // define and create resource
1783 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1784 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1785 String uniqueId = resourceDetails.getUniqueId();
1787 String updatedTagField = "";
1788 ArrayList<String> resourceTags = new ArrayList<String>();
1789 resourceTags.add(updatedTagField);
1791 resourceDetails.setTags(resourceTags);
1792 List<String> variables = Arrays.asList("Resource", "tag");
1793 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1794 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, updatedRestResponse.getResponse());
1796 // update resource tags metadata: empty
1797 resourceTags = new ArrayList<String>();
1799 resourceDetails.setTags(resourceTags);
1800 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1801 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List, updatedRestResponse.getResponse());
1803 // update resource description metadata: 1 characters
1804 updatedTagField = "A";
1805 resourceTags = new ArrayList<String>();
1806 resourceTags.add(updatedTagField);
1807 resourceTags.add(resourceDetails.getName());
1809 resourceDetails.setTags(resourceTags);
1810 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1811 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1812 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1813 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1814 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1816 // OK - tag up to 50 chars
1817 updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
1818 resourceTags.add(updatedTagField);
1819 resourceDetails.setTags(resourceTags);
1820 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1821 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1822 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1823 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1824 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1826 // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
1827 String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
1828 String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
1829 String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
1830 String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
1831 String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
1832 String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
1833 String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
1834 String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
1835 String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
1836 String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
1837 String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
1838 String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
1839 String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
1840 String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
1841 String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
1842 String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
1843 String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
1844 String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
1845 String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
1847 resourceTags = new ArrayList<String>();
1848 resourceTags.add(updatedTagField);
1849 resourceTags.add(updatedTagField1);
1850 resourceTags.add(updatedTagField2);
1851 resourceTags.add(updatedTagField3);
1852 resourceTags.add(updatedTagField4);
1853 resourceTags.add(updatedTagField5);
1854 resourceTags.add(updatedTagField6);
1855 resourceTags.add(updatedTagField7);
1856 resourceTags.add(updatedTagField8);
1857 resourceTags.add(updatedTagField9);
1858 resourceTags.add(updatedTagField10);
1859 resourceTags.add(updatedTagField11);
1860 resourceTags.add(updatedTagField12);
1861 resourceTags.add(updatedTagField13);
1862 resourceTags.add(updatedTagField14);
1863 resourceTags.add(updatedTagField15);
1864 resourceTags.add(updatedTagField16);
1865 resourceTags.add(updatedTagField17);
1866 resourceTags.add(updatedTagField18);
1867 resourceTags.add(updatedTagField19);
1868 resourceTags.add(resourceDetails.getName());
1870 resourceDetails.setTags(resourceTags);
1871 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1872 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1873 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1874 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1875 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1877 // Add another tag-exceeds limit
1878 resourceTags.add("d");
1879 resourceDetails.setTags(resourceTags);
1880 ArrayList<String> myArray = new ArrayList<String>();
1881 myArray.add(0, "1024");
1882 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1883 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray, updatedRestResponse.getResponse());
1885 // Tag exceeds limit - 51
1886 resourceTags = new ArrayList<String>();
1887 updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
1888 resourceTags.add(updatedTagField);
1889 resourceTags.add(resourceDetails.getName());
1891 resourceDetails.setTags(resourceTags);
1893 myArray.add(0, "50");
1894 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1895 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray, updatedRestResponse.getResponse());
1900 public void UpdateResource_DesriptionFieldValidation() throws Exception {
1901 // define and create resource
1902 RestResponse updatedRestResponse;
1904 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1905 String uniqueId = resourceDetails.getUniqueId();
1906 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1907 List<String> resource = new ArrayList<>();
1908 resource.add("Resource");
1909 // update resource description metadata: 0 characters
1910 String updatedDescription = "";
1912 resourceDetails.setDescription(updatedDescription);
1913 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1914 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, updatedRestResponse.getResponse());
1916 // update resource description metadata: null
1917 updatedDescription = null;
1919 resourceDetails.setDescription(updatedDescription);
1920 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1921 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, updatedRestResponse.getResponse());
1923 // update resource description metadata: 1 characters
1924 updatedDescription = "A";
1926 resourceDetails.setDescription(updatedDescription);
1927 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1928 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1929 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1930 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1931 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1933 // update resource description metadata: 1024 characters
1934 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."
1935 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
1936 + "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."
1937 + "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."
1938 + "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."
1939 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
1940 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
1942 resourceDetails.setDescription(updatedDescription);
1943 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
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 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1947 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1949 // update resource description metadata: 1025 characters
1950 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."
1951 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
1952 + "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."
1953 + "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."
1954 + "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."
1955 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
1956 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
1958 resourceDetails.setDescription(updatedDescription);
1959 resource.add(1, "1024");
1960 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1961 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource, updatedRestResponse.getResponse());
1966 public void UpdateResource_TagsFormatValidation() throws Exception {
1967 char[] notValidCharsArray = getTagInValidFormatChars();
1969 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1970 assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
1971 String resourceName = resourceDetails.getName();
1973 // update tag details
1974 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1975 ArrayList<String> resourceTags = new ArrayList<String>();
1977 String updatedTagField;
1978 RestResponse updatedRestResponse;
1979 List<String> variables = Arrays.asList("Resource", "tag");
1981 for (int i = 0; i < notValidCharsArray.length; i++) {
1982 updatedTagField = "UpdatedTag" + notValidCharsArray[i];
1983 resourceTags = new ArrayList<String>();
1984 resourceTags.add(updatedTagField);
1985 resourceTags.add(resourceDetails.getName());
1987 updatedResourceDetails.setTags(resourceTags);
1989 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1990 // validate response
1991 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1992 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1993 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, updatedRestResponse.getResponse());
1994 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
1995 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
2002 public void UpdateResourceCategory_negativeFlow() throws Exception {
2004 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2005 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2006 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2007 String uniqueID = resourceDetails.getUniqueId();
2009 // Update resource Category Successfully
2010 ResourceReqDetails updatedResourceDetails = resourceDetails;
2012 updatedResourceDetails.removeAllCategories();
2013 updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(), ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2014 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2016 // validate response
2017 List<String> resourceList = new ArrayList<String>();
2018 resourceList.add(0, "Resource");
2019 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2020 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2021 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
2022 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2024 // Updating resource category
2025 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2026 updatedResourceDetails.addCategory("");
2027 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2028 // validate response
2029 resourceList = new ArrayList<String>();
2030 resourceList.add(0, "Resource");
2031 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2032 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2033 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
2034 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2036 // Updating resource category
2037 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2038 updatedResourceDetails.addCategory("XXXXXX");
2039 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2040 // validate response
2041 resourceList = new ArrayList<String>();
2042 resourceList.add(0, "Resource");
2043 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2044 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2045 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
2046 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2049 logger.debug("Changing resource life cycle ");
2050 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2051 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2053 // Update resource Category
2054 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2055 updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2056 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2058 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2059 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2060 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List, updatedRestResponse.getResponse());
2061 assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2064 logger.debug("Changing resource life cycle ");
2065 RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2066 assertNotNull("check response object is not null after checkout resource", checkoutResource);
2067 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2068 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2070 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2071 assertNotNull("check response object is not null after update resource", getRestResponse);
2072 parseResponseAndValidate(resourceDetails, getRestResponse);
2077 public void UpdateResourceCategorySuccessfully() throws Exception {
2079 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2080 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2081 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2083 // Update resource Category Successfully
2084 ResourceReqDetails updatedResourceDetails = resourceDetails;
2086 updatedResourceDetails.removeAllCategories();
2087 updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(), ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2088 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2090 // validate response
2091 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2092 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2093 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2094 // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2095 // updatedRestResponse);
2096 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2098 // validate category updated
2099 assertTrue(updatedResourceDetails.getCategories().get(0).getName().equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2101 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
2102 assertNotNull("check response object is not null after update resource", getRestResponse);
2103 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2105 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2111 public void Validation_UpdateIcon() throws Exception {
2112 // Fields to update (Forbidden)
2113 String _updatedIcon = "mySecondIcon.Jpg";
2115 // administrator permissions
2116 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2118 // define and create resource
2119 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2121 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2122 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2123 String resourceName = resourceDetails.getName();
2125 // update metadata details
2126 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2127 // change icon of metadata
2128 updatedResourceDetails.setIcon(_updatedIcon);
2130 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2132 // validate response
2133 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2134 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2135 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), Arrays.asList("Resource"), updatedRestResponse.getResponse());
2139 updatedResourceDetails.setIcon(_updatedIcon);
2140 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2141 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2142 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2143 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), Arrays.asList("Resource"), updatedRestResponse.getResponse());
2145 // get resource with original name. original metadata should be returned
2146 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, resourceDetails.getUniqueId());
2147 // validate response
2148 assertNotNull("check response object is not null after get resource", getRestResponse);
2149 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2150 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2152 // parse updated response to javaObject
2153 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
2154 // validate that metadata was not changed
2155 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2157 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), "0.1");
2162 public void UpdateResourceTypeSuccess() throws Exception {
2164 String newResourceType = ResourceTypeEnum.VL.toString();
2165 String currentResourceType = resourceDetails.getResourceType();
2166 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2167 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2168 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2170 resourceDetails.setResourceType(newResourceType);
2171 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2172 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2173 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2174 // assertTrue("Check resource type after update resource",
2175 // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2176 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2181 public void UpdateResourceTypeAndNameSuccess() throws Exception {
2183 String newResourceType = ResourceTypeEnum.VL.toString();
2184 String currentResourceType = resourceDetails.getResourceType();
2185 String newResourceName = "new Name";
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(newResourceType);
2192 resourceDetails.setName(newResourceName);
2193 List<String> tags = resourceDetails.getTags();
2194 tags.add(newResourceName);
2195 resourceDetails.setTags(tags);
2197 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2198 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2199 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2200 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2201 assertTrue("Check resource name after update resource", updatedResourceJavaObject.getName().equals(newResourceName));
2206 public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2208 String newResourceType = ResourceTypeEnum.VF.toString();
2209 String currentResourceType = resourceDetails.getResourceType();
2210 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2211 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2212 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2214 resourceDetails.setResourceType(newResourceType);
2215 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2216 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2217 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKOUT);
2218 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2219 currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2221 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2222 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2223 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2224 // assertTrue("Check resource type after update resource",
2225 // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2226 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2231 public void UpdateResourceTypeCheckInLCS() throws Exception {
2233 String resourceType = ResourceTypeEnum.VL.toString();
2234 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2235 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2236 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2238 resourceDetails.setResourceType(resourceType);
2239 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
2240 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2242 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2244 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2246 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2247 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2248 assertEquals("Check response code after create resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2250 List<String> variables = new ArrayList<>();
2251 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, updatedRestResponse.getResponse());
2256 public void UpdateResourceTypeCertifiedLCS() throws Exception {
2258 String resourceType = ResourceTypeEnum.VL.toString();
2259 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2260 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2261 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2263 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2264 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2266 resourceDetails.setResourceType(resourceType);
2267 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2269 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2271 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2272 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2273 assertEquals("Check response code after create resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2275 List<String> variables = new ArrayList<>();
2276 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, updatedRestResponse.getResponse());
2281 public void UpdateResourceTypeInvalidType() throws Exception {
2283 String resourceType = "INVALID TYPE";
2284 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2285 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2286 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2288 resourceDetails.setResourceType(resourceType);
2289 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2291 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2293 assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2294 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2295 assertEquals("Check response code after update resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2297 List<String> variables = new ArrayList<>();
2298 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables, updatedRestResponse.getResponse());