summaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts
diff options
context:
space:
mode:
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts')
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java647
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java185
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java673
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java176
4 files changed, 0 insertions, 1681 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java
deleted file mode 100644
index 02bf110c8d..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java
+++ /dev/null
@@ -1,647 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.artifacts;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import fj.data.Either;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.BasicResponseHandler;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.*;
-import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.api.Urls;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.*;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
-import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.Decoder;
-import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
-import org.openecomp.sdc.ci.tests.utils.general.Convertor;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ServiceValidationUtils;
-import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.util.GeneralUtility;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class DownloadComponentArt extends ComponentBaseTest {
-
- private static Logger log = LoggerFactory.getLogger(DownloadComponentArt.class.getName());
- protected static final String UPLOAD_ARTIFACT_PAYLOAD = "UHVUVFktVXNlci1LZXktRmlsZS0yOiBzc2gtcnNhDQpFbmNyeXB0aW9uOiBhZXMyNTYtY2JjDQpDb21tZW5wOA0K";
- protected static final String UPLOAD_ARTIFACT_NAME = "TLV_prv.ppk";
-
- protected Config config = Config.instance();
- protected String contentTypeHeaderData = "application/json";
- protected String acceptHeaderDate = "application/json";
-
-
-
- protected Gson gson = new Gson();
- protected JSONParser jsonParser = new JSONParser();
-
-
- protected String serviceVersion;
- protected ResourceReqDetails resourceDetails;
- protected User sdncUserDetails;
- protected ServiceReqDetails serviceDetails;
-
-
- @BeforeMethod
- public void init() throws Exception{
- sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- Resource resourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- Service serviceObj = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
-
-
- resourceDetails = new ResourceReqDetails(resourceObj);
- serviceDetails = new ServiceReqDetails(serviceObj);
- }
-
- @Rule
- public static TestName name = new TestName();
-
- public DownloadComponentArt() {
- super(name, DownloadComponentArt.class.getName());
-
- }
-
-
-
- // External API - Download artifact for resource
- @Test
- public void downloadArtifactFromResourceViaExternalAPI() throws Exception {
- Resource resourceDetailsVF;
- Either<Resource, RestResponse> createdResource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true);
- resourceDetailsVF = createdResource.left().value();
- ArtifactDefinition heatArtifact = AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT, resourceDetailsVF, UserRoleEnum.DESIGNER, true, true).left().value();
- resourceDetails = new ResourceReqDetails(resourceDetailsVF);
-
- String resourceUUID = resourceDetailsVF.getUUID();
- String artifactUUID = heatArtifact.getArtifactUUID();
-
- System.out.println("Resource UUID: " + resourceUUID);
- System.out.println("Artifact UUID: " + artifactUUID);
-
- RestResponse restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), "Resource");
-
- Integer responseCode = restResponse.getErrorCode();
- Integer expectedCode = 200;
- Assert.assertEquals(responseCode,expectedCode, "Response code is not correct.");
-
- String response = restResponse.getResponse();
-
- String payloadData = "aGVhdF90ZW1wbGF0ZV92ZXJzaW9uOiAyMDEzLTA1LTIzDQoNCmRlc2NyaXB0aW9uOiBTaW1wbGUgdGVtcGxhdGUgdG8gZGVwbG95IGEgc3RhY2sgd2l0aCB0d28gdmlydHVhbCBtYWNoaW5lIGluc3RhbmNlcw0KDQpwYXJhbWV0ZXJzOg0KICBpbWFnZV9uYW1lXzE6DQogICAgdHlwZTogc3RyaW5nDQogICAgbGFiZWw6IEltYWdlIE5hbWUNCiAgICBkZXNjcmlwdGlvbjogU0NPSU1BR0UgU3BlY2lmeSBhbiBpbWFnZSBuYW1lIGZvciBpbnN0YW5jZTENCiAgICBkZWZhdWx0OiBjaXJyb3MtMC4zLjEteDg2XzY0DQogIGltYWdlX25hbWVfMjoNCiAgICB0eXBlOiBzdHJpbmcNCiAgICBsYWJlbDogSW1hZ2UgTmFtZQ0KICAgIGRlc2NyaXB0aW9uOiBTQ09JTUFHRSBTcGVjaWZ5IGFuIGltYWdlIG5hbWUgZm9yIGluc3RhbmNlMg0KICAgIGRlZmF1bHQ6IGNpcnJvcy0wLjMuMS14ODZfNjQNCiAgbmV0d29ya19pZDoNCiAgICB0eXBlOiBzdHJpbmcNCiAgICBsYWJlbDogTmV0d29yayBJRA0KICAgIGRlc2NyaXB0aW9uOiBTQ09ORVRXT1JLIE5ldHdvcmsgdG8gYmUgdXNlZCBmb3IgdGhlIGNvbXB1dGUgaW5zdGFuY2UNCiAgICBoaWRkZW46IHRydWUNCiAgICBjb25zdHJhaW50czoNCiAgICAgIC0gbGVuZ3RoOiB7IG1pbjogNiwgbWF4OiA4IH0NCiAgICAgICAgZGVzY3JpcHRpb246IFBhc3N3b3JkIGxlbmd0aCBtdXN0IGJlIGJldHdlZW4gNiBhbmQgOCBjaGFyYWN0ZXJzLg0KICAgICAgLSByYW5nZTogeyBtaW46IDYsIG1heDogOCB9DQogICAgICAgIGRlc2NyaXB0aW9uOiBSYW5nZSBkZXNjcmlwdGlvbg0KICAgICAgLSBhbGxvd2VkX3ZhbHVlczoNCiAgICAgICAgLSBtMS5zbWFsbA0KICAgICAgICAtIG0xLm1lZGl1bQ0KICAgICAgICAtIG0xLmxhcmdlDQogICAgICAgIGRlc2NyaXB0aW9uOiBBbGxvd2VkIHZhbHVlcyBkZXNjcmlwdGlvbg0KICAgICAgLSBhbGxvd2VkX3BhdHRlcm46ICJbYS16QS1aMC05XSsiDQogICAgICAgIGRlc2NyaXB0aW9uOiBQYXNzd29yZCBtdXN0IGNvbnNpc3Qgb2YgY2hhcmFjdGVycyBhbmQgbnVtYmVycyBvbmx5Lg0KICAgICAgLSBhbGxvd2VkX3BhdHRlcm46ICJbQS1aXStbYS16QS1aMC05XSoiDQogICAgICAgIGRlc2NyaXB0aW9uOiBQYXNzd29yZCBtdXN0IHN0YXJ0IHdpdGggYW4gdXBwZXJjYXNlIGNoYXJhY3Rlci4NCiAgICAgIC0gY3VzdG9tX2NvbnN0cmFpbnQ6IG5vdmEua2V5cGFpcg0KICAgICAgICBkZXNjcmlwdGlvbjogQ3VzdG9tIGRlc2NyaXB0aW9uDQoNCnJlc291cmNlczoNCiAgbXlfaW5zdGFuY2UxOg0KICAgIHR5cGU6IE9TOjpOb3ZhOjpTZXJ2ZXINCiAgICBwcm9wZXJ0aWVzOg0KICAgICAgaW1hZ2U6IHsgZ2V0X3BhcmFtOiBpbWFnZV9uYW1lXzEgfQ0KICAgICAgZmxhdm9yOiBtMS5zbWFsbA0KICAgICAgbmV0d29ya3M6DQogICAgICAgIC0gbmV0d29yayA6IHsgZ2V0X3BhcmFtIDogbmV0d29ya19pZCB9DQogIG15X2luc3RhbmNlMjoNCiAgICB0eXBlOiBPUzo6Tm92YTo6U2VydmVyDQogICAgcHJvcGVydGllczoNCiAgICAgIGltYWdlOiB7IGdldF9wYXJhbTogaW1hZ2VfbmFtZV8yIH0NCiAgICAgIGZsYXZvcjogbTEudGlueQ0KICAgICAgbmV0d29ya3M6DQogICAgICAgIC0gbmV0d29yayA6IHsgZ2V0X3BhcmFtIDogbmV0d29ya19pZCB9";
- String decodedPaypload = Decoder.decode(payloadData);
-
- Assert.assertEquals(response, decodedPaypload, "Response deployment artifact not correct.");
-
- String auditAction = "DownloadArtifact";
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName());
- expectedResourceAuditJavaObject.setResourceType("Resource");
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
-
- expectedResourceAuditJavaObject.setCONSUMER_ID("ci");
- String resource_url = String.format("/sdc/v1/catalog/resources/%s/artifacts/%s", resourceUUID, artifactUUID);
- expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url);
-
- AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
-
- // External API - Download artifact for resource - negative test
- @Test
- public void downloadArtifactFromResourceViaExternalAPINegativeTest() throws Exception {
- Resource resourceDetailsVF;
- Either<Resource, RestResponse> createdResource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true);
- resourceDetailsVF = createdResource.left().value();
- ArtifactDefinition heatArtifact = AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT, resourceDetailsVF, UserRoleEnum.DESIGNER, true, true).left().value();
- resourceDetails = new ResourceReqDetails(resourceDetailsVF);
-
- String resourceUUID = resourceDetailsVF.getUUID();
- String artifactUUID = heatArtifact.getArtifactUUID();
-
- System.out.println("Resource UUID: " + resourceUUID);
- System.out.println("Artifact UUID: " + artifactUUID);
-
- RestResponse restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, "dfsgfdsg324", ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), "Resource");
-
- Integer responseCode = restResponse.getErrorCode();
- Integer expectedCode = 200;
- Assert.assertEquals(responseCode,expectedCode, "Response code is not correct.");
- }
-
-
-
-
-
- // External API - Download artifact for service - negative test
- @Test
- public void downloadArtifactFromServiceViaExternalAPI() throws Exception {
-
- Service resourceDetailsService;
- Either<Service, RestResponse> createdResource = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true);
- resourceDetailsService = createdResource.left().value();
-
- ArtifactDefinition heatArtifact = AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.OTHER, resourceDetailsService, UserRoleEnum.DESIGNER, true, true).left().value();
-
- String resourceUUID = resourceDetailsService.getUUID();
- String artifactUUID = heatArtifact.getArtifactUUID();
-
- System.out.println("Resource UUID: " + resourceUUID);
- System.out.println("Artifact UUID: " + artifactUUID);
-
- RestResponse restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), "Service");
-
- Integer responseCode = restResponse.getErrorCode();
- Integer expectedCode = 200;
- Assert.assertEquals(responseCode,expectedCode, "Response code is not correct.");
-
- String response = restResponse.getResponse();
-
- String payloadData = "aGVhdF90ZW1wbGF0ZV92ZXJzaW9uOiAyMDEzLTA1LTIzDQoNCmRlc2NyaXB0aW9uOiBTaW1wbGUgdGVtcGxhdGUgdG8gZGVwbG95IGEgc3RhY2sgd2l0aCB0d28gdmlydHVhbCBtYWNoaW5lIGluc3RhbmNlcw0KDQpwYXJhbWV0ZXJzOg0KICBpbWFnZV9uYW1lXzE6DQogICAgdHlwZTogc3RyaW5nDQogICAgbGFiZWw6IEltYWdlIE5hbWUNCiAgICBkZXNjcmlwdGlvbjogU0NPSU1BR0UgU3BlY2lmeSBhbiBpbWFnZSBuYW1lIGZvciBpbnN0YW5jZTENCiAgICBkZWZhdWx0OiBjaXJyb3MtMC4zLjEteDg2XzY0DQogIGltYWdlX25hbWVfMjoNCiAgICB0eXBlOiBzdHJpbmcNCiAgICBsYWJlbDogSW1hZ2UgTmFtZQ0KICAgIGRlc2NyaXB0aW9uOiBTQ09JTUFHRSBTcGVjaWZ5IGFuIGltYWdlIG5hbWUgZm9yIGluc3RhbmNlMg0KICAgIGRlZmF1bHQ6IGNpcnJvcy0wLjMuMS14ODZfNjQNCiAgbmV0d29ya19pZDoNCiAgICB0eXBlOiBzdHJpbmcNCiAgICBsYWJlbDogTmV0d29yayBJRA0KICAgIGRlc2NyaXB0aW9uOiBTQ09ORVRXT1JLIE5ldHdvcmsgdG8gYmUgdXNlZCBmb3IgdGhlIGNvbXB1dGUgaW5zdGFuY2UNCiAgICBoaWRkZW46IHRydWUNCiAgICBjb25zdHJhaW50czoNCiAgICAgIC0gbGVuZ3RoOiB7IG1pbjogNiwgbWF4OiA4IH0NCiAgICAgICAgZGVzY3JpcHRpb246IFBhc3N3b3JkIGxlbmd0aCBtdXN0IGJlIGJldHdlZW4gNiBhbmQgOCBjaGFyYWN0ZXJzLg0KICAgICAgLSByYW5nZTogeyBtaW46IDYsIG1heDogOCB9DQogICAgICAgIGRlc2NyaXB0aW9uOiBSYW5nZSBkZXNjcmlwdGlvbg0KICAgICAgLSBhbGxvd2VkX3ZhbHVlczoNCiAgICAgICAgLSBtMS5zbWFsbA0KICAgICAgICAtIG0xLm1lZGl1bQ0KICAgICAgICAtIG0xLmxhcmdlDQogICAgICAgIGRlc2NyaXB0aW9uOiBBbGxvd2VkIHZhbHVlcyBkZXNjcmlwdGlvbg0KICAgICAgLSBhbGxvd2VkX3BhdHRlcm46ICJbYS16QS1aMC05XSsiDQogICAgICAgIGRlc2NyaXB0aW9uOiBQYXNzd29yZCBtdXN0IGNvbnNpc3Qgb2YgY2hhcmFjdGVycyBhbmQgbnVtYmVycyBvbmx5Lg0KICAgICAgLSBhbGxvd2VkX3BhdHRlcm46ICJbQS1aXStbYS16QS1aMC05XSoiDQogICAgICAgIGRlc2NyaXB0aW9uOiBQYXNzd29yZCBtdXN0IHN0YXJ0IHdpdGggYW4gdXBwZXJjYXNlIGNoYXJhY3Rlci4NCiAgICAgIC0gY3VzdG9tX2NvbnN0cmFpbnQ6IG5vdmEua2V5cGFpcg0KICAgICAgICBkZXNjcmlwdGlvbjogQ3VzdG9tIGRlc2NyaXB0aW9uDQoNCnJlc291cmNlczoNCiAgbXlfaW5zdGFuY2UxOg0KICAgIHR5cGU6IE9TOjpOb3ZhOjpTZXJ2ZXINCiAgICBwcm9wZXJ0aWVzOg0KICAgICAgaW1hZ2U6IHsgZ2V0X3BhcmFtOiBpbWFnZV9uYW1lXzEgfQ0KICAgICAgZmxhdm9yOiBtMS5zbWFsbA0KICAgICAgbmV0d29ya3M6DQogICAgICAgIC0gbmV0d29yayA6IHsgZ2V0X3BhcmFtIDogbmV0d29ya19pZCB9DQogIG15X2luc3RhbmNlMjoNCiAgICB0eXBlOiBPUzo6Tm92YTo6U2VydmVyDQogICAgcHJvcGVydGllczoNCiAgICAgIGltYWdlOiB7IGdldF9wYXJhbTogaW1hZ2VfbmFtZV8yIH0NCiAgICAgIGZsYXZvcjogbTEudGlueQ0KICAgICAgbmV0d29ya3M6DQogICAgICAgIC0gbmV0d29yayA6IHsgZ2V0X3BhcmFtIDogbmV0d29ya19pZCB9";
- String decodedPaypload = Decoder.decode(payloadData);
-
- Assert.assertEquals(response, decodedPaypload, "Response deployment artifact not correct.");
-
- String auditAction = "DownloadArtifact";
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setResourceName(resourceDetailsService.getName());
- expectedResourceAuditJavaObject.setResourceType("Service");
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
-
- expectedResourceAuditJavaObject.setCONSUMER_ID("ci");
- String resource_url = String.format("/sdc/v1/catalog/services/%s/artifacts/%s", resourceUUID, artifactUUID);
- expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url);
-
- AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
-
-
-
-
-
- // External API - Download ComponentInstance artifact of service - negative test
- @Test
- public void downloadArtifactOfComponentInstanceFromServiceViaExternalAPI() throws Exception {
-
- Either<Resource, RestResponse> resourceDetailsVF_01e = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true);
- Component resourceDetailsVF_01 = resourceDetailsVF_01e.left().value();
- ArtifactDefinition heatArtifact = AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT, resourceDetailsVF_01, UserRoleEnum.DESIGNER, true, true).left().value();
-
- resourceDetailsVF_01 = AtomicOperationUtils.changeComponentState(resourceDetailsVF_01, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
-
- Service resourceDetailsService;
- Either<Service, RestResponse> createdResource = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true);
- resourceDetailsService = createdResource.left().value();
-
-
- ComponentInstance resourceDetailsVF1ins_01 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceDetailsVF_01, resourceDetailsService, UserRoleEnum.DESIGNER, true).left().value();
-
-
- System.out.println("-----");
-
-
- String resourceUUID = resourceDetailsService.getUUID();
- String componentNormalizedName = resourceDetailsVF1ins_01.getNormalizedName();
- String artifactUUID = heatArtifact.getArtifactUUID();
-
- System.out.println("Resource UUID: " + resourceUUID);
- System.out.println("Component NormalizedName: " + componentNormalizedName);
- System.out.println("Artifact UUID: " + artifactUUID);
-
- RestResponse restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(resourceUUID, componentNormalizedName, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), "Service");
-//
- Integer responseCode = restResponse.getErrorCode();
- Integer expectedCode = 200;
- Assert.assertEquals(responseCode,expectedCode, "Response code is not correct.");
-
- String response = restResponse.getResponse();
-
- String payloadData = "aGVhdF90ZW1wbGF0ZV92ZXJzaW9uOiAyMDEzLTA1LTIzDQoNCmRlc2NyaXB0aW9uOiBTaW1wbGUgdGVtcGxhdGUgdG8gZGVwbG95IGEgc3RhY2sgd2l0aCB0d28gdmlydHVhbCBtYWNoaW5lIGluc3RhbmNlcw0KDQpwYXJhbWV0ZXJzOg0KICBpbWFnZV9uYW1lXzE6DQogICAgdHlwZTogc3RyaW5nDQogICAgbGFiZWw6IEltYWdlIE5hbWUNCiAgICBkZXNjcmlwdGlvbjogU0NPSU1BR0UgU3BlY2lmeSBhbiBpbWFnZSBuYW1lIGZvciBpbnN0YW5jZTENCiAgICBkZWZhdWx0OiBjaXJyb3MtMC4zLjEteDg2XzY0DQogIGltYWdlX25hbWVfMjoNCiAgICB0eXBlOiBzdHJpbmcNCiAgICBsYWJlbDogSW1hZ2UgTmFtZQ0KICAgIGRlc2NyaXB0aW9uOiBTQ09JTUFHRSBTcGVjaWZ5IGFuIGltYWdlIG5hbWUgZm9yIGluc3RhbmNlMg0KICAgIGRlZmF1bHQ6IGNpcnJvcy0wLjMuMS14ODZfNjQNCiAgbmV0d29ya19pZDoNCiAgICB0eXBlOiBzdHJpbmcNCiAgICBsYWJlbDogTmV0d29yayBJRA0KICAgIGRlc2NyaXB0aW9uOiBTQ09ORVRXT1JLIE5ldHdvcmsgdG8gYmUgdXNlZCBmb3IgdGhlIGNvbXB1dGUgaW5zdGFuY2UNCiAgICBoaWRkZW46IHRydWUNCiAgICBjb25zdHJhaW50czoNCiAgICAgIC0gbGVuZ3RoOiB7IG1pbjogNiwgbWF4OiA4IH0NCiAgICAgICAgZGVzY3JpcHRpb246IFBhc3N3b3JkIGxlbmd0aCBtdXN0IGJlIGJldHdlZW4gNiBhbmQgOCBjaGFyYWN0ZXJzLg0KICAgICAgLSByYW5nZTogeyBtaW46IDYsIG1heDogOCB9DQogICAgICAgIGRlc2NyaXB0aW9uOiBSYW5nZSBkZXNjcmlwdGlvbg0KICAgICAgLSBhbGxvd2VkX3ZhbHVlczoNCiAgICAgICAgLSBtMS5zbWFsbA0KICAgICAgICAtIG0xLm1lZGl1bQ0KICAgICAgICAtIG0xLmxhcmdlDQogICAgICAgIGRlc2NyaXB0aW9uOiBBbGxvd2VkIHZhbHVlcyBkZXNjcmlwdGlvbg0KICAgICAgLSBhbGxvd2VkX3BhdHRlcm46ICJbYS16QS1aMC05XSsiDQogICAgICAgIGRlc2NyaXB0aW9uOiBQYXNzd29yZCBtdXN0IGNvbnNpc3Qgb2YgY2hhcmFjdGVycyBhbmQgbnVtYmVycyBvbmx5Lg0KICAgICAgLSBhbGxvd2VkX3BhdHRlcm46ICJbQS1aXStbYS16QS1aMC05XSoiDQogICAgICAgIGRlc2NyaXB0aW9uOiBQYXNzd29yZCBtdXN0IHN0YXJ0IHdpdGggYW4gdXBwZXJjYXNlIGNoYXJhY3Rlci4NCiAgICAgIC0gY3VzdG9tX2NvbnN0cmFpbnQ6IG5vdmEua2V5cGFpcg0KICAgICAgICBkZXNjcmlwdGlvbjogQ3VzdG9tIGRlc2NyaXB0aW9uDQoNCnJlc291cmNlczoNCiAgbXlfaW5zdGFuY2UxOg0KICAgIHR5cGU6IE9TOjpOb3ZhOjpTZXJ2ZXINCiAgICBwcm9wZXJ0aWVzOg0KICAgICAgaW1hZ2U6IHsgZ2V0X3BhcmFtOiBpbWFnZV9uYW1lXzEgfQ0KICAgICAgZmxhdm9yOiBtMS5zbWFsbA0KICAgICAgbmV0d29ya3M6DQogICAgICAgIC0gbmV0d29yayA6IHsgZ2V0X3BhcmFtIDogbmV0d29ya19pZCB9DQogIG15X2luc3RhbmNlMjoNCiAgICB0eXBlOiBPUzo6Tm92YTo6U2VydmVyDQogICAgcHJvcGVydGllczoNCiAgICAgIGltYWdlOiB7IGdldF9wYXJhbTogaW1hZ2VfbmFtZV8yIH0NCiAgICAgIGZsYXZvcjogbTEudGlueQ0KICAgICAgbmV0d29ya3M6DQogICAgICAgIC0gbmV0d29yayA6IHsgZ2V0X3BhcmFtIDogbmV0d29ya19pZCB9";
- String decodedPaypload = Decoder.decode(payloadData);
-
- Assert.assertEquals(response, decodedPaypload, "Response deployment artifact not correct.");
-
- String auditAction = "DownloadArtifact";
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setResourceName(resourceDetailsVF1ins_01.getName());
- expectedResourceAuditJavaObject.setResourceType("Service");
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
-
- expectedResourceAuditJavaObject.setCONSUMER_ID("ci");
- String resource_url = String.format("/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceUUID, componentNormalizedName, artifactUUID);
- expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url);
-
-// AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
-
-
-
-
-
-
-
-
- @Test
- public void downloadArtifactFromResourceTest() throws Exception {
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- String jsonBody = createUploadArtifactBodyJson();
-
- String resourceId = resourceDetails.getUniqueId();
- String url = String.format(Urls.ADD_ARTIFACT_TO_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId);
- HttpPost httppost = createPostAddArtifactRequeast(jsonBody, url, true);
- HttpResponse response = httpclient.execute(httppost);
- int status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("failed to add artifact", 200, status);
-
- ArtifactDefinition origArtifact = getArtifactDataFromJson(jsonBody);
- addArtifactDataFromResponse(response, origArtifact);
- String artifactId = origArtifact.getUniqueId();
-
- url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId, artifactId);
- HttpGet httpGet = createGetRequest(url);
- response = httpclient.execute(httpGet);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("failed to download artifact", 200, status);
-
- InputStream inputStream = response.getEntity().getContent();
- ArtifactUiDownloadData artifactUiDownloadData = getArtifactUiDownloadData(IOUtils.toString(inputStream));
- AssertJUnit.assertEquals("Downloaded payload is different from uploaded one", UPLOAD_ARTIFACT_PAYLOAD, artifactUiDownloadData.getBase64Contents());
- AssertJUnit.assertEquals("Downloaded artifact name is different from uploaded one", UPLOAD_ARTIFACT_NAME, artifactUiDownloadData.getArtifactName());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor.constructFieldsForAuditValidation(resourceDetails, resourceDetails.getVersion(), sdncUserDetails);
- String auditAction = "ArtifactDownload";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setArtifactData(AuditValidationUtils.buildArtifactDataAudit(origArtifact));
- expectedResourceAuditJavaObject.setCurrArtifactUuid(origArtifact.getUniqueId());
- expectedResourceAuditJavaObject.setPrevArtifactUuid("");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void downloadArtifactFromServiceTest() throws Exception {
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
-
- try {
-
- String jsonStr = createUploadArtifactBodyJson();
-
- String url = String.format(Urls.ADD_ARTIFACT_TO_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), serviceDetails.getUniqueId());
- HttpPost httpPost = createPostAddArtifactRequeast(jsonStr, url, true);
- CloseableHttpResponse result = httpclient.execute(httpPost);
- int status = result.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("failed to add artifact", 200, status);
-
- ArtifactDefinition origArtifact = getArtifactDataFromJson(jsonStr);
- addArtifactDataFromResponse(result, origArtifact);
- String artifactId = origArtifact.getUniqueId();
-
- url = String.format(Urls.UI_DOWNLOAD_SERVICE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), serviceDetails.getUniqueId(), artifactId);
- HttpGet httpGet = createGetRequest(url);
- CloseableHttpResponse response2 = httpclient.execute(httpGet);
- status = response2.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("failed to download artifact", 200, status);
- InputStream inputStream = response2.getEntity().getContent();
- ArtifactUiDownloadData artifactUiDownloadData = getArtifactUiDownloadData(IOUtils.toString(inputStream));
- AssertJUnit.assertEquals("Downloaded payload is different from uploaded one", UPLOAD_ARTIFACT_PAYLOAD, artifactUiDownloadData.getBase64Contents());
- AssertJUnit.assertEquals("Downloaded artifact name is different from uploaded one", UPLOAD_ARTIFACT_NAME, artifactUiDownloadData.getArtifactName());
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = AuditValidationUtils.constructFieldsForAuditValidation(serviceDetails, serviceDetails.getVersion(), sdncUserDetails);
- String auditAction = "ArtifactDownload";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setArtifactData(AuditValidationUtils.buildArtifactDataAudit(origArtifact));
- expectedResourceAuditJavaObject.setCurrArtifactUuid(origArtifact.getUniqueId());
- expectedResourceAuditJavaObject.setPrevArtifactUuid("");
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- } finally {
-// RestResponse response = ServiceRestUtils.deleteService(serviceDetails, serviceVersion, sdncUserDetails );
-// checkDeleteResponse(response);
- httpclient.close();
- }
- }
-
- @Test
- public void downloadArtifactFromResourceNotFound() throws Exception {
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
-
- String resourceId = resourceDetails.getUniqueId();
- String artifactIdNotFound = "11111";
-
- ArtifactDefinition origArtifact = new ArtifactDefinition();
- origArtifact.setUniqueId(artifactIdNotFound);
-
- String url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId, artifactIdNotFound);
- HttpGet httpGet = createGetRequest(url);
- CloseableHttpResponse response = httpclient.execute(httpGet);
- int status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("expected 404 not found", 404, status);
-
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_NOT_FOUND.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor.constructFieldsForAuditValidation(resourceDetails, resourceDetails.getVersion(), sdncUserDetails);
- String auditAction = "ArtifactDownload";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setDesc(errorInfo.getAuditDesc(""));
- expectedResourceAuditJavaObject.setArtifactData("");
- expectedResourceAuditJavaObject.setCurrArtifactUuid(origArtifact.getUniqueId());
- expectedResourceAuditJavaObject.setPrevArtifactUuid("");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- expectedResourceAuditJavaObject.setPrevArtifactUuid(null);
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void downloadArtifactFromServiceNotFound() throws Exception {
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
-
- String artifactIdNotFound = "11111";
- ArtifactDefinition origArtifact = new ArtifactDefinition();
- origArtifact.setUniqueId(artifactIdNotFound);
-
- String url = String.format(Urls.UI_DOWNLOAD_SERVICE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), serviceDetails.getUniqueId(), artifactIdNotFound);
- HttpGet httpGet = createGetRequest(url);
- CloseableHttpResponse response2 = httpclient.execute(httpGet);
- int status = response2.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("expected 404 not found", 404, status);
-
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_NOT_FOUND.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils.constructFieldsForAuditValidation(serviceDetails, serviceDetails.getVersion(), sdncUserDetails);
- String auditAction = "ArtifactDownload";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setDesc(errorInfo.getAuditDesc(""));
- expectedResourceAuditJavaObject.setArtifactData("");
- expectedResourceAuditJavaObject.setCurrArtifactUuid(origArtifact.getUniqueId());
- expectedResourceAuditJavaObject.setPrevArtifactUuid("");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void addArtifactToResourceTest() throws Exception {
-
- ArtifactReqDetails defaultArtifact = ElementFactory.getDefaultArtifact();
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(defaultArtifact, sdncUserDetails, resourceDetails.getUniqueId());
- int status = response.getErrorCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + response.getErrorCode(), 200, status);
-
- RestResponse resourceResp = ResourceRestUtils.getResource(resourceDetails.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
- AssertJUnit.assertNotNull(resource);
-
- Map<String, ArtifactDefinition> artifacts = resource.getArtifacts();
- boolean isExist = false;
- for (Map.Entry<String, ArtifactDefinition> entry : artifacts.entrySet()) {
- if (entry.getKey().equals(defaultArtifact.getArtifactLabel())) {
- isExist = true;
-
- }
- }
- AssertJUnit.assertTrue(isExist);
- }
-
-
- protected String createUploadArtifactBodyJson() {
- Map<String, Object> jsonBody = new HashMap<String, Object>();
- jsonBody.put("artifactName", UPLOAD_ARTIFACT_NAME);
- jsonBody.put("artifactDisplayName", "configure");
- jsonBody.put("artifactType", "SHELL");
- jsonBody.put("mandatory", "false");
- jsonBody.put("description", "ff");
- jsonBody.put("payloadData", UPLOAD_ARTIFACT_PAYLOAD);
- jsonBody.put("artifactLabel", "configure");
- return gson.toJson(jsonBody);
- }
-
- protected ArtifactDefinition getArtifactDataFromJson(String json) {
- Gson gson = new Gson();
- JsonObject jsonElement = new JsonObject();
- jsonElement = gson.fromJson(json, jsonElement.getClass());
- ArtifactDefinition artifact = new ArtifactDefinition();
- String payload = null;
- JsonElement artifactPayload = jsonElement.get(Constants.ARTIFACT_PAYLOAD_DATA);
- if (artifactPayload != null && !artifactPayload.isJsonNull()) {
- payload = artifactPayload.getAsString();
- }
- jsonElement.remove(Constants.ARTIFACT_PAYLOAD_DATA);
- artifact = gson.fromJson(jsonElement, ArtifactDefinition.class);
- artifact.setPayloadData(payload);
-
- /*atifact.setArtifactName(UPLOAD_ARTIFACT_NAME);
-artifact.setArtifactDisplayName("configure");
-artifact.setArtifactType("SHELL");
-artifact.setMandatory(false);
-artifact.setDescription("ff");
-artifact.setPayloadData(UPLOAD_ARTIFACT_PAYLOAD);
-artifact.setArtifactLabel("configure");*/
- return artifact;
- }
-
- protected HttpGet createGetRequest(String url) {
- HttpGet httpGet = new HttpGet(url);
- httpGet.addHeader(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- httpGet.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- httpGet.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId());
- return httpGet;
- }
-
- protected String getArtifactUid(HttpResponse response) throws HttpResponseException, IOException, ParseException {
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- String artifactId = (String) responseMap.get("uniqueId");
- return artifactId;
- }
-
- protected String getArtifactEsId(HttpResponse response) throws HttpResponseException, IOException, ParseException {
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- String esId = (String) responseMap.get("EsId");
- return esId;
- }
-
- protected ArtifactDefinition addArtifactDataFromResponse(HttpResponse response, ArtifactDefinition artifact) throws HttpResponseException, IOException, ParseException {
- //String responseString = new BasicResponseHandler().handleResponse(response);
- HttpEntity entity = response.getEntity();
- String responseString = EntityUtils.toString(entity);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- artifact.setEsId((String)responseMap.get("esId"));
- artifact.setUniqueId((String) responseMap.get("uniqueId"));
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.findType((String) responseMap.get("artifactGroupType")));
- artifact.setTimeout(((Long) responseMap.get("timeout")).intValue());
- return artifact;
- }
-
- protected String getLifecycleArtifactUid(CloseableHttpResponse response) throws HttpResponseException, IOException, ParseException {
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- responseMap = (JSONObject) responseMap.get("implementation");
- String artifactId = (String) responseMap.get("uniqueId");
- return artifactId;
- }
-
- protected HttpDelete createDeleteArtifactRequest(String url) {
- HttpDelete httpDelete = new HttpDelete(url);
- httpDelete.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId());
- httpDelete.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- return httpDelete;
- }
-
- protected HttpPost createPostAddArtifactRequeast(String jsonBody, String url, boolean addMd5Header) throws UnsupportedEncodingException {
- HttpPost httppost = new HttpPost(url);
- httppost.addHeader(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- httppost.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- httppost.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId());
- if (addMd5Header) {
- httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5Base64EncodedByString(jsonBody));
- }
- StringEntity input = new StringEntity(jsonBody);
- input.setContentType("application/json");
- httppost.setEntity(input);
- log.debug("Executing request {}" , httppost.getRequestLine());
- return httppost;
- }
-
- protected String createLoadArtifactBody() {
- Map<String, Object> json = new HashMap<String, Object>();
- json.put("artifactName", "install_apache2.sh");
- json.put("artifactType", "SHELL");
- json.put("description", "ddd");
- json.put("payloadData", "UEsDBAoAAAAIAAeLb0bDQz");
- json.put("artifactLabel", "name123");
-
- String jsonStr = gson.toJson(json);
- return jsonStr;
- }
-
- protected void checkDeleteResponse(RestResponse response) {
- BaseRestUtils.checkStatusCode(response, "delete request failed", false, 204, 404);
- }
-
- protected ArtifactUiDownloadData getArtifactUiDownloadData(String artifactUiDownloadDataStr) throws Exception {
-
- ObjectMapper mapper = new ObjectMapper();
- try {
- ArtifactUiDownloadData artifactUiDownloadData = mapper.readValue(artifactUiDownloadDataStr, ArtifactUiDownloadData.class);
- return artifactUiDownloadData;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
-
-}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java
deleted file mode 100644
index 80e0a54ee4..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.artifacts;
-
-import org.apache.commons.codec.binary.Base64;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
-import org.openecomp.sdc.be.model.*;
-import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceInstantiationType;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.*;
-import org.testng.annotations.Test;
-import org.yaml.snakeyaml.Yaml;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class HeatEnvArtifact extends ComponentBaseTest {
-
- @Rule
- public static TestName name = new TestName();
-
- public HeatEnvArtifact() {
- super(name, HeatEnvArtifact.class.getName());
- }
-
- @Test(enabled = true)
- public void heatEnvOnResourceFormatTest() throws Exception {
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
-
- Resource createdResource = createVfFromCSAR(sdncModifierDetails, "csarHeatEnv.csar");
- assertNotNull(createdResource);
-
- RestResponse certifyState = LifecycleRestUtils.changeComponentState(createdResource, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- BaseRestUtils.checkSuccess(certifyState);
-
- Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(certifyState.getResponse(), Resource.class);
-
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(
- "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(),
- ServiceInstantiationType.A_LA_CARTE.getValue());
-
- // 2 create service
- RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails);
- ResourceRestUtils.checkCreateResponse(createServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(createServiceResponse.getResponse(), Service.class);
-
- // 3 create vf instance in service
- ComponentInstanceReqDetails componentInstanceDetails = ElementFactory.getComponentInstance(certifiedResource);
- RestResponse createComponentInstance = ComponentInstanceRestUtils.createComponentInstance(componentInstanceDetails, sdncModifierDetails, service);
- ResourceRestUtils.checkCreateResponse(createComponentInstance);
-
- RestResponse getService = ServiceRestUtils.getService(service.getUniqueId());
- BaseRestUtils.checkSuccess(getService);
- service = ResponseParser.parseToObjectUsingMapper(getService.getResponse(), Service.class);
-
- List<ComponentInstance> componentInstances = service.getComponentInstances();
- assertNotNull(componentInstances);
- assertEquals(1, componentInstances.size());
-
- ComponentInstance vfi = componentInstances.get(0);
- Map<String, ArtifactDefinition> deploymentArtifacts = vfi.getDeploymentArtifacts();
- assertNotNull(deploymentArtifacts);
- assertEquals(4, deploymentArtifacts.size());
- ArtifactDefinition heatEnv = deploymentArtifacts.get("heat0env");
- assertNotNull(heatEnv);
-
- Map<String, Object> yaml = downloadComponentInstanceYamlFile(service.getUniqueId(), vfi.getUniqueId(), sdncModifierDetails, heatEnv.getUniqueId());
- assertNotNull(yaml);
- Map<String, Object> paramters = (Map<String, Object>)yaml.get("parameters");
- assertNotNull(paramters);
- assertEquals(8, paramters.size());
- assertEquals(null, paramters.get("param8"));
- List<HeatParameterDataDefinition> heatParameters = heatEnv.getHeatParameters();
- heatParameters.forEach(p -> {
- assertEquals(p.getCurrentValue(), paramters.get(p.getName()));
- });
- }
- @Test(enabled = true)
- public void noHeatEnvOnResourceFormatTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
-
- Resource createdResource = createVfFromCSAR(sdncModifierDetails, "csarHeatNoEnv.csar");
- assertNotNull(createdResource);
-
- RestResponse certifyState = LifecycleRestUtils.changeComponentState(createdResource, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- BaseRestUtils.checkSuccess(certifyState);
-
- Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(certifyState.getResponse(), Resource.class);
-
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(
- "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(),
- ServiceInstantiationType.A_LA_CARTE.getValue());
-
- // 2 create service
- RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails);
- ResourceRestUtils.checkCreateResponse(createServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(createServiceResponse.getResponse(), Service.class);
-
- // 3 create vf instance in service
- ComponentInstanceReqDetails componentInstanceDetails = ElementFactory.getComponentInstance(certifiedResource);
- RestResponse createComponentInstance = ComponentInstanceRestUtils.createComponentInstance(componentInstanceDetails, sdncModifierDetails, service);
- ResourceRestUtils.checkCreateResponse(createComponentInstance);
-
- RestResponse getService = ServiceRestUtils.getService(service.getUniqueId());
- BaseRestUtils.checkSuccess(getService);
- service = ResponseParser.parseToObjectUsingMapper(getService.getResponse(), Service.class);
-
- List<ComponentInstance> componentInstances = service.getComponentInstances();
- assertNotNull(componentInstances);
- assertEquals(1, componentInstances.size());
-
- ComponentInstance vfi = componentInstances.get(0);
- Map<String, ArtifactDefinition> deploymentArtifacts = vfi.getDeploymentArtifacts();
- assertNotNull(deploymentArtifacts);
- assertEquals(4, deploymentArtifacts.size());
- ArtifactDefinition heatEnv = deploymentArtifacts.get("heat0env");
- assertNotNull(heatEnv);
-
- Map<String, Object> yaml = downloadComponentInstanceYamlFile(service.getUniqueId(), vfi.getUniqueId(), sdncModifierDetails, heatEnv.getUniqueId());
- assertNotNull(yaml);
- Map<String, Object> paramters = (Map<String, Object>)yaml.get("parameters");
- assertNotNull(paramters);
- assertEquals(8, paramters.size());
- assertEquals(null, paramters.get("param1"));
- assertEquals(null, paramters.get("param2"));
- assertEquals(null, paramters.get("param4"));
- assertEquals(null, paramters.get("param5"));
- assertEquals(null, paramters.get("param7"));
- assertEquals(null, paramters.get("param8"));
- List<HeatParameterDataDefinition> heatParameters = heatEnv.getHeatParameters();
- heatParameters.forEach(p -> {
- assertEquals(p.getCurrentValue(), paramters.get(p.getName()));
- });
-
- }
- //****************************************
- private Map<String, Object> downloadComponentInstanceYamlFile(String serviceUniqueId, String resourceInstanceId, User user, String artifactUniqeId) throws Exception {
- RestResponse heatEnvDownloadResponse = ArtifactRestUtils.downloadResourceInstanceArtifact(serviceUniqueId, resourceInstanceId, user, artifactUniqeId);
- BaseRestUtils.checkSuccess(heatEnvDownloadResponse);
-
- ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(heatEnvDownloadResponse.getResponse(), ArtifactUiDownloadData.class);
- byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
- byte[] decodeBase64 = Base64.decodeBase64(fromUiDownload);
- Yaml yaml = new Yaml();
-
- InputStream inputStream = new ByteArrayInputStream(decodeBase64);
-
- Map<String, Object> load = (Map<String, Object>) yaml.load(inputStream);
-
- return load;
- }
-}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java
deleted file mode 100644
index b15da07139..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java
+++ /dev/null
@@ -1,673 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.artifacts;
-
-//import static org.junit.Assert.assertTrue;
-
-import fj.data.Either;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.*;
-import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.*;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.*;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import static org.testng.AssertJUnit.*;
-
-public class PlaceHolderValidations extends ComponentBaseTest {
- private static Logger logger = LoggerFactory.getLogger(PlaceHolderValidations.class.getName());
- private static final String heatExtension = "yaml";
- // private static final String yangXmlExtension = "xml";
- // private static final String muranoPkgExtension = "zip";
- private final String folderName = "addHeatArtifactToServiceAndSertify";
- private Resource resource;
- private final int timeOut = 60;
- private ArtifactReqDetails updateArtifactReqDetails = null;
- protected User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- protected User sdncDesignerDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2);
- protected ResourceReqDetails resourceDetails1;
- protected ResourceReqDetails resourceVF;
- protected ResourceReqDetails resourceCP;
- protected ResourceReqDetails resourceVL;
-
- protected ArtifactReqDetails heatArtifactDetails;
- protected ArtifactReqDetails heatVolArtifactDetails;
- protected ArtifactReqDetails heatNetArtifactDetails;
-
- public PlaceHolderValidations() {
- super(name, PlaceHolderValidations.class.getName());
- }
-
- @Rule
- public static TestName name = new TestName();
-
- @BeforeMethod
- public void init() throws IOException, Exception {
-
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatNetArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
- heatVolArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType());
- Resource resourceObject = AtomicOperationUtils
- .createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- resourceDetails1 = new ResourceReqDetails(resourceObject);
- resourceObject = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true)
- .left().value();
- resourceVF = new ResourceReqDetails(resourceObject);
- resourceObject = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.CP, UserRoleEnum.DESIGNER, true)
- .left().value();
- resourceCP = new ResourceReqDetails(resourceObject);
- resourceObject = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VL, UserRoleEnum.DESIGNER, true)
- .left().value();
- resourceVL = new ResourceReqDetails(resourceObject);
- }
-
- @Test
- public void validateDeploymentPlaceHoldersByConfig() throws IOException {
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails1, sdncDesignerDetails1);
- Resource resourceObject = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceObject.getDeploymentArtifacts();
- assertNotNull("deploymentArtifacts list is null", deploymentArtifacts);
- List<String> listOfResDepArtTypesFromConfig = Utils.getListOfDepResArtLabels(true);
- assertNotNull("deployment artifact types list is null", listOfResDepArtTypesFromConfig);
- for (String resDepArtType : listOfResDepArtTypesFromConfig) {
- assertNotNull("placeholder of " + resDepArtType + " type doesn't exist",
- deploymentArtifacts.get(resDepArtType));
- }
- }
-
- /*private void validateToscaArtifactsBeforeAndAfterSFT(ResourceReqDetails resourceDetails)
- throws IOException, Exception {
- RestResponse componentResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails1);
- Component component = ResponseParser.convertResourceResponseToJavaObject(componentResponse.getResponse());
- Map<String, ArtifactDefinition> toscaArtifacts = component.getToscaArtifacts();
- for (ArtifactDefinition artifact : toscaArtifacts.values()) {
- assertNull(artifact.getEsId());
- }
-
- componentResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails1,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- component = ResponseParser.convertResourceResponseToJavaObject(componentResponse.getResponse());
- toscaArtifacts = component.getToscaArtifacts();
-
- for (ArtifactDefinition artifact : toscaArtifacts.values()) {
- assertEquals(artifact.getEsId(), artifact.getUniqueId());
- List<Pair<String, String>> fields = new ArrayList();
- fields.add(new Pair<String, String>("id", artifact.getEsId()));
- List<Row> fetchFromTable = CassandraUtils.fetchFromTableQuery("sdcartifact", "resources", fields);
- assertTrue(1 == fetchFromTable.size());
- }
- }*/
-
- /*@Test
- public void validateToscaArtifactsBeforeAndAfterSFT() throws IOException, Exception {
- // TODO ADD VF and Service
- validateToscaArtifactsBeforeAndAfterSFT(resourceDetails1);
- validateToscaArtifactsBeforeAndAfterSFT(resourceCP);
- validateToscaArtifactsBeforeAndAfterSFT(resourceVL);
- }*/
-
- @Test
- public void validateToscaPlaceHoldersByConfig() throws IOException, Exception {
- List<Component> components = new ArrayList<>();
- RestResponse componentGetResponse = ResourceRestUtils.getResource(resourceDetails1, sdncDesignerDetails1);
- components.add(ResponseParser.convertResourceResponseToJavaObject(componentGetResponse.getResponse()));
-
- componentGetResponse = ResourceRestUtils.getResource(resourceCP, sdncDesignerDetails1);
- components.add(ResponseParser.convertResourceResponseToJavaObject(componentGetResponse.getResponse()));
-
- componentGetResponse = ResourceRestUtils.getResource(resourceVF, sdncDesignerDetails1);
- components.add(ResponseParser.convertResourceResponseToJavaObject(componentGetResponse.getResponse()));
-
- componentGetResponse = ResourceRestUtils.getResource(resourceVL, sdncDesignerDetails1);
- components.add(ResponseParser.convertResourceResponseToJavaObject(componentGetResponse.getResponse()));
-
- Service service = AtomicOperationUtils
- .createServiceByCategory(ServiceCategoriesEnum.MOBILITY, UserRoleEnum.DESIGNER, true).left().value();
- componentGetResponse = ServiceRestUtils.getService(service.getUniqueId(),
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- components.add(ResponseParser.parseToObjectUsingMapper(componentGetResponse.getResponse(), Service.class));
-
- for (Component component : components) {
- Map<String, ArtifactDefinition> toscaArtifacts = component.getToscaArtifacts();
- assertNotNull("toscaArtifacts list is null", toscaArtifacts);
- List<String> listOfToscaArtTypesFromConfig = Utils.getListOfToscaArtLabels(true);
- assertNotNull("tosca artifact types list is null", listOfToscaArtTypesFromConfig);
- for (String toscaArtType : listOfToscaArtTypesFromConfig) {
- assertNotNull("placeholder of " + toscaArtType + " type doesn't exist",
- toscaArtifacts.get(toscaArtType));
- }
- }
-
- }
-
- // test check configuration of "displayName" field for "heat" type
- // deployment artifact
- @Test
- public void validateDeploymentPlaceHoldersDescriptionOfHeatByConfig() throws IOException {
-
- Map<String, Object> mapOfDepResArtTypesObjects = getMapOfDepResArtTypesObjects();
- assertNotNull("deployment artifact types list is null", mapOfDepResArtTypesObjects);
- Object object = mapOfDepResArtTypesObjects.get("heat");
- if (object instanceof Map<?, ?>) {
- Map<String, Object> map = (Map<String, Object>) object;
- assertTrue(map.get("displayName").equals("Base HEAT Template"));
- } else {
- assertTrue("return object does not instance of map", false);
- }
- }
-
- @Test
- public void addDepResArtEachType() throws Exception {
-
- String artType;
-
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatArtifactDetails);
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatVolArtifactDetails);
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatNetArtifactDetails);
- RestResponse response = ResourceRestUtils.getResource(resourceDetails1.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
- List<String> listOfResDepArtTypesFromConfig = Utils.getListOfDepResArtLabels(true);
- assertNotNull("deployment artifact types list is null", listOfResDepArtTypesFromConfig);
- for (String iter : listOfResDepArtTypesFromConfig) {
- artType = iter;
- verifyDepArtPlaceHoldersByType(artType);
- }
- }
-
- @Test
- public void checkHeatParametersExistingForEachType() throws Exception {
-
- String artType;
-
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatArtifactDetails);
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatVolArtifactDetails);
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatNetArtifactDetails);
- RestResponse response = ResourceRestUtils.getResource(resourceDetails1.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
- List<String> listOfResDepArtTypesFromConfig = Utils.getListOfDepResArtLabels(true);
- assertNotNull("deployment artifact types list is null", listOfResDepArtTypesFromConfig);
- for (String iter : listOfResDepArtTypesFromConfig) {
- artType = iter;
- verifyDepArtPlaceHoldersByType(artType);
- verifyHeatParametersExistance(artType, false);
- }
- }
-
- @Test
- public void checkHeatParametersExistingForSpecificType() throws Exception {
-
- String artType;
-
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatVolArtifactDetails);
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatNetArtifactDetails);
- RestResponse response = ResourceRestUtils.getResource(resourceDetails1.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
- List<String> listOfResDepArtTypesFromConfig = Utils.getListOfDepResArtLabels(true);
- assertNotNull("deployment artifact types list is null", listOfResDepArtTypesFromConfig);
- for (String iter : listOfResDepArtTypesFromConfig) {
- artType = iter;
- if (heatArtifactDetails.getArtifactLabel().equals(iter)) {
- verifyHeatParametersExistance(artType, true);
- } else {
- verifyHeatParametersExistance(artType, false);
- }
- }
- }
-
- @Test
- public void addAndDeleteDepResArtEachType() throws Exception {
-
- String artType;
-
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatArtifactDetails);
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatVolArtifactDetails);
- addDeploymentArtifactByTypeToResource(resourceDetails1, heatNetArtifactDetails);
- RestResponse response = ResourceRestUtils.getResource(resourceDetails1.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
- List<String> listOfResDepArtTypesFromConfig = Utils.getListOfDepResArtLabels(true);
- assertNotNull("deployment artifact types list is null", listOfResDepArtTypesFromConfig);
- for (String iter : listOfResDepArtTypesFromConfig) {
- artType = iter;
- verifyDepArtPlaceHoldersByType(artType);
- }
- RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails1,
- sdncDesignerDetails1, LifeCycleStatesEnum.CHECKIN);
- assertTrue("expected response code in CHECKIN 200", restResponseResource.getErrorCode() == 200);
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails1, sdncDesignerDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- assertTrue("expected response code in CHECKOUT 200", restResponseResource.getErrorCode() == 200);
-
- // delete all deployment artifacts
- deleteDeploymentArtifactByTypeToResource(resourceDetails1, heatArtifactDetails);
- deleteDeploymentArtifactByTypeToResource(resourceDetails1, heatVolArtifactDetails);
- deleteDeploymentArtifactByTypeToResource(resourceDetails1, heatNetArtifactDetails);
- response = ResourceRestUtils.getResource(resourceDetails1.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
- listOfResDepArtTypesFromConfig = Utils.getListOfDepResArtLabels(true);
- assertNotNull("deployment artifact types list is null", listOfResDepArtTypesFromConfig);
- for (String iter : listOfResDepArtTypesFromConfig) {
- artType = iter;
- verifyDepArtPlaceHoldersByType(artType);
- }
- }
-
- @Test
- public void addRemoveAddAgainArtifact() throws Exception {
-
- // get MAP before upload artifact
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails1, sdncDesignerDetails1);
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
-
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get("heat");
-
- // validate place holder exist
- assertNotNull(artifactDefinition);
-
- // add artifact
- updateArtifactReqDetails = getUpdateArtifactDetails(ArtifactTypeEnum.HEAT.getType());
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(
- updateArtifactReqDetails, sdncDesignerDetails1, resourceDetails1.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: "
- + addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + addInformationalArtifactToResource.getErrorCode(),
- addInformationalArtifactToResource.getErrorCode() == 200);
-
- ArtifactDefinition artifactDefinitionResponseJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(addInformationalArtifactToResource.getResponse());
- ArtifactDefinition artDef1 = fillArtDefFromResponse(artifactDefinitionResponseJavaObject);
-
- // remove artifact
- RestResponse deleteArtifactFromResource = ArtifactRestUtils.deleteInformationalArtifactFromResource(
- resourceDetails1.getUniqueId(), updateArtifactReqDetails, sdncDesignerDetails1);
- logger.debug(
- "addInformationalArtifactToResource response: " + deleteArtifactFromResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + deleteArtifactFromResource.getErrorCode(),
- deleteArtifactFromResource.getErrorCode() == 200);
-
- RestResponse getResourceResp = ResourceRestUtils.getResource(resourceDetails1, sdncDesignerDetails1);
-
- artifactDefinitionResponseJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(deleteArtifactFromResource.getResponse());
- assertTrue(artifactDefinitionResponseJavaObject.getArtifactName().isEmpty());
- assertTrue(artifactDefinitionResponseJavaObject.getDescription().isEmpty());
- assertTrue(artifactDefinitionResponseJavaObject.getArtifactChecksum().isEmpty());
- assertTrue(artifactDefinitionResponseJavaObject.getEsId().isEmpty());
- assertTrue(artifactDefinitionResponseJavaObject.getArtifactUUID().isEmpty());
- assertNull(artifactDefinitionResponseJavaObject.getHeatParameters());
-
- // add artifact again with different user
- addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails1, resourceDetails1.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: "
- + addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + addInformationalArtifactToResource.getErrorCode(),
- addInformationalArtifactToResource.getErrorCode() == 200);
-
- artifactDefinitionResponseJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(addInformationalArtifactToResource.getResponse());
- ArtifactDefinition artDef2 = fillArtDefFromResponse(artifactDefinitionResponseJavaObject);
-
- assertFalse("check artifact checksum", artDef1.getArtifactChecksum().equals(artDef2.getArtifactChecksum()));
- assertTrue("check artifact EsId", artDef1.getEsId().equals(artDef2.getEsId()));
- assertFalse("check artifact UUID", artDef1.getArtifactUUID().equals(artDef2.getArtifactUUID()));
- assertTrue("check UserIdCreator", artDef1.getUserIdCreator().equals(artDef2.getUserIdCreator()));
- assertTrue("check UserIdLastUpdater", artDef1.getUserIdLastUpdater().equals(artDef2.getUserIdLastUpdater()));
- }
-
- @Test
- public void addUpdateArtifactByType() throws Exception {
-
- // get MAP before upload artifact
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails1, sdncDesignerDetails1);
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
-
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get("heat");
-
- // validate place holder exist
- assertNotNull(artifactDefinition);
-
- // add artifact
- updateArtifactReqDetails = getUpdateArtifactDetails(ArtifactTypeEnum.HEAT.getType());
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(
- updateArtifactReqDetails, sdncDesignerDetails1, resourceDetails1.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: "
- + addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + addInformationalArtifactToResource.getErrorCode(),
- addInformationalArtifactToResource.getErrorCode() == 200);
-
- ArtifactDefinition artifactDefinitionResponseJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(addInformationalArtifactToResource.getResponse());
- ArtifactDefinition artDef1 = fillArtDefFromResponse(artifactDefinitionResponseJavaObject);
-
- RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails1,
- sdncDesignerDetails1, LifeCycleStatesEnum.CHECKIN);
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails1, sdncDesignerDetails2,
- LifeCycleStatesEnum.CHECKOUT);
-
- // update with different user artifact
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setUniqueId(artifactDefinition.getUniqueId());
- heatArtifactDetails.setArtifactName("2.yaml");
- heatArtifactDetails.setArtifactLabel(artifactDefinition.getArtifactLabel());
-
- addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails2, resourceDetails1.getUniqueId(), "heat");
- logger.debug("addInformationalArtifactToResource response: "
- + addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + addInformationalArtifactToResource.getErrorCode(),
- addInformationalArtifactToResource.getErrorCode() == 200);
-
- artifactDefinitionResponseJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(addInformationalArtifactToResource.getResponse());
- ArtifactDefinition artDef2 = fillArtDefFromResponse(artifactDefinitionResponseJavaObject);
- verifyArtDefFields(artDef1, artDef2);
-
- }
-
- @Test
- public void addUpdateDeleteArtifact() throws Exception {
-
- // get MAP before upload artifact
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails1, sdncDesignerDetails1);
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
-
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get("heat");
-
- // validate place holder exist
- assertNotNull(artifactDefinition);
-
- updateArtifactReqDetails = getUpdateArtifactDetails(ArtifactTypeEnum.HEAT.getType());
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(
- updateArtifactReqDetails, sdncDesignerDetails1, resourceDetails1.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: "
- + addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + addInformationalArtifactToResource.getErrorCode(),
- addInformationalArtifactToResource.getErrorCode() == 200);
-
- ArtifactDefinition artifactDefinitionResponseJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(addInformationalArtifactToResource.getResponse());
- ArtifactDefinition artDef1 = fillArtDefFromResponse(artifactDefinitionResponseJavaObject);
-
- RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails1,
- sdncDesignerDetails1, LifeCycleStatesEnum.CHECKIN);
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails1, sdncDesignerDetails2,
- LifeCycleStatesEnum.CHECKOUT);
-
- // update with different user artifact
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setArtifactName("2.yaml");
-
- addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails2, resourceDetails1.getUniqueId(), "heat");
- logger.debug("addInformationalArtifactToResource response: "
- + addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + addInformationalArtifactToResource.getErrorCode(),
- addInformationalArtifactToResource.getErrorCode() == 200);
-
- artifactDefinitionResponseJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(addInformationalArtifactToResource.getResponse());
- ArtifactDefinition artDef2 = fillArtDefFromResponse(artifactDefinitionResponseJavaObject);
-
- verifyArtDefFields(artDef1, artDef2);
-
- RestResponse delteArtifactFromResource = ArtifactRestUtils.deleteInformationalArtifactFromResource(
- resourceDetails1.getUniqueId(), heatArtifactDetails, sdncDesignerDetails2);
- logger.debug("addInformationalArtifactToResource response: {}", delteArtifactFromResource.getResponseMessage());
- assertTrue("response code is not 200, returned :" + delteArtifactFromResource.getErrorCode(),
- delteArtifactFromResource.getErrorCode() == 200);
-
- }
-
- @Test
- public void addHeatVolArtInvalidExtension() throws Exception {
-
- heatVolArtifactDetails.setArtifactName("heatVol.txt");
- RestResponse response = getResponseOnAddDeploymentArtifactByTypeToResource(resourceDetails1,
- heatVolArtifactDetails);
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
- assertEquals("Check response code after upload artifact", errorInfo.getCode(), response.getErrorCode());
- List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT_VOL.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables,
- response.getResponse());
- }
-
- @Test
- public void addHeatNetArtInvalidExtension() throws Exception {
-
- heatNetArtifactDetails.setArtifactName("yaml");
- RestResponse response = getResponseOnAddDeploymentArtifactByTypeToResource(resourceDetails1,
- heatNetArtifactDetails);
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
- assertEquals("Check response code after upload artifact", errorInfo.getCode(), response.getErrorCode());
- List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT_NET.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables,
- response.getResponse());
- }
-
- @Test
- public void checkServiceSecurityTemplateInformationalArtifactsCreation() throws IOException, Exception {
-
- Either<Service, RestResponse> createServiceResponse = AtomicOperationUtils
- .createServiceByCategory(ServiceCategoriesEnum.MOBILITY, UserRoleEnum.DESIGNER, true);
- Map<String, ArtifactDefinition> artifacts = null;
- ArtifactDefinition securitytemplate = null;
- if (createServiceResponse.isLeft()) {
- Component component = createServiceResponse.left().value();
- artifacts = component.getArtifacts();
- securitytemplate = artifacts.get("servicesecuritytemplate");
- assertNotNull(securitytemplate);
- assertEquals("Service Security Template", securitytemplate.getArtifactDisplayName());
- } else {
- logger.debug("checkSecurityTemplateInformationalArtifactsCreation service creation response: "
- + createServiceResponse.right().value().getResponseMessage());
- }
- }
-
- @Test
- public void checkResourceSecurityTemplateInformationalArtifactsCreation() throws IOException, Exception {
-
- Resource resource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.CONTAINER_APPLICATION, ResourceCategoryEnum.APPLICATION_L4_BORDER,
- UserRoleEnum.DESIGNER, true).left().value();
- Map<String, ArtifactDefinition> artifacts = resource.getArtifacts();
- ArtifactDefinition securitytemplate = artifacts.get("resourcesecuritytemplate");
- assertNotNull(securitytemplate);
- assertEquals("Resource Security Template", securitytemplate.getArtifactDisplayName());
- }
-
- // Benny
- @Test
- public void serviceSecurityTemplateInformationalArtifact() throws IOException, Exception {
- String artifactPlaceHolder = "servicesecuritytemplate";
- Service service = AtomicOperationUtils
- .createServiceByCategory(ServiceCategoriesEnum.MOBILITY, UserRoleEnum.DESIGNER, true).left().value();
- Map<String, ArtifactDefinition> artifacts = service.getArtifacts();
- ArtifactDefinition securitytemplate = artifacts.get(artifactPlaceHolder);
- assertNotNull(securitytemplate);
- assertEquals("Service Security Template", securitytemplate.getArtifactDisplayName());
- assertEquals("OTHER", securitytemplate.getArtifactType());
- assertEquals(artifactPlaceHolder, securitytemplate.getArtifactLabel());
- // Get service
- RestResponse getService = ServiceRestUtils.getService(service.getUniqueId(),
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, getService.getErrorCode().intValue());
- service = ResponseParser.parseToObjectUsingMapper(getService.getResponse(), Service.class);
- artifacts = service.getArtifacts();
- securitytemplate = artifacts.get(artifactPlaceHolder);
- assertNotNull(securitytemplate);
- assertEquals("Service Security Template", securitytemplate.getArtifactDisplayName());
- assertEquals("OTHER", securitytemplate.getArtifactType());
- assertEquals(artifactPlaceHolder, securitytemplate.getArtifactLabel());
- }
-
- @Test
- public void resourceSecurityTemplateInformationalArtifacts() throws IOException, Exception {
- String artifactPlaceHolder = "resourcesecuritytemplate";
- Resource resource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.CONTAINER_APPLICATION, ResourceCategoryEnum.APPLICATION_L4_BORDER,
- UserRoleEnum.DESIGNER, true).left().value();
- Map<String, ArtifactDefinition> artifacts = resource.getArtifacts();
- ArtifactDefinition securitytemplate = artifacts.get("resourcesecuritytemplate");
- assertNotNull(securitytemplate);
- assertEquals("Resource Security Template", securitytemplate.getArtifactDisplayName());
- assertEquals("OTHER", securitytemplate.getArtifactType());
- assertEquals(artifactPlaceHolder, securitytemplate.getArtifactLabel());
- // Get resource
- RestResponse getresource = ResourceRestUtils.getResource(ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- resource.getUniqueId());
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, getresource.getErrorCode().intValue());
- resource = ResponseParser.parseToObjectUsingMapper(getresource.getResponse(), Resource.class);
- artifacts = resource.getArtifacts();
- securitytemplate = artifacts.get(artifactPlaceHolder);
- assertNotNull(securitytemplate);
- assertEquals("Resource Security Template", securitytemplate.getArtifactDisplayName());
- assertEquals("OTHER", securitytemplate.getArtifactType());
- assertEquals(artifactPlaceHolder, securitytemplate.getArtifactLabel());
- }
-
- // ================================================
-
- @SuppressWarnings("unchecked")
- private Map<String, Object> getMapOfDepResArtTypesObjects() throws FileNotFoundException {
-
- return (Map<String, Object>) Utils.parseYamlConfig("deploymentResourceArtifacts");
-
- }
-
- private void addDeploymentArtifactByTypeToResource(ResourceReqDetails resourceReqDetails,
- ArtifactReqDetails artReqDetails) throws IOException, Exception {
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(artReqDetails,
- sdncDesignerDetails1, resourceReqDetails.getUniqueId());
- assertTrue("add" + artReqDetails.getArtifactLabel() + " artifact to resource request returned status:"
- + response.getErrorCode(), response.getErrorCode() == 200);
- }
-
- private RestResponse getResponseOnAddDeploymentArtifactByTypeToResource(ResourceReqDetails resourceReqDetails,
- ArtifactReqDetails artReqDetails) throws IOException, Exception {
-
- return ArtifactRestUtils.addInformationalArtifactToResource(artReqDetails, sdncDesignerDetails1,
- resourceReqDetails.getUniqueId());
- }
-
- private void deleteDeploymentArtifactByTypeToResource(ResourceReqDetails resourceReqDetails,
- ArtifactReqDetails artReqDetails) throws IOException, Exception {
-
- RestResponse response = ArtifactRestUtils.deleteInformationalArtifactFromResource(
- resourceReqDetails.getUniqueId(), artReqDetails, sdncDesignerDetails1);
- assertTrue("delete" + artReqDetails.getArtifactLabel() + " artifact to resource request returned status:"
- + response.getErrorCode(), response.getErrorCode() == 200);
- }
-
- private void verifyDepArtPlaceHoldersByType(String artType) {
-
- Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts();
- assertNotNull("deployment artifact data is null", deploymentArtifacts.get(artType));
- assertNotNull("deployment artifact data is null", deploymentArtifacts.get(artType).getEsId());
- assertNotNull("deployment artifact data is null", deploymentArtifacts.get(artType).getDescription());
- assertTrue(
- "deployment artifact timeout does not equal to default value " + timeOut + " expected " + timeOut
- + ", actual - " + deploymentArtifacts.get(artType).getTimeout(),
- deploymentArtifacts.get(artType).getTimeout() == timeOut);
- assertTrue("deployment artifact label value ",
- deploymentArtifacts.get(artType).getArtifactLabel().equals(artType));
- }
-
- private void verifyHeatParametersExistance(String artType, Boolean isNull) {
- Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts();
- if (isNull) {
- assertNull("heatParameters list for type " + artType + " is not null",
- deploymentArtifacts.get(artType).getHeatParameters());
- } else {
- assertNotNull("heatParameters list for type " + artType + " is null",
- deploymentArtifacts.get(artType).getHeatParameters());
- }
- }
-
- private void verifyArtDefFields(ArtifactDefinition artDef1, ArtifactDefinition artDef2) {
-
- assertFalse("check artifact checksum", artDef1.getArtifactChecksum().equals(artDef2.getArtifactChecksum()));
- assertFalse("check artifact EsId", artDef1.getEsId().equals(artDef2.getEsId()));
- assertFalse("check artifact UUID", artDef1.getArtifactUUID().equals(artDef2.getArtifactUUID()));
- assertTrue("check UserIdCreator", artDef1.getUserIdCreator().equals(artDef2.getUserIdCreator()));
- assertFalse("check UserIdLastUpdater", artDef1.getUserIdLastUpdater().equals(artDef2.getUserIdLastUpdater()));
-
- }
-
- private ArtifactDefinition fillArtDefFromResponse(ArtifactDefinition artifactDefinitionResponseJavaObject) {
- ArtifactDefinition artDef = new ArtifactDefinition();
- artDef.setArtifactChecksum(artifactDefinitionResponseJavaObject.getArtifactChecksum());
- artDef.setEsId(artifactDefinitionResponseJavaObject.getEsId());
- artDef.setArtifactUUID(artifactDefinitionResponseJavaObject.getArtifactUUID());
- artDef.setUserIdCreator(artifactDefinitionResponseJavaObject.getUserIdCreator());
- artDef.setUserIdLastUpdater(artifactDefinitionResponseJavaObject.getUserIdLastUpdater());
- return artDef;
- }
-
- private ArtifactReqDetails getUpdateArtifactDetails(String artType) throws IOException, Exception {
- String ext = heatExtension;
- String sourceDir = config.getResourceConfigDir();
- String testResourcesPath = sourceDir + File.separator + folderName;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}", listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, ext, true);
- ArtifactReqDetails updateArtifactReqDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
- updateArtifactReqDetails.setPayload(payload);
- updateArtifactReqDetails.setArtifactName("1.yaml");
- return updateArtifactReqDetails;
- }
-}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java
deleted file mode 100644
index 09c4d387a2..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.artifacts;
-
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.RespJsonKeysEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.validation.ArtifactValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.testng.AssertJUnit;
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class ValidateHeatArtFieldsTypes extends ComponentBaseTest {
-
- protected User sdncDesignerDetails;
- protected ResourceReqDetails resourceDetails;
- protected ServiceReqDetails serviceDetails;
-
- private static final String heatExtension = "yaml";
- private static final String yangXmlExtension = "xml";
- private static final String muranoPkgExtension = "zip";
- private final String folderName = "yamlFieldsValidation";
-
- private final String uuidString = RespJsonKeysEnum.UUID.getRespJsonKeyName().toString();
-
- public ValidateHeatArtFieldsTypes() {
- super(name, ValidateHeatArtFieldsTypes.class.getName());
- }
-
- @Rule
- public static TestName name = new TestName();
-
- @Test
- public void validateHeatArtFiledTypes() throws Exception {
-
- // get relevant resource and service
-
- sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- resourceDetails = ElementFactory.getDefaultResource();
-
- RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails);
- AssertJUnit.assertTrue("create request returned status:" + response.getErrorCode(),
- response.getErrorCode() == 201);
-
- // add artifact to resource1
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- List<String> listOfArtifactFromFolder = ArtifactValidationUtils.getListOfArtifactFromFolder(folderName);
- for (int i = 0; i < listOfArtifactFromFolder.size(); i++) {
- heatArtifactDetails = ArtifactValidationUtils.replaceDefaultArtWithArtFromList(heatArtifactDetails,
- heatExtension, folderName, i);
- response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails,
- resourceDetails.getUniqueId());
-
- if (heatArtifactDetails.getArtifactName().contains("bool")) {
- if (heatArtifactDetails.getArtifactName().contains("negative")) {
- // validate negative response
- List<String> variables = Arrays.asList("HEAT", "boolean", "city_name");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_HEAT_PARAMETER_VALUE.name(),
- variables, response.getResponse());
- }
- if (heatArtifactDetails.getArtifactName().contains("positive")) {
- AssertJUnit.assertTrue(
- "add HEAT artifact to resource request returned status:" + response.getErrorCode()
- + " fileName: " + heatArtifactDetails.getArtifactName(),
- response.getErrorCode() == 200);
- ArtifactDefinition artifactDefinitionJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(response.getResponse());
- List<HeatParameterDataDefinition> heatParameters = artifactDefinitionJavaObject.getHeatParameters();
- String currentValue = null;
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- if (heatParameterDefinition.getName().equals("city_name")) {
- currentValue = heatParameterDefinition.getCurrentValue();
- }
- }
- if (heatArtifactDetails.getArtifactName().contains("true")) {
- AssertJUnit.assertTrue(currentValue.equals("true"));
- }
- if (heatArtifactDetails.getArtifactName().contains("false")) {
- AssertJUnit.assertTrue(currentValue.equals("false"));
- }
- RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils
- .deleteInformationalArtifactFromResource(resourceDetails.getUniqueId(), heatArtifactDetails,
- sdncDesignerDetails);
- AssertJUnit.assertTrue(
- "delete HEAT artifact from resource request returned status:"
- + deleteInformationalArtifactFromResource.getErrorCode(),
- deleteInformationalArtifactFromResource.getErrorCode() == 200);
- }
-
- } else if (heatArtifactDetails.getArtifactName().contains("number")) {
- if (heatArtifactDetails.getArtifactName().contains("negative")) {
- // validate negative response
- List<String> variables = Arrays.asList("HEAT", "number", "city_name");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_HEAT_PARAMETER_VALUE.name(),
- variables, response.getResponse());
- }
- if (heatArtifactDetails.getArtifactName().contains("positive")) {
- AssertJUnit.assertTrue(
- "add HEAT artifact to resource request returned status:" + response.getErrorCode()
- + " fileName: " + heatArtifactDetails.getArtifactName(),
- response.getErrorCode() == 200);
- }
-
- } else if (heatArtifactDetails.getArtifactName().contains("string")) {
- if (heatArtifactDetails.getArtifactName().contains("negative")) {
- // validate negative response
- List<String> variables = Arrays.asList("HEAT", "string", "city_name");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_HEAT_PARAMETER_VALUE.name(),
- variables, response.getResponse());
- }
- if (heatArtifactDetails.getArtifactName().contains("positive")) {
- AssertJUnit.assertTrue(
- "add HEAT artifact to resource request returned status:" + response.getErrorCode()
- + " fileName: " + heatArtifactDetails.getArtifactName(),
- response.getErrorCode() == 200);
- }
-
- }
-
- else if (heatArtifactDetails.getArtifactName().contains("unsupported")) {
-
- // validate negative response
- List<String> variables = Arrays.asList("HEAT", "number123");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_HEAT_PARAMETER_TYPE.name(),
- variables, response.getResponse());
-
- }
-
- else {
- AssertJUnit.assertTrue(
- "add HEAT artifact to resource request returned status:" + response.getErrorCode(),
- response.getErrorCode() == 200);
- }
- }
-
- }
-
-}