summaryrefslogtreecommitdiffstats
path: root/asdc-tests
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-tests')
-rw-r--r--asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ArtifactTypeEnum.java2
-rw-r--r--asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java28
-rw-r--r--asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ToscaTemplateVersionTest.java67
-rw-r--r--asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java50
-rw-r--r--asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java2
-rw-r--r--asdc-tests/src/test/resources/CI/tests/importToscaResourceByCreateUrl/loadBalancerTestVersion.yml6
6 files changed, 123 insertions, 32 deletions
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ArtifactTypeEnum.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ArtifactTypeEnum.java
index eafdf80a0a..724fca2b4d 100644
--- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ArtifactTypeEnum.java
+++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ArtifactTypeEnum.java
@@ -33,7 +33,7 @@ public enum ArtifactTypeEnum {
TOSCA_TEMPLATE("TOSCA_TEMPLATE"), TOSCA_CSAR("TOSCA_CSAR"), VNF_CATALOG("VNF_CATALOG"), VF_LICENSE("VF_LICENSE"), VENDOR_LICENSE("VENDOR_LICENSE"),
MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), APPC_CONFIG("APPC_CONFIG"), HEAT_NESTED("HEAT_NESTED"),
HEAT_ARTIFACT("HEAT_ARTIFACT"), VF_MODULES_METADATA("VF_MODULES_METADATA"), LIFECYCLE_OPERATIONS("LIFECYCLE_OPERATIONS"),
- VES_EVENTS("VES_EVENTS"), PERFORMANCE_COUNTER("PERFORMANCE_COUNTER"),
+ VES_EVENTS("VES_EVENTS"), PERFORMANCE_COUNTER("PERFORMANCE_COUNTER"), UCPE_LAYER_2_CONFIGURATION("UCPE_LAYER_2_CONFIGURATION"),
// DCAE Artifacts
DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"), DCAE_EVENT("DCAE_EVENT"), DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"),
DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"),
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java
index 5f0cbaf1c7..2edd3284c4 100644
--- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java
+++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.openecomp.sdc.ci.tests.utils.ToscaParserUtils.downloadAndParseToscaTemplate;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -67,7 +68,9 @@ 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.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+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.ImportUtils;
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.ComponentInstanceRestUtils;
@@ -362,7 +365,7 @@ public class ExportToscaTest extends ComponentBaseTest {
JsonParser jsonParser = new JsonParser();
- for (Map.Entry<String, List<ComponentInstanceProperty>> entry : componentInstancesProperties.entrySet()) {
+ for (Entry<String, List<ComponentInstanceProperty>> entry : componentInstancesProperties.entrySet()) {
Optional<ComponentInstance> findFirst = componentInstances.stream().filter(ci -> ci.getUniqueId().equals(entry.getKey())).findFirst();
assertTrue(findFirst.isPresent());
@@ -627,29 +630,6 @@ public class ExportToscaTest extends ComponentBaseTest {
assertEquals("validate input description", inputDef.getDescription(), (String) inputInFile.get("description"));
}
- private Map<String, Object> downloadAndParseToscaTemplate(User sdncModifierDetails, Component createdComponent) throws Exception {
- String artifactUniqeId = createdComponent.getToscaArtifacts().get("assettoscatemplate").getUniqueId();
- RestResponse toscaTemplate;
-
- if (createdComponent.getComponentType() == ComponentTypeEnum.RESOURCE) {
- toscaTemplate = ArtifactRestUtils.downloadResourceArtifactInternalApi(createdComponent.getUniqueId(), sdncModifierDetails, artifactUniqeId);
-
- } else {
- toscaTemplate = ArtifactRestUtils.downloadServiceArtifactInternalApi(createdComponent.getUniqueId(), sdncModifierDetails, artifactUniqeId);
- }
- BaseRestUtils.checkSuccess(toscaTemplate);
-
- ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(toscaTemplate.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;
- }
-
public ArtifactDefinition findMasterArtifact(Map<String, ArtifactDefinition> deplymentArtifact, List<ArtifactDefinition> artifacts, List<String> artifactsList) {
for (String artifactUid : artifactsList) {
for (Entry<String, ArtifactDefinition> entry : deplymentArtifact.entrySet()) {
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ToscaTemplateVersionTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ToscaTemplateVersionTest.java
new file mode 100644
index 0000000000..1fbcd428ca
--- /dev/null
+++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ToscaTemplateVersionTest.java
@@ -0,0 +1,67 @@
+package org.openecomp.sdc.ci.tests.execute.imports;
+
+import org.junit.rules.TestName;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
+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.ToscaParserUtils;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openecomp.sdc.ci.tests.utils.general.ImportUtils;
+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.rest.ServiceRestUtils;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class ToscaTemplateVersionTest extends ComponentBaseTest {
+
+ private static final String EXPECTED_EXPORT_TOSCA_VERSION = "tosca_simple_yaml_1_1";
+ private static final String YML_110_VERSION = "loadBalancerTestVersion.yml";
+ public static TestName name = new TestName();
+ private String SOURCE_DIR;
+ private static String WORK_DIR = "importToscaResourceByCreateUrl";
+
+ public ToscaTemplateVersionTest() {
+ super(name, ToscaTemplateVersionTest.class.getName());
+ }
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ SOURCE_DIR = config.getResourceConfigDir();
+ }
+
+ @Test
+ public void verifyExportYamlVersion() throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciYamlVersionTest", ServiceCategoriesEnum.MOBILITY, defaultUser.getUserId());
+ RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, defaultUser);
+ BaseRestUtils.checkCreateResponse(serviceResponse);
+ Service service = ResponseParser.parseToObjectUsingMapper(serviceResponse.getResponse(), Service.class);
+ Map<String, Object> load = ToscaParserUtils.downloadAndParseToscaTemplate(defaultUser, service);
+ assertEquals(ToscaParserUtils.getToscaVersion(load), EXPECTED_EXPORT_TOSCA_VERSION);
+ }
+
+ @Test
+ public void testVerifyImportYamlVersion_1_1_0() throws Exception {
+ String testResourcesPath = Paths.get(SOURCE_DIR, WORK_DIR).toString();
+ ImportReqDetails importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(ElementFactory.getDefaultImportResource(), testResourcesPath,
+ YML_110_VERSION);
+ RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null);
+ BaseRestUtils.checkCreateResponse(importResourceResponse);
+
+ }
+}
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
index e5928b327f..5449a5fc6b 100644
--- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
+++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
@@ -22,19 +22,30 @@ package org.openecomp.sdc.ci.tests.utils;
import static org.testng.AssertJUnit.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.apache.commons.codec.binary.Base64;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.datatypes.enums.ToscaKeysEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaNodeTemplatesTopologyTemplateDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaNodeTypesDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaPropertiesNodeTemplatesDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaRequirementsNodeTemplatesDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinition;
+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.ResponseParser;
import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,6 +65,29 @@ public class ToscaParserUtils {
return null;
}
+ public static Map<String, Object> downloadAndParseToscaTemplate(User sdncModifierDetails, Component createdComponent) throws Exception {
+ String artifactUniqeId = createdComponent.getToscaArtifacts().get("assettoscatemplate").getUniqueId();
+ RestResponse toscaTemplate;
+
+ if (createdComponent.getComponentType() == ComponentTypeEnum.RESOURCE) {
+ toscaTemplate = ArtifactRestUtils.downloadResourceArtifactInternalApi(createdComponent.getUniqueId(), sdncModifierDetails, artifactUniqeId);
+
+ } else {
+ toscaTemplate = ArtifactRestUtils.downloadServiceArtifactInternalApi(createdComponent.getUniqueId(), sdncModifierDetails, artifactUniqeId);
+ }
+ BaseRestUtils.checkSuccess(toscaTemplate);
+
+ ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(toscaTemplate.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;
+ }
+
public static ToscaDefinition getToscaDefinitionObjectByCsarUuid(String csarUUID) throws Exception {
String TOSCAMetaLocation = "TOSCA-Metadata/TOSCA.meta";
@@ -70,7 +104,7 @@ public class ToscaParserUtils {
ToscaKeysEnum toscaKey = ToscaKeysEnum.findToscaKey((String) key);
switch (toscaKey) {
case TOSCA_DEFINITION_VERSION:
- getToscaDefinitionVersion(toscaMap, toscaDefinition);
+ enrichToscaDefinitionWithToscaVersion(toscaMap, toscaDefinition);
break;
case NODE_TYPES:
getToscaNodeTypes(toscaMap, toscaDefinition);
@@ -92,19 +126,23 @@ public class ToscaParserUtils {
}
- public static void getToscaDefinitionVersion(Map<?, ?> toscaMap, ToscaDefinition toscaDefinition) {
+ public static void enrichToscaDefinitionWithToscaVersion(Map<?, ?> toscaMap, ToscaDefinition toscaDefinition) {
if (toscaMap.get("tosca_definitions_version") != null) {
- toscaDefinition.setToscaDefinitionVersion((String) toscaMap.get("tosca_definitions_version"));
+ toscaDefinition.setToscaDefinitionVersion(getToscaVersion(toscaMap));
}
}
+ public static String getToscaVersion(Map<?, ?> toscaMap) {
+ return (String) toscaMap.get("tosca_definitions_version");
+ }
+
// spec 90 page
public static void getToscaNodeTypes(Map<?, ?> toscaMap, ToscaDefinition toscaDefinition) {
@SuppressWarnings("unchecked")
Map<String, Map<String, String>> nodeTypes = (Map<String, Map<String, String>>) toscaMap.get("node_types");
List<ToscaNodeTypesDefinition> listToscaNodeTypes = new ArrayList<>();
if (nodeTypes != null) {
- for (Map.Entry<String, Map<String, String>> entry : nodeTypes.entrySet()) {
+ for (Entry<String, Map<String, String>> entry : nodeTypes.entrySet()) {
ToscaNodeTypesDefinition toscaNodeTypes = new ToscaNodeTypesDefinition();
String toscaNodeName = entry.getKey();
toscaNodeTypes.setName(toscaNodeName);
@@ -179,7 +217,7 @@ public class ToscaParserUtils {
@SuppressWarnings("unchecked")
List<Map<String, Object>> requirementList = (List<Map<String, Object>>) node.get("requirements");
for (int i = 0; i < requirementList.size(); i++) {
- for (Map.Entry<String, Object> requirement : requirementList.get(i).entrySet()) {
+ for (Entry<String, Object> requirement : requirementList.get(i).entrySet()) {
ToscaRequirementsNodeTemplatesDefinition toscaRequirement = new ToscaRequirementsNodeTemplatesDefinition();
if (requirement.getKey() != null) {
String requirementName = requirement.getKey();
@@ -237,7 +275,7 @@ public class ToscaParserUtils {
if (node.get("properties") != null) {
@SuppressWarnings("unchecked")
Map<String, Object> properties = (Map<String, Object>) node.get("properties");
- for (Map.Entry<String, Object> property : properties.entrySet()) {
+ for (Entry<String, Object> property : properties.entrySet()) {
ToscaPropertiesNodeTemplatesDefinition toscaProperty = new ToscaPropertiesNodeTemplatesDefinition();
String propertyName = property.getKey();
Object propertyValue = property.getValue();
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
index 39f2c04b55..6ffb2b29b5 100644
--- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
+++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
@@ -436,7 +436,7 @@ public class ResponseParser {
}
public static List<String> getDerivedListFromJson(RestResponse res) throws JSONException {
- JSONArray listFromJson = getListFromJson(res, "derivedList");
+ JSONArray listFromJson = getListFromJson(res, "derivedFrom");
List<String> lst = new ArrayList<String>();
for (int i = 0; i < listFromJson.length(); i++) {
lst.add(listFromJson.getString(i));
diff --git a/asdc-tests/src/test/resources/CI/tests/importToscaResourceByCreateUrl/loadBalancerTestVersion.yml b/asdc-tests/src/test/resources/CI/tests/importToscaResourceByCreateUrl/loadBalancerTestVersion.yml
new file mode 100644
index 0000000000..6b68dd00d4
--- /dev/null
+++ b/asdc-tests/src/test/resources/CI/tests/importToscaResourceByCreateUrl/loadBalancerTestVersion.yml
@@ -0,0 +1,6 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+node_types:
+ org.openecomp.resource.vfc.nodes.LoadBalancerTest1:
+ derived_from: tosca.nodes.Root
+ properties:
+