2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.resource;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertNotNull;
25 import static org.testng.AssertJUnit.assertTrue;
27 import java.io.FileNotFoundException;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.HashMap;
31 import java.util.Iterator;
32 import java.util.List;
35 import org.json.JSONException;
36 import org.json.JSONObject;
37 import org.junit.rules.TestName;
38 import org.openecomp.sdc.be.dao.api.ActionStatus;
39 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
40 import org.openecomp.sdc.be.model.LifecycleStateEnum;
41 import org.openecomp.sdc.be.model.Resource;
42 import org.openecomp.sdc.be.model.User;
43 import org.openecomp.sdc.be.model.category.CategoryDefinition;
44 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
45 import org.openecomp.sdc.ci.tests.api.Urls;
46 import org.openecomp.sdc.ci.tests.config.Config;
47 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
48 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
49 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
50 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
53 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
54 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
55 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
56 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
57 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
58 import org.openecomp.sdc.ci.tests.utils.DbUtils;
59 import org.openecomp.sdc.ci.tests.utils.Utils;
60 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
61 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
63 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
64 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
65 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
66 import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
67 import org.openecomp.sdc.common.util.ValidationUtils;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
70 import org.testng.AssertJUnit;
71 import org.testng.annotations.BeforeMethod;
72 import org.testng.annotations.Test;
74 import com.google.gson.Gson;
76 public class UpdateResourceMetadataTest extends ComponentBaseTest {
77 private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
78 protected List<String> Empty_List = new ArrayList<String>();
79 protected String extendedChars;
81 protected final String contentTypeHeaderData = "application/json";
82 protected final String acceptHeaderDate = "application/json";
83 protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
85 public static TestName name = new TestName();
86 protected User sdncModifierDetails;
87 protected ResourceReqDetails resourceDetails;
89 public UpdateResourceMetadataTest() {
90 super(name, UpdateResourceMetadataTest.class.getName());
94 public String extendedCharsStringBuilder() throws Exception {
95 char[] extendedCharsArray = new char[128];
97 for (int i = 0; i < extendedCharsArray.length - 1; i++) {
98 extendedCharsArray[i] = ch;
101 extendedChars = new String(extendedCharsArray);
102 return extendedChars;
107 public void setup() throws Exception {
108 sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
109 resourceDetails = defineResourse();
115 public void UpdateDerivedFromSuccess() throws Exception {
117 String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
118 String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
120 // Getting both derived from resources for validation
122 * RestResponse resourceByNameAndVersion = resourceUtils.getResourceByNameAndVersion(sdncModifierDetails, oldDerivedFromName, "1.0"); assertEquals("Check response code after get database normative", 200,
123 * resourceByNameAndVersion.getErrorCode().intValue()); Resource databaseNormative = resourceUtils.parseResourceResp(resourceByNameAndVersion);
125 * resourceByNameAndVersion = resourceUtils.getResourceByNameAndVersion(sdncModifierDetails, newDerivedFromName, "1.0"); assertEquals("Check response code after get database normative", 200,
126 * resourceByNameAndVersion.getErrorCode().intValue()); Resource lbNormative = resourceUtils.parseResourceResp(resourceByNameAndVersion);
129 // Derived from set to Database
130 List<String> derivedFrom = new ArrayList<>();
131 derivedFrom.add(oldDerivedFromName);
132 resourceDetails.setDerivedFrom(derivedFrom);
134 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
135 AssertJUnit.assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
136 Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
139 derivedFrom.add(newDerivedFromName);
140 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResource.getUniqueId(), "");
141 AssertJUnit.assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
145 protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
146 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
148 updatedResourceDetails.setVersion("mumu");
149 updatedResourceDetails.setIsAbstract(true);
150 updatedResourceDetails.setIsHighestVersion(true);
151 updatedResourceDetails.setCreatorUserId("df4444");
152 updatedResourceDetails.setCreatorFullName("John Doe");
153 updatedResourceDetails.setLastUpdaterUserId("gf5646");
154 updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
155 updatedResourceDetails.setCreationDate(new Long(4444));
156 updatedResourceDetails.setLastUpdateDate(new Long("534535"));
157 updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
158 updatedResourceDetails.setCost("6.1");
159 updatedResourceDetails.setLicenseType("Installation");
160 updatedResourceDetails.setUUID("dfsfsdf");
161 return updatedResourceDetails;
164 public void UpdateResourceNotFoundTest() throws Exception {
166 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
168 String resourceName = "cisco4";
170 String description = "updatedDescription";
171 ArrayList<String> resourceTags = new ArrayList<String>();
172 resourceTags.add("tag2");
173 String category = ServiceCategoriesEnum.MOBILITY.getValue();
174 ArrayList<String> derivedFrom = new ArrayList<String>();
175 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
176 String vendorName = "newOracle";
177 String vendorRelease = "2.5";
178 String contactId = "jh0003";
179 String icon = "myICON";
181 ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category, derivedFrom, vendorName, vendorRelease, contactId, icon);
182 updatedResourceDetails.setUniqueId("dummyId");
183 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, "0.1");
186 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
187 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
188 AssertJUnit.assertEquals("Check response code after update resource", 404, updatedRestResponse.getErrorCode().intValue());
189 // String resourceId =
190 // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
191 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), updatedRestResponse.getResponse());
194 // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
196 updatedResourceDetails = defineUpdatedResourse(resourceName);
197 updatedResourceDetails.setUniqueId("dummyId");
198 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, "0.1");
199 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
200 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
201 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), updatedRestResponse.getResponse());
205 public char[] getInValidChars() throws Exception {
207 char[] extendedCharsArray = new char[59];
209 for (int i = 0; i < 44; i++) {
210 extendedCharsArray[i] = ch;
214 for (int i = 44; i < 51; i++) {
215 extendedCharsArray[i] = ch;
219 for (int i = 51; i < 55; i++) {
220 extendedCharsArray[i] = ch;
224 for (int i = 55; i < 59; i++) {
225 extendedCharsArray[i] = ch;
228 return extendedCharsArray;
231 public char[] getTagInValidFormatChars() throws Exception {
232 // Tag format is the same as defined for "Resource Name" :
233 // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
234 // ('_'), dash ('-'), dot ('.')
235 char[] notValidCharsArray = new char[30];
237 for (int i = 0; i < 12; i++) {
238 notValidCharsArray[i] = ch;
241 notValidCharsArray[13] = 47;
243 for (int i = 14; i < 21; i++) {
244 notValidCharsArray[i] = ch;
248 for (int i = 21; i < 24; i++) {
249 notValidCharsArray[i] = ch;
252 notValidCharsArray[24] = 96;
254 for (int i = 25; i < 30; i++) {
255 notValidCharsArray[i] = ch;
258 return notValidCharsArray;
261 public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
263 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
265 // define and create resource
266 ResourceReqDetails resourceDetails = defineResourse();
267 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
268 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
269 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
271 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
272 String resourceId = resourceDetails.getUniqueId();
273 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
276 JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
278 List<String> resource = new ArrayList<>();
279 resource.add("Resource");
281 // remove Description
282 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description", ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
284 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags", ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
286 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category", ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
288 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName", ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
289 // remove VendorRelease
290 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease", ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
291 // remove AT&T Contact
292 UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId", ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
294 // get resource with original name. original metadata should be returned
295 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
297 AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
298 AssertJUnit.assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
299 AssertJUnit.assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
301 // parse updated response to javaObject
302 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
303 // validate that metadata was not changed
304 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
306 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
307 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
308 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
311 // End of validation tests
312 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
314 protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
315 String description = "updatedDescription";
316 ArrayList<String> resourceTags = new ArrayList<String>();
317 // Duplicate tags are allowed and should be de-duplicated by server side
318 resourceTags.add(resourceName);
319 resourceTags.add("tag1");
320 resourceTags.add("tag1");
321 resourceTags.add("tag2");
322 resourceTags.add("tag2");
323 String category = ServiceCategoriesEnum.VOIP.getValue();
324 ArrayList<String> derivedFrom = new ArrayList<String>();
325 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
326 String vendorName = "updatedOracle";
327 String vendorRelease = "3.5";
328 String contactId = "jh0001";
329 String icon = "myUpdatedICON";
331 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category, derivedFrom, vendorName, vendorRelease, contactId, icon);
332 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
334 return resourceDetails;
337 protected ResourceReqDetails defineResourse() {
338 String resourceName = "cisco4";
339 String description = "description";
340 ArrayList<String> resourceTags = new ArrayList<String>();
341 resourceTags.add(resourceName);
342 ArrayList<String> derivedFrom = new ArrayList<String>();
343 derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
344 String vendorName = "Oracle";
345 String vendorRelease = "1.5";
346 String contactId = "jh0003";
347 String icon = "objectStorage";
349 ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null, derivedFrom, vendorName, vendorRelease, contactId, icon);
350 resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
352 return resourceDetails;
355 protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails) throws Exception {
357 DbUtils.cleanAllAudits();
360 RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
363 AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
364 AssertJUnit.assertNotNull("check error code exists in response after create resource", restResponse.getErrorCode());
365 AssertJUnit.assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
370 protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails, String uri) throws Exception {
373 RestResponse ResourceResponse;
375 config = Utils.getConfig();
376 Map<String, String> headersMap = new HashMap<String, String>();
377 headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
378 headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
379 headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
380 HttpRequest http = new HttpRequest();
381 String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(), config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
384 ResourceResponse = http.httpSendGet(url, headersMap);
385 } else if (uri == "POST") {
386 Gson gson = new Gson();
387 String userBodyJson = gson.toJson(updatedResourceDetails);
388 ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
389 } else if (uri == "DELETE") {
390 ResourceResponse = http.httpSendDelete(url, headersMap);
394 return ResourceResponse;
395 } catch (FileNotFoundException e) {
396 // TODO Auto-generated catch block
404 protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
405 // json object: resourceName and icon are must
406 JSONObject jObject = new JSONObject();
408 List<String> tagsList = Arrays.asList(resourceDetails.getName());
409 List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
411 jObject.put("name", resourceDetails.getName());
412 jObject.put("description", "updatedDescription");
413 jObject.put("tags", tagsList);
414 jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
415 jObject.put("derivedFrom", derivedFromList);
416 jObject.put("vendorName", "newOracle");
417 jObject.put("vendorRelease", "1.5");
418 jObject.put("contactId", "jh0003");
419 jObject.put("icon", resourceDetails.getIcon());
424 protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
425 jObject.remove(removedPropery);
430 // purpose: function for controlling json body fields and validating
432 protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject, String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
434 JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
435 // remove description from jsonObject
436 jObject = RemoveFromJsonObject(jObject, removedField);
437 // update with incomplete body.
438 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(), sdncModifierDetails, resourceId);
440 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
441 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
442 ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
446 // purpose: function for validating error response
447 protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails, String recievedMessage, List<String> variables) throws Exception {
448 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, "0.1");
450 AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
451 AssertJUnit.assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
452 ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
456 protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse) throws Exception {
457 // parse response to javaObject
458 Resource updatedResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
459 AssertJUnit.assertTrue(!resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
460 AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
461 AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
462 AssertJUnit.assertTrue(!resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
463 AssertJUnit.assertTrue(!resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
464 AssertJUnit.assertTrue(!resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
465 AssertJUnit.assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
466 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
467 AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName().equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
468 AssertJUnit.assertTrue(!resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
469 AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
470 AssertJUnit.assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
471 AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
475 protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse) throws Exception {
476 // parse response to javaObject
477 Resource updatedResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
478 // validate request vs response
479 ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
482 public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails, String resourceVersion) {
484 ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
486 expectedResourceAuditJavaObject.setAction("Checkout");
487 expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
488 expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
489 expectedResourceAuditJavaObject.setStatus("200.0");
490 expectedResourceAuditJavaObject.setDesc("OK");
491 expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
492 expectedResourceAuditJavaObject.setResourceType("Resource");
493 expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
494 expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
495 expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
496 expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
498 return expectedResourceAuditJavaObject;
502 public enum FieldToValidate {
503 ContactId, Tags, VendorName, VendorRelease, Description
507 public void UpdateBy_postTest() throws Exception {
509 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
510 String resourceName = resourceDetails.getName();
512 // update resource - without changing resourceName
513 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
515 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
518 assertNotNull("check response object is not null after update resource", updatedRestResponse);
519 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
520 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
522 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
523 assertNotNull("check response object is not null after update resource", getRestResponse);
524 parseResponseAndValidate(resourceDetails, getRestResponse);
529 public void UpdateBy_getTest() throws Exception {
531 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
532 String resourceName = resourceDetails.getName();
534 // update resource - without changing resourceName
535 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
536 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
539 assertNotNull("check response object is not null after update resource", updatedRestResponse);
540 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
541 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
543 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
544 assertNotNull("check response object is not null after update resource", getRestResponse);
545 parseResponseAndValidate(resourceDetails, getRestResponse);
550 public void UpdateBy_deleteTest() throws Exception {
552 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
553 String resourceName = resourceDetails.getName();
555 // update resource - without changing resourceName
556 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
557 RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "DELETE");
560 assertNotNull("check response object is not null after update resource", updatedRestResponse);
561 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
562 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, updatedRestResponse.getResponse());
564 RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
565 assertNotNull("check response object is not null after update resource", getRestResponse);
566 parseResponseAndValidate(resourceDetails, getRestResponse);
573 public void UpdateWithInvaldJsonBodyTest() throws Exception {
575 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
576 resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
577 String resourceId = resourceDetails.getUniqueId();
579 // update Descirption value
580 String description = "updatedDescription";
582 // send update with incompleted json, only description string
583 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails, resourceId);
586 assertNotNull("check response object is not null after update resource", updatedRestResponse);
587 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
588 assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
590 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
591 assertNotNull("check response object is not null after update resource", getRestResponse);
592 parseResponseAndValidate(resourceDetails, getRestResponse);
597 // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
600 // RestResponse restResponse = createResource(sdncModifierDetails,
602 // String resourceName = resourceDetails.getName();
604 // // new user parameters
605 // String userFirstName = "Kot";
606 // String userLastName = "Matroskin";
607 // String role = "ADMIN";
608 // User sdncUserDetails = new User(userFirstName, userLastName,
609 // httpCspUserId, email, role,null);
610 // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
611 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
613 // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
614 // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
616 // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
617 // httpCspUserId, email,role,null);
618 // ResourceReqDetails updatedResourceDetails =
619 // defineUpdatedResourse(resourceName);
620 // RestResponse updatedRestResponse =
621 // ResourceRestUtils.updateResource(updatedResourceDetails,
622 // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
624 // // validate response
625 // assertNotNull("check response object is not null after update resource",
626 // updatedRestResponse);
627 // assertNotNull("check error code exists in response after update
628 // resource", updatedRestResponse.getErrorCode());
629 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
630 // Empty_List, updatedRestResponse.getResponse());
632 // RestResponse getRestResponse =
633 // ResourceRestUtils.getResource(sdncModifierDetails,
634 // resourceDetails.getUniqueId());
635 // assertNotNull("check response object is not null after update resource",
637 // parseResponseAndValidate(resourceDetails, getRestResponse);
643 public void UpdateResourceNameSensitiveTest() throws Exception {
644 User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
645 String resourceBaseVersion = "0.1";
646 String resourceName = "Ab";
647 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
649 RestResponse response = null;
650 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
651 BaseRestUtils.checkDeleteResponse(response);
652 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
653 BaseRestUtils.checkDeleteResponse(response);
655 RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
656 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
659 logger.debug("Changing resource life cycle ");
660 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
661 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
663 // String resourceCertifyVersion = "0.1";
664 logger.debug("Changing resource life cycle ");
665 checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
666 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
668 updatedResourceDetails.setName("ABC_-bt.aT");
669 ArrayList<String> resourceTag = new ArrayList<String>();
670 resourceTag.add(0, "ABC_-bt.aT");
671 updatedResourceDetails.setTags(resourceTag);
672 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
673 assertNotNull("check response object is not null after update resource", updatedRestResponse);
674 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
675 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
676 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
679 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
680 BaseRestUtils.checkDeleteResponse(response);
681 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
682 BaseRestUtils.checkDeleteResponse(response);
687 public void UpdateIcon_InegativeFlow() throws Exception {
689 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
690 String resourceName = resourceDetails.getName();
692 List<String> resourceList = new ArrayList<String>();
693 resourceList.add(0, "Resource");
694 // check InValid Characters
695 char[] notValidCharsArray = new char[59];
696 notValidCharsArray = getInValidChars();
697 // update metadata details
698 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
699 RestResponse updatedRestResponse;
701 for (int i = 0; i < notValidCharsArray.length; i++) {
702 // change icon of metadata
703 updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
705 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
707 assertNotNull("check response object is not null after update resource", updatedRestResponse);
708 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
709 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList, updatedRestResponse.getResponse());
710 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
711 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
716 String updateIcon = "";
717 updatedResourceDetails.setIcon(updateIcon);
718 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
719 assertNotNull("check response object is not null after update resource", updatedRestResponse);
720 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
721 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList, updatedRestResponse.getResponse());
723 // Icon length more then 25 characters
724 resourceList.add(1, "25");
725 updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
726 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
728 assertNotNull("check response object is not null after update resource", updatedRestResponse);
729 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
730 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList, updatedRestResponse.getResponse());
731 assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
732 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
734 // get resource with original name. original metadata should be returned
735 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
737 assertNotNull("check response object is not null after get resource", getRestResponse);
738 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
739 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
741 // parse updated response to javaObject
742 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
743 // validate that metadata was not changed
744 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
749 public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
751 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
752 String resourceBaseVersion = "0.1";
755 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
756 String resourceName = resourceDetails.getName();
758 ResourceReqDetails updatedResourceDetails = defineResourse();
759 updatedResourceDetails.setName("updatedResourceName");
760 List<String> tags = updatedResourceDetails.getTags();
762 for (Iterator<String> iter = tags.listIterator(); iter.hasNext();) {
763 String a = iter.next();
764 if (a.equals("updatedResourceName")) {
769 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
771 List<String> resourceList = new ArrayList<String>();
772 assertNotNull("check response object is not null after update resource", updatedRestResponse);
773 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
774 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(), resourceList, updatedRestResponse.getResponse());
775 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
777 // get resource with original name. original metadata should be returned
778 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
780 assertNotNull("check response object is not null after get resource", getRestResponse);
781 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
782 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
783 // parse updated response to javaObject
784 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
785 // validate that metadata was not changed
786 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
791 public void UpdateResourceName_negativeFlow() throws Exception {
792 // The validation are done in Tag's validation
793 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
795 RestResponse updatedRestResponse;
796 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
797 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
798 String uniqueId = resourceDetails.getUniqueId();
799 String resourceName = resourceDetails.getName();
800 // check InValid Characters
801 char[] notValidCharsArray = new char[59];
802 notValidCharsArray = getInValidChars();
803 ArrayList<String> resource_Name = new ArrayList<String>();
804 List<String> resourceList = new ArrayList<String>();
806 ArrayList<String> resourceTags = new ArrayList<String>();
807 resourceList.add(0, "Resource");
809 // update metadata details
810 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
811 for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
812 if (i != 1 && i != 46 && /*
813 * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
814 */ i != 31) // space ("") and dot(.)
816 // change resourceName parameter
817 updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
818 resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
819 updatedResourceDetails.setTags(resource_Name);
820 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, uniqueId, "");
822 // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
823 // Empty_List, updatedRestResponse.getResponse());
824 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList, updatedRestResponse.getResponse());
829 // resourceName length more then 50 characters
830 // Duplicate tags are allowed and should be de-duplicated by server side
831 resource_Name.add(resourceName);
832 resource_Name.add("tag1");
833 resource_Name.add("tag1");
834 resource_Name.add("tag2");
835 resource_Name.add("tag2");
837 resourceList.add(1, "1024");
838 // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
839 updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
840 // resource_Name.add("123456789012345678901234567890123456789012345678901");
841 updatedResourceDetails.setTags(resource_Name);
842 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, uniqueId, "");
844 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList, updatedRestResponse.getResponse());
846 // get resource with original name. original metadata should be returned
847 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, resourceDetails.getUniqueId());
849 assertNotNull("check response object is not null after get resource", getRestResponse);
850 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
851 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
852 // parse updated response to javaObject
853 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
854 // validate that metadata was not changed
855 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
858 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), "0.1");
859 BaseRestUtils.checkDeleteResponse(response);
863 public void UpdateResourceInformation_NotCheckedOut() throws Exception {
865 String resourceBaseVersion = "0.1";
866 List<String> resourceList = new ArrayList<String>();
868 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
869 String resourceName = resourceDetails.getName();
872 logger.debug("Changing resource life cycle ");
873 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
874 assertNotNull("check response object is not null after checkout resource", checkoutResource);
875 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
876 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
878 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
880 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
881 assertNotNull("check response object is not null after update resource", updatedRestResponse);
882 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
883 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, updatedRestResponse.getResponse());
884 assertEquals("Check response code after updating resource icon", 409, updatedRestResponse.getErrorCode().intValue());
886 // get resource with original name. original metadata should be returned
887 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
889 assertNotNull("check response object is not null after get resource", getRestResponse);
890 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
891 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
893 // parse updated response to javaObject
894 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
895 // validate that metadata was not changed
896 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
901 public void UpdateResourceInformation_resourceVersion_11() throws Exception {
903 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
904 String resourceBaseVersion = "0.1";
907 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
908 String resourceName = resourceDetails.getName();
910 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
914 logger.debug("Changing resource life cycle ");
915 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
916 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
918 logger.debug("Changing resource life cycle ");
919 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
920 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
922 logger.debug("Changing resource life cycle ");
923 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
924 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
926 logger.debug("Changing resource life cycle ");
927 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
928 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
930 String resourceCertifyVersion = "1.0";
931 logger.debug("Changing resource life cycle ");
932 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
933 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
935 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
937 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
939 List<String> resourceList = new ArrayList<String>();
940 assertNotNull("check response object is not null after update resource", updatedRestResponse);
941 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
942 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, updatedRestResponse.getResponse());
943 // assertEquals("Check response code after updating resource icon", 409,
944 // updatedRestResponse.getErrorCode().intValue());
946 // get resource with original name. original metadata should be returned
947 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
949 assertNotNull("check response object is not null after get resource", getRestResponse);
951 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
953 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
954 // parse updated response to javaObject
955 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
956 // validate that metadata was not changed
957 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
962 public void UpdateResourceInformation_resourceVersion_02() throws Exception {
964 String resourceBaseVersion = "0.1";
967 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
968 String resourceName = resourceDetails.getName();
970 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
974 logger.debug("Changing resource life cycle ");
975 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
976 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
978 // String resourceCertifyVersion = "0.1";
979 logger.debug("Changing resource life cycle ");
980 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
981 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
983 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
985 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
987 assertNotNull("check response object is not null after update resource", updatedRestResponse);
988 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
989 assertEquals("Check response code after updating resource icon", 200, updatedRestResponse.getErrorCode().intValue());
991 // get resource with original name. original metadata should be returned
992 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
994 assertNotNull("check response object is not null after get resource", getRestResponse);
995 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
996 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
998 // parse updated response to javaObject
999 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1000 // validate that metadata was not changed
1001 ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
1004 RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
1005 BaseRestUtils.checkDeleteResponse(response);
1006 response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.2");
1007 BaseRestUtils.checkDeleteResponse(response);
1012 public void UpdateResourceIcon_resourceVersion_11() throws Exception {
1013 // Can be changed only if major version is "0".
1015 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1016 String resourceBaseVersion = "0.1";
1019 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1020 String resourceName = resourceDetails.getName();
1022 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1026 logger.debug("Changing resource life cycle ");
1027 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1028 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1030 logger.debug("Changing resource life cycle ");
1031 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1032 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1034 logger.debug("Changing resource life cycle ");
1035 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1036 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1038 logger.debug("Changing resource life cycle ");
1039 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1040 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1042 String resourceCertifyVersion = "1.0";
1043 logger.debug("Changing resource life cycle ");
1044 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1045 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1047 // ResourceReqDetails updatedResourceDetails =
1048 // defineUpdatedResourse(resourceName);
1049 ResourceReqDetails updatedResourceDetails = defineResourse();
1050 // updatedResourceDetails.setVendorName("updatedVandorName");
1051 updatedResourceDetails.setIcon("updatedIcon");
1053 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1054 // validate response
1055 List<String> resourceList = new ArrayList<String>();
1056 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1058 // get resource with original name. original metadata should be returned
1059 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1060 // validate response
1061 assertNotNull("check response object is not null after get resource", getRestResponse);
1062 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1063 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1064 // parse updated response to javaObject
1065 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1066 // validate that metadata was not changed
1067 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1072 public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
1073 // Can be changed only if the major resource version is "0".
1074 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1075 String resourceBaseVersion = "0.1";
1078 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1079 String resourceName = resourceDetails.getName();
1081 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1085 logger.debug("Changing resource life cycle ");
1086 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1087 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1089 logger.debug("Changing resource life cycle ");
1090 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1091 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1093 logger.debug("Changing resource life cycle ");
1094 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1095 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1097 logger.debug("Changing resource life cycle ");
1098 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1099 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1101 String resourceCertifyVersion = "1.0";
1102 logger.debug("Changing resource life cycle ");
1103 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1104 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1106 // ResourceReqDetails updatedResourceDetails =
1107 // defineUpdatedResourse(resourceName);
1108 ResourceReqDetails updatedResourceDetails = defineResourse();
1110 updatedResourceDetails.setVendorName("updatedVandorName");
1112 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1113 // validate response
1114 List<String> resourceList = new ArrayList<String>();
1115 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1116 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1117 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1118 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
1120 // get resource with original name. original metadata should be returned
1121 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1122 // validate response
1123 assertNotNull("check response object is not null after get resource", getRestResponse);
1124 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1125 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1126 // parse updated response to javaObject
1127 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1128 // validate that metadata was not changed
1129 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1134 public void UpdateResourceName_resourceVersion_11() throws Exception {
1135 // Can be changed only if the major resource version is "0".
1136 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1137 String resourceBaseVersion = "0.1";
1140 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1141 assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
1142 String resourceName = resourceDetails.getName();
1144 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1148 logger.debug("Changing resource life cycle ");
1149 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1150 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1152 logger.debug("Changing resource life cycle ");
1153 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1154 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1156 logger.debug("Changing resource life cycle ");
1157 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1158 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1160 logger.debug("Changing resource life cycle ");
1161 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1162 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1164 String resourceCertifyVersion = "1.0";
1165 logger.debug("Changing resource life cycle ");
1166 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1167 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1170 * //ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); ResourceReqDetails updatedResourceDetails = defineResourse();
1172 * updatedResourceDetails.setResourceName("updatedResourceName"); updatedResourceDetails.setIcon("updatedResourceName");
1174 resourceDetails.setName("updatedResourceName");
1175 List<String> tagList = new ArrayList<String>();
1176 tagList.add(0, "updatedResourceName");
1177 resourceDetails.setTags(tagList);
1179 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1180 // validate response
1181 List<String> resourceList = new ArrayList<String>();
1182 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1183 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1184 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList, updatedRestResponse.getResponse());
1189 public void UpdateResourceTag_resourceVersion_11() throws Exception {
1190 // Tag Can be updated when major version is "0".
1191 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1192 String resourceBaseVersion = "0.1";
1195 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1196 String resourceName = resourceDetails.getName();
1198 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1202 logger.debug("Changing resource life cycle ");
1203 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1204 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1206 logger.debug("Changing resource life cycle ");
1207 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1208 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1210 logger.debug("Changing resource life cycle ");
1211 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1212 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1214 logger.debug("Changing resource life cycle ");
1215 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1216 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1218 String resourceCertifyVersion = "1.0";
1219 logger.debug("Changing resource life cycle ");
1220 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1221 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1223 // ResourceReqDetails updatedResourceDetails =
1224 // defineUpdatedResourse(resourceName);
1225 ResourceReqDetails updatedResourceDetails = defineResourse();
1226 // updatedResourceDetails.setVendorName("updatedVandorName");
1228 ArrayList<String> resourceTags = new ArrayList<String>();
1229 resourceTags.add("NewTag");
1230 resourceTags.add(resourceDetails.getName());
1232 updatedResourceDetails.setTags(resourceTags);
1234 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1235 // validate response
1236 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1237 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1238 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1240 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1241 assertNotNull("check response object is not null after update resource", getRestResponse);
1242 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1247 public void UpdateAllowedParames_resourceVersion_11() throws Exception {
1249 // Tag, contactId, vendorRelease,tags And description - Can be also
1250 // updated when major version is NOT "0".
1251 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1252 String resourceBaseVersion = "0.1";
1255 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1257 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1261 logger.debug("Changing resource life cycle ");
1262 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1263 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1265 logger.debug("Changing resource life cycle ");
1266 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1267 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1269 logger.debug("Changing resource life cycle ");
1270 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1271 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1273 logger.debug("Changing resource life cycle ");
1274 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1275 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1277 String resourceCertifyVersion = "1.0";
1278 logger.debug("Changing resource life cycle ");
1279 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1280 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1282 // ResourceReqDetails updatedResourceDetails =
1283 // defineUpdatedResourse(resourceName);
1284 ResourceReqDetails updatedResourceDetails = defineResourse();
1285 // updatedResourceDetails.setVendorName("updatedVandorName");
1287 // updated allowed parameters when major resource version is NOT "0"
1288 ArrayList<String> resourceTags = new ArrayList<String>();
1289 resourceTags.add("NewTag");
1290 resourceTags.add(resourceDetails.getName());
1291 updatedResourceDetails.setTags(resourceTags);
1292 updatedResourceDetails.setDescription("UpdatedDescription");
1293 updatedResourceDetails.setVendorRelease("5.1");
1294 updatedResourceDetails.setContactId("bt750h");
1296 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1297 // validate response
1298 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1299 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1300 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1302 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1303 assertNotNull("check response object is not null after update resource", getRestResponse);
1304 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
1309 public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
1310 // DerivedFrom parameter - Can be updated when major version is "0".
1311 User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1312 String resourceBaseVersion = "0.1";
1315 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1316 String resourceName = resourceDetails.getName();
1318 // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
1322 logger.debug("Changing resource life cycle ");
1323 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
1324 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1326 logger.debug("Changing resource life cycle ");
1327 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1328 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1330 logger.debug("Changing resource life cycle ");
1331 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
1332 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1334 logger.debug("Changing resource life cycle ");
1335 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
1336 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1338 String resourceCertifyVersion = "1.0";
1339 logger.debug("Changing resource life cycle ");
1340 checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
1341 assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
1343 // ResourceReqDetails updatedResourceDetails =
1344 // defineUpdatedResourse(resourceName);
1345 ResourceReqDetails updatedResourceDetails = defineResourse();
1346 ArrayList<String> drivenFrom = new ArrayList<String>();
1347 drivenFrom.add(0, "tosca.nodes.Container.Application");
1348 updatedResourceDetails.setDerivedFrom(drivenFrom);
1350 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1351 // validate response
1352 List<String> resourceList = new ArrayList<String>();
1353 ResourceRestUtils.checkSuccess(updatedRestResponse);
1355 // get resource with original name. original metadata should be returned
1356 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
1357 // validate response
1358 assertNotNull("check response object is not null after get resource", getRestResponse);
1359 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
1360 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
1361 // parse updated response to javaObject
1362 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
1363 // validate that metadata was not changed
1364 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
1369 public void UpdateResource_vendorNameValidation() throws Exception {
1371 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1372 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1373 String updatedVendorName = "";
1374 String uniqueId = resourceDetails.getUniqueId();
1375 resourceDetails.setVendorName(updatedVendorName);
1376 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1377 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1378 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1379 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1381 // update resource vendorName metadata: 1 characters
1382 updatedVendorName = " ";
1384 resourceDetails.setVendorName(updatedVendorName);
1385 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1386 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1387 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1388 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1390 // update resource vendorName metadata: 25 characters
1391 updatedVendorName = "Verification and validati";
1393 resourceDetails.setVendorName(updatedVendorName);
1394 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1395 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1396 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1397 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1398 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1400 // update resource vendorName metadata: 26 characters
1401 updatedVendorName = "Verification and validatii";
1403 List<String> myList = new ArrayList<String>();
1404 myList.add(0, "25");
1405 resourceDetails.setVendorName(updatedVendorName);
1406 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1407 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1408 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList, updatedRestResponse.getResponse());
1410 // update resource VendorRelease metadata: forbidden characters
1411 updatedVendorName = "A1<";
1413 resourceDetails.setVendorName(updatedVendorName);
1414 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1415 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1416 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1418 updatedVendorName = "A1>";
1420 resourceDetails.setVendorName(updatedVendorName);
1421 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1422 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1423 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1425 updatedVendorName = "A1:";
1427 resourceDetails.setVendorName(updatedVendorName);
1428 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1429 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1430 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1432 updatedVendorName = "A1\"";
1434 resourceDetails.setVendorName(updatedVendorName);
1435 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1436 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1437 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1439 updatedVendorName = "A1/";
1441 resourceDetails.setVendorName(updatedVendorName);
1442 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1443 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1444 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1446 updatedVendorName = "A1\\";
1448 resourceDetails.setVendorName(updatedVendorName);
1449 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1450 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1451 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1453 updatedVendorName = "A1|";
1455 resourceDetails.setVendorName(updatedVendorName);
1456 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1457 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1458 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1460 updatedVendorName = "A1?";
1462 resourceDetails.setVendorName(updatedVendorName);
1463 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1464 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1465 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1467 updatedVendorName = "A1*";
1469 resourceDetails.setVendorName(updatedVendorName);
1470 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1471 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1472 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1474 // update resource vendorName metadata: null
1475 updatedVendorName = null;
1477 resourceDetails.setVendorName(updatedVendorName);
1478 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1479 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1480 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, updatedRestResponse.getResponse());
1485 public void UpdateResource_vendorReleaseValidation() throws Exception {
1487 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1488 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1489 RestResponse updatedRestResponse;
1490 String uniqueId = resourceDetails.getUniqueId();
1491 String updatedVendorRelease;
1492 // set VendorRelease
1494 // update resource VendorRelease metadata: 1 characters
1495 updatedVendorRelease = "1";
1496 // set VendorRelease
1497 resourceDetails.setVendorRelease(updatedVendorRelease);
1498 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1499 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1500 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1501 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1502 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1504 // update resource VendorRelease metadata: 25 characters
1505 updatedVendorRelease = "(!#1.00000000000000000000";
1506 // set VendorRelease
1507 resourceDetails.setVendorRelease(updatedVendorRelease);
1508 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1509 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1510 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1511 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1512 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1514 // update resource VendorRelease metadata: 26 characters
1515 updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
1516 resourceDetails.setVendorRelease(updatedVendorRelease);
1517 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1518 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(), Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
1520 // UpdateAndValidate(sdncModifierDetails, resourceDetails,
1521 // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
1522 // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
1524 // update resource VendorRelease metadata: forbidden characters
1525 updatedVendorRelease = "A1<";
1526 // set VendorRelease
1527 resourceDetails.setVendorRelease(updatedVendorRelease);
1528 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1529 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1531 updatedVendorRelease = "A1>";
1532 // set VendorRelease
1533 resourceDetails.setVendorRelease(updatedVendorRelease);
1534 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1535 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1537 updatedVendorRelease = "A1:";
1538 // set VendorRelease
1539 resourceDetails.setVendorRelease(updatedVendorRelease);
1540 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1541 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1543 updatedVendorRelease = "A1\"";
1544 // set VendorRelease
1545 resourceDetails.setVendorRelease(updatedVendorRelease);
1546 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1547 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1549 updatedVendorRelease = "A1/";
1550 // set VendorRelease
1551 resourceDetails.setVendorRelease(updatedVendorRelease);
1552 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1553 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1555 updatedVendorRelease = "A1\\";
1556 // set VendorRelease
1557 resourceDetails.setVendorRelease(updatedVendorRelease);
1558 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1559 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1561 updatedVendorRelease = "A1|";
1562 // set VendorRelease
1563 resourceDetails.setVendorRelease(updatedVendorRelease);
1564 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1565 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1567 updatedVendorRelease = "A1?";
1568 // set VendorRelease
1569 resourceDetails.setVendorRelease(updatedVendorRelease);
1570 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1571 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1573 updatedVendorRelease = "A1*";
1574 // set VendorRelease
1575 resourceDetails.setVendorRelease(updatedVendorRelease);
1576 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1577 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1579 // update resource VendorRelease metadata: null
1580 updatedVendorRelease = null;
1581 // set VendorRelease
1582 resourceDetails.setVendorRelease(updatedVendorRelease);
1583 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1584 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1585 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List, updatedRestResponse.getResponse());
1590 public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
1611 RestResponse updatedRestResponse;
1613 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1614 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1615 String uniqueId = resourceDetails.getUniqueId();
1617 List<String> myList = new ArrayList<String>();
1618 myList.add(0, "Resource");
1619 String updatedContactId = "";
1620 resourceDetails.setContactId(updatedContactId);
1622 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1623 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1625 updatedContactId = "ab12345";
1626 resourceDetails.setContactId(updatedContactId);
1627 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1628 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1630 updatedContactId = " ";
1631 resourceDetails.setContactId(updatedContactId);
1632 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1633 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1635 updatedContactId = "ab 50h";
1636 resourceDetails.setContactId(updatedContactId);
1637 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1638 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1640 updatedContactId = "ab123c";
1641 resourceDetails.setContactId(updatedContactId);
1642 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1643 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1644 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1645 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1647 updatedContactId = "cd789E";
1648 resourceDetails.setContactId(updatedContactId);
1649 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1650 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1651 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1653 resourceDetails.setContactId(updatedContactId.toLowerCase());
1654 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1656 updatedContactId = "ef4567";
1657 resourceDetails.setContactId(updatedContactId);
1658 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1659 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1660 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1661 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1662 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1664 updatedContactId = "AA012A";
1665 resourceDetails.setContactId(updatedContactId);
1666 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1667 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1668 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1669 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1671 resourceDetails.setContactId(updatedContactId.toLowerCase());
1672 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1674 updatedContactId = "CD012c";
1675 resourceDetails.setContactId(updatedContactId);
1676 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1677 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1678 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1679 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1681 resourceDetails.setContactId(updatedContactId.toLowerCase());
1682 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1684 updatedContactId = "EF0123";
1685 resourceDetails.setContactId(updatedContactId);
1686 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1687 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1688 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1689 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1691 resourceDetails.setContactId(updatedContactId.toLowerCase());
1692 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1694 ////////////////////////////// **************//////////////////////////////
1695 List<String> resource = Arrays.asList("Resource");
1696 updatedContactId = "01345a";
1697 resourceDetails.setContactId(updatedContactId);
1698 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1699 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1701 updatedContactId = "0y000B";
1702 resourceDetails.setContactId(updatedContactId);
1703 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1704 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1706 updatedContactId = "Y1000b";
1707 resourceDetails.setContactId(updatedContactId);
1708 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1709 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1711 updatedContactId = "abxyzC";
1712 resourceDetails.setContactId(updatedContactId);
1713 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1714 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1716 updatedContactId = "cdXYZc";
1717 resourceDetails.setContactId(updatedContactId);
1718 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1719 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1721 updatedContactId = "efXY1D";
1722 resourceDetails.setContactId(updatedContactId);
1723 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1724 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1726 updatedContactId = "EFabcD";
1727 resourceDetails.setContactId(updatedContactId);
1728 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1729 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1731 updatedContactId = "EFABCD";
1732 resourceDetails.setContactId(updatedContactId);
1733 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1734 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1736 updatedContactId = "EFABC1";
1737 resourceDetails.setContactId(updatedContactId);
1738 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1739 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1741 updatedContactId = "efui1D";
1742 resourceDetails.setContactId(updatedContactId);
1743 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1744 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1746 updatedContactId = "efui1!";
1747 resourceDetails.setContactId(updatedContactId);
1748 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1749 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1751 updatedContactId = "ef555!";
1752 resourceDetails.setContactId(updatedContactId);
1753 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1754 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1756 updatedContactId = ",f555";
1757 resourceDetails.setContactId(updatedContactId);
1758 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1759 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1761 updatedContactId = "EF55.5";
1762 resourceDetails.setContactId(updatedContactId);
1763 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1764 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1766 // update resource contactId metadata: extended character set (128–255)
1767 resourceDetails.setContactId(extendedCharsStringBuilder());
1768 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1769 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, updatedRestResponse.getResponse());
1771 // update resource contactId metadata: null
1772 updatedContactId = null;
1773 resourceDetails.setContactId(updatedContactId);
1774 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1775 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, updatedRestResponse.getResponse());
1780 public void UpdateResource_TagsFieldValidation() throws Exception {
1781 RestResponse updatedRestResponse;
1782 // define and create resource
1784 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1785 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1786 String uniqueId = resourceDetails.getUniqueId();
1788 String updatedTagField = "";
1789 ArrayList<String> resourceTags = new ArrayList<String>();
1790 resourceTags.add(updatedTagField);
1792 resourceDetails.setTags(resourceTags);
1793 List<String> variables = Arrays.asList("Resource", "tag");
1794 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1795 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, updatedRestResponse.getResponse());
1797 // update resource tags metadata: empty
1798 resourceTags = new ArrayList<String>();
1800 resourceDetails.setTags(resourceTags);
1801 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1802 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List, updatedRestResponse.getResponse());
1804 // update resource description metadata: 1 characters
1805 updatedTagField = "A";
1806 resourceTags = new ArrayList<String>();
1807 resourceTags.add(updatedTagField);
1808 resourceTags.add(resourceDetails.getName());
1810 resourceDetails.setTags(resourceTags);
1811 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1812 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1813 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1814 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1815 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1817 // OK - tag up to 50 chars
1818 updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
1819 resourceTags.add(updatedTagField);
1820 resourceDetails.setTags(resourceTags);
1821 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1822 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1823 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1824 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1825 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1827 // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
1828 String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
1829 String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
1830 String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
1831 String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
1832 String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
1833 String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
1834 String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
1835 String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
1836 String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
1837 String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
1838 String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
1839 String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
1840 String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
1841 String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
1842 String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
1843 String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
1844 String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
1845 String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
1846 String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
1848 resourceTags = new ArrayList<String>();
1849 resourceTags.add(updatedTagField);
1850 resourceTags.add(updatedTagField1);
1851 resourceTags.add(updatedTagField2);
1852 resourceTags.add(updatedTagField3);
1853 resourceTags.add(updatedTagField4);
1854 resourceTags.add(updatedTagField5);
1855 resourceTags.add(updatedTagField6);
1856 resourceTags.add(updatedTagField7);
1857 resourceTags.add(updatedTagField8);
1858 resourceTags.add(updatedTagField9);
1859 resourceTags.add(updatedTagField10);
1860 resourceTags.add(updatedTagField11);
1861 resourceTags.add(updatedTagField12);
1862 resourceTags.add(updatedTagField13);
1863 resourceTags.add(updatedTagField14);
1864 resourceTags.add(updatedTagField15);
1865 resourceTags.add(updatedTagField16);
1866 resourceTags.add(updatedTagField17);
1867 resourceTags.add(updatedTagField18);
1868 resourceTags.add(updatedTagField19);
1869 resourceTags.add(resourceDetails.getName());
1871 resourceDetails.setTags(resourceTags);
1872 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1873 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1874 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1875 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1876 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1878 // Add another tag-exceeds limit
1879 resourceTags.add("d");
1880 resourceDetails.setTags(resourceTags);
1881 ArrayList<String> myArray = new ArrayList<String>();
1882 myArray.add(0, "1024");
1883 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1884 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray, updatedRestResponse.getResponse());
1886 // Tag exceeds limit - 51
1887 resourceTags = new ArrayList<String>();
1888 updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
1889 resourceTags.add(updatedTagField);
1890 resourceTags.add(resourceDetails.getName());
1892 resourceDetails.setTags(resourceTags);
1894 myArray.add(0, "50");
1895 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1896 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray, updatedRestResponse.getResponse());
1901 public void UpdateResource_DesriptionFieldValidation() throws Exception {
1902 // define and create resource
1903 RestResponse updatedRestResponse;
1905 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1906 String uniqueId = resourceDetails.getUniqueId();
1907 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
1908 List<String> resource = new ArrayList<>();
1909 resource.add("Resource");
1910 // update resource description metadata: 0 characters
1911 String updatedDescription = "";
1913 resourceDetails.setDescription(updatedDescription);
1914 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1915 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, updatedRestResponse.getResponse());
1917 // update resource description metadata: null
1918 updatedDescription = null;
1920 resourceDetails.setDescription(updatedDescription);
1921 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1922 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, updatedRestResponse.getResponse());
1924 // update resource description metadata: 1 characters
1925 updatedDescription = "A";
1927 resourceDetails.setDescription(updatedDescription);
1928 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1929 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1930 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1931 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1932 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1934 // update resource description metadata: 1024 characters
1935 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."
1936 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
1937 + "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."
1938 + "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."
1939 + "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."
1940 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
1941 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
1943 resourceDetails.setDescription(updatedDescription);
1944 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1945 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1946 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1947 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
1948 parseResponseAndValidate(resourceDetails, updatedRestResponse);
1950 // update resource description metadata: 1025 characters
1951 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."
1952 + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
1953 + "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."
1954 + "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."
1955 + "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."
1956 + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
1957 + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
1959 resourceDetails.setDescription(updatedDescription);
1960 resource.add(1, "1024");
1961 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, "");
1962 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource, updatedRestResponse.getResponse());
1967 public void UpdateResource_TagsFormatValidation() throws Exception {
1968 char[] notValidCharsArray = getTagInValidFormatChars();
1970 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
1971 assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
1972 String resourceName = resourceDetails.getName();
1974 // update tag details
1975 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
1976 ArrayList<String> resourceTags = new ArrayList<String>();
1978 String updatedTagField;
1979 RestResponse updatedRestResponse;
1980 List<String> variables = Arrays.asList("Resource", "tag");
1982 for (int i = 0; i < notValidCharsArray.length; i++) {
1983 updatedTagField = "UpdatedTag" + notValidCharsArray[i];
1984 resourceTags = new ArrayList<String>();
1985 resourceTags.add(updatedTagField);
1986 resourceTags.add(resourceDetails.getName());
1988 updatedResourceDetails.setTags(resourceTags);
1990 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
1991 // validate response
1992 assertNotNull("check response object is not null after update resource", updatedRestResponse);
1993 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
1994 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, updatedRestResponse.getResponse());
1995 assertEquals("Check response code after updating resource icon", 400, updatedRestResponse.getErrorCode().intValue());
1996 assertEquals("Check response code after updating resource icon", "Bad Request", updatedRestResponse.getResponseMessage().toString());
2003 public void UpdateResourceCategory_negativeFlow() throws Exception {
2005 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2006 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2007 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2008 String uniqueID = resourceDetails.getUniqueId();
2010 // Update resource Category Successfully
2011 ResourceReqDetails updatedResourceDetails = resourceDetails;
2013 updatedResourceDetails.removeAllCategories();
2014 updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(), ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2015 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2017 // validate response
2018 List<String> resourceList = new ArrayList<String>();
2019 resourceList.add(0, "Resource");
2020 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2021 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2022 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
2023 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2025 // Updating resource category
2026 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2027 updatedResourceDetails.addCategory("");
2028 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2029 // validate response
2030 resourceList = new ArrayList<String>();
2031 resourceList.add(0, "Resource");
2032 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2033 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2034 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
2035 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2037 // Updating resource category
2038 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2039 updatedResourceDetails.addCategory("XXXXXX");
2040 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2041 // validate response
2042 resourceList = new ArrayList<String>();
2043 resourceList.add(0, "Resource");
2044 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2045 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2046 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, updatedRestResponse.getResponse());
2047 assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
2050 logger.debug("Changing resource life cycle ");
2051 RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
2052 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2054 // Update resource Category
2055 updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
2056 updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
2057 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2059 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2060 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2061 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List, updatedRestResponse.getResponse());
2062 assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
2065 logger.debug("Changing resource life cycle ");
2066 RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
2067 assertNotNull("check response object is not null after checkout resource", checkoutResource);
2068 assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
2069 assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
2071 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
2072 assertNotNull("check response object is not null after update resource", getRestResponse);
2073 parseResponseAndValidate(resourceDetails, getRestResponse);
2078 public void UpdateResourceCategorySuccessfully() throws Exception {
2080 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2081 assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
2082 Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2084 // Update resource Category Successfully
2085 ResourceReqDetails updatedResourceDetails = resourceDetails;
2087 updatedResourceDetails.removeAllCategories();
2088 updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(), ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
2089 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, resourceDetails.getUniqueId(), "");
2091 // validate response
2092 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2093 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2094 assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
2095 // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
2096 // updatedRestResponse);
2097 parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
2099 // validate category updated
2100 assertTrue(updatedResourceDetails.getCategories().get(0).getName().equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
2102 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
2103 assertNotNull("check response object is not null after update resource", getRestResponse);
2104 parseResponseAndValidate(updatedResourceDetails, getRestResponse);
2106 ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
2112 public void Validation_UpdateIcon() throws Exception {
2113 // Fields to update (Forbidden)
2114 String _updatedIcon = "mySecondIcon.Jpg";
2116 // administrator permissions
2117 User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
2119 // define and create resource
2120 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
2122 RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
2123 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2124 String resourceName = resourceDetails.getName();
2126 // update metadata details
2127 ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
2128 // change icon of metadata
2129 updatedResourceDetails.setIcon(_updatedIcon);
2131 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2133 // validate response
2134 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2135 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2136 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), Arrays.asList("Resource"), updatedRestResponse.getResponse());
2140 updatedResourceDetails.setIcon(_updatedIcon);
2141 updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
2142 assertNotNull("check response object is not null after update resource", updatedRestResponse);
2143 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2144 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), Arrays.asList("Resource"), updatedRestResponse.getResponse());
2146 // get resource with original name. original metadata should be returned
2147 RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, resourceDetails.getUniqueId());
2148 // validate response
2149 assertNotNull("check response object is not null after get resource", getRestResponse);
2150 assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
2151 assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
2153 // parse updated response to javaObject
2154 Resource getResourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(getRestResponse.getResponse());
2155 // validate that metadata was not changed
2156 ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
2158 ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), "0.1");
2163 public void UpdateResourceTypeSuccess() throws Exception {
2165 String newResourceType = ResourceTypeEnum.VL.toString();
2166 String currentResourceType = resourceDetails.getResourceType();
2167 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2168 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2169 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2171 resourceDetails.setResourceType(newResourceType);
2172 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2173 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2174 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2175 // assertTrue("Check resource type after update resource",
2176 // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
2177 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2182 public void UpdateResourceTypeAndNameSuccess() throws Exception {
2184 String newResourceType = ResourceTypeEnum.VL.toString();
2185 String currentResourceType = resourceDetails.getResourceType();
2186 String newResourceName = "new Name";
2188 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2189 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2190 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2192 resourceDetails.setResourceType(newResourceType);
2193 resourceDetails.setName(newResourceName);
2194 List<String> tags = resourceDetails.getTags();
2195 tags.add(newResourceName);
2196 resourceDetails.setTags(tags);
2198 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2199 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2200 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2201 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2202 assertTrue("Check resource name after update resource", updatedResourceJavaObject.getName().equals(newResourceName));
2207 public void UpdateResourceTypeAfterResourceCertification() throws Exception {
2209 String newResourceType = ResourceTypeEnum.VF.toString();
2210 String currentResourceType = resourceDetails.getResourceType();
2211 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2212 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2213 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2215 resourceDetails.setResourceType(newResourceType);
2216 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2217 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2218 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKOUT);
2219 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2220 currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2222 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2223 assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
2224 Resource updatedResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
2225 // assertTrue("Check resource type after update resource",
2226 // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
2227 assertTrue("Check resource type after update resource", updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
2232 public void UpdateResourceTypeCheckInLCS() throws Exception {
2234 String resourceType = ResourceTypeEnum.VL.toString();
2235 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2236 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2237 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2239 resourceDetails.setResourceType(resourceType);
2240 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
2241 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2243 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2245 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2247 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2248 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2249 assertEquals("Check response code after create resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2251 List<String> variables = new ArrayList<>();
2252 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, updatedRestResponse.getResponse());
2257 public void UpdateResourceTypeCertifiedLCS() throws Exception {
2259 String resourceType = ResourceTypeEnum.VL.toString();
2260 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2261 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2262 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2264 restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
2265 assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
2267 resourceDetails.setResourceType(resourceType);
2268 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2270 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2272 assertNotNull("check response object is not null after create resouce", updatedRestResponse);
2273 assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
2274 assertEquals("Check response code after create resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2276 List<String> variables = new ArrayList<>();
2277 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, updatedRestResponse.getResponse());
2282 public void UpdateResourceTypeInvalidType() throws Exception {
2284 String resourceType = "INVALID TYPE";
2285 RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
2286 assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
2287 Resource currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
2289 resourceDetails.setResourceType(resourceType);
2290 RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
2292 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
2294 assertNotNull("check response object is not null after update resouce", updatedRestResponse);
2295 assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
2296 assertEquals("Check response code after update resource", errorInfo.getCode(), updatedRestResponse.getErrorCode());
2298 List<String> variables = new ArrayList<>();
2299 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables, updatedRestResponse.getResponse());