diff options
Diffstat (limited to 'test-apis-ci/src/main/java')
20 files changed, 453 insertions, 64 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java index ea1c9eff8d..15a1eb783a 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java @@ -364,5 +364,7 @@ public interface Urls { final String ONBOARD_VERSION = "http://%s:%s/onboarding-api/docs/build-info.json"; final String OS_VERSION = "http://%s:%s/sdc2/rest/version"; +// amdocs APIs + final String GET_VENDOR_SOFTWARE_PRODUCT = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/packages/%s"; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java index 8456e5b35b..5a80fd14ca 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java @@ -35,8 +35,10 @@ public class ResourceReqDetails extends ComponentReqDetails { Boolean isAbstract; Boolean isHighestVersion; String cost; + String licenseType; String toscaResourceName; + String resourceVendorModelNumber; private String resourceType = ResourceTypeEnum.VFC.toString(); // Default // value @@ -45,6 +47,21 @@ public class ResourceReqDetails extends ComponentReqDetails { super(); } + public ResourceReqDetails(List<String> derivedFrom, String vendorName, String vendorRelease, Boolean isAbstract, Boolean isHighestVersion, String cost, String licenseType, String toscaResourceName, String resourceVendorModelNumber, + String resourceType) { + super(); + this.derivedFrom = derivedFrom; + this.vendorName = vendorName; + this.vendorRelease = vendorRelease; + this.isAbstract = isAbstract; + this.isHighestVersion = isHighestVersion; + this.cost = cost; + this.licenseType = licenseType; + this.toscaResourceName = toscaResourceName; + this.resourceVendorModelNumber = resourceVendorModelNumber; + this.resourceType = resourceType; + } + public ResourceReqDetails(Resource resource) { super(); this.resourceType = resource.getResourceType().toString(); @@ -68,6 +85,7 @@ public class ResourceReqDetails extends ComponentReqDetails { this.UUID = resource.getUUID(); this.categories = resource.getCategories(); this.importedToscaChecksum = resource.getImportedToscaChecksum(); + this.resourceVendorModelNumber = resource.getResourceVendorModelNumber(); } @@ -136,6 +154,13 @@ public class ResourceReqDetails extends ComponentReqDetails { this.toscaResourceName = resourceName; } + public String getResourceVendorModelNumber() { + return resourceVendorModelNumber; + } + + public void setResourceVendorModelNumber(String resourceVendorModelNumber) { + this.resourceVendorModelNumber = resourceVendorModelNumber; + } public String getToscaResourceName() { return toscaResourceName; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java index e33183ca94..2f3d648ef6 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java @@ -26,6 +26,43 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.category.CategoryDefinition; public class ServiceReqDetails extends ComponentReqDetails { + + protected String serviceType; + protected String serviceRole; + protected String namingPolicy; + protected Boolean ecompGeneratedNaming; + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceRole() { + return serviceRole; + } + + public void setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + } + + public String getNamingPolicy() { + return namingPolicy; + } + + public void setNamingPolicy(String namingPolicy) { + this.namingPolicy = namingPolicy; + } + + public Boolean getEcompGeneratedNaming() { + return ecompGeneratedNaming; + } + + public void setEcompGeneratedNaming(Boolean ecompGeneratedNaming) { + this.ecompGeneratedNaming = ecompGeneratedNaming; + } public ServiceReqDetails(String serviceName, String category, ArrayList<String> tags, String description, String contactId, String icon) { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java index 7e363202bb..1f578d108c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java @@ -311,7 +311,7 @@ public class ArtifactServletTest extends ComponentBaseTest { httppost.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); httppost.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId()); if (addMd5Header) { - httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5ByString(jsonBody)); + httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5Base64EncodedByString(jsonBody)); } StringEntity input = new StringEntity(jsonBody); input.setContentType("application/json"); 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 index bb2b662009..5f1230f4ce 100644 --- 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 @@ -624,7 +624,7 @@ artifact.setArtifactLabel("configure");*/ httppost.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); httppost.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId()); if (addMd5Header) { - httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5ByString(jsonBody)); + httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5Base64EncodedByString(jsonBody)); } StringEntity input = new StringEntity(jsonBody); input.setContentType("application/json"); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java index 7ba705fc7d..258619292f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java @@ -212,7 +212,7 @@ public class DistributionDownloadArtifactTest extends ComponentBaseTest { AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes())); // validating checksum - String actualPayloadChecksum = GeneralUtility.calculateMD5ByByteArray(actualContents.getBytes()); + String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(actualContents.getBytes()); AssertJUnit.assertEquals(expectedPayloadChecksum, actualPayloadChecksum); // validate audit @@ -380,7 +380,7 @@ public class DistributionDownloadArtifactTest extends ComponentBaseTest { // validating checksum byte[] bytes = actualContents.getBytes(); - String actualPayloadChecksum = GeneralUtility.calculateMD5ByByteArray(bytes); + String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(bytes); assertEquals(expectedPayloadChecksum, actualPayloadChecksum); // validating valid zip diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java index c069f984d2..56deb3e08b 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java @@ -189,7 +189,7 @@ public class ImportNewResourceCITest extends ComponentBaseTest { + " \"icon\": \"router\",\r\n" + " \"tags\": [\r\n" + " \"importResource4test\"\r\n" + " ],\r\n" + " \"payloadData\": \"" + encodedPayload + "\"\r\n" + "}"; - String md5 = GeneralUtility.calculateMD5ByString(json); + String md5 = GeneralUtility.calculateMD5Base64EncodedByString(json); Map<String, String> headers = new HashMap<String, String>(); headers.put(Constants.MD5_HEADER, md5); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java index 18b2329663..d7ac4a5676 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java @@ -29,9 +29,7 @@ public class ToscaDefinition { String tosca_definitions_version; Map<String, String> metadata; -// Map<String, ToscaImportsDefinition> imports; -// TODO waiting for answer about imports representation - Object imports; + List<Map<String, ToscaImportsDefinition>> imports; Map<String, ToscaNodeTypesDefinition> node_types; ToscaTopologyTemplateDefinition topology_template; @@ -39,54 +37,49 @@ public class ToscaDefinition { super(); } - @Override - public String toString() { - return "ToscaDefinition [tosca_definitions_version=" + tosca_definitions_version + ", metadata=" + metadata + ", imports=" + imports + ", node_types=" + node_types + ", topology_template=" + topology_template + "]"; - } - public String getTosca_definitions_version() { - return tosca_definitions_version; - } - public void setTosca_definitions_version(String tosca_definitions_version) { + public ToscaDefinition(String tosca_definitions_version, Map<String, String> metadata, List<Map<String, ToscaImportsDefinition>> imports, Map<String, ToscaNodeTypesDefinition> node_types, + ToscaTopologyTemplateDefinition topology_template) { + super(); this.tosca_definitions_version = tosca_definitions_version; + this.metadata = metadata; + this.imports = imports; + this.node_types = node_types; + this.topology_template = topology_template; } + + public Map<String, String> getMetadata() { return metadata; } + + public void setMetadata(Map<String, String> metadata) { this.metadata = metadata; } - - -// public Map<String,ToscaImportsDefinition> getImports() { -// return (Map<String, ToscaImportsDefinition>) imports; -// } -// -// public void setImports(Map<String,ToscaImportsDefinition> imports) { -// this.imports = imports; -// } -// -// public List<ToscaImportsDefinition> getImports() { -// return (List<ToscaImportsDefinition>) imports; -// } -// -// public void setImports(List<ToscaImportsDefinition> imports) { -// this.imports = imports; -// } - - public Object getImports() { + + public List<Map<String, ToscaImportsDefinition>> getImports() { return imports; } - public void setImports(Object imports) { + public void setImports(List<Map<String, ToscaImportsDefinition>> imports) { this.imports = imports; } + public String getTosca_definitions_version() { + return tosca_definitions_version; + } + + public void setTosca_definitions_version(String tosca_definitions_version) { + this.tosca_definitions_version = tosca_definitions_version; + } + + public Map<String, ToscaNodeTypesDefinition> getNode_types() { return node_types; } @@ -109,9 +102,7 @@ public class ToscaDefinition { public static TypeDescription getTypeDescription(){ TypeDescription typeDescription = new TypeDescription(ToscaDefinition.class); typeDescription.putMapPropertyType("metadata", String.class, String.class); -// TODO Andrey imports format - typeDescription.putMapPropertyType("imports", String.class, ToscaImportsDefinition.class); -// typeDescription.putListPropertyType("imports", List.class); + typeDescription.putListPropertyType("imports", Map.class); typeDescription.putMapPropertyType("node_types", String.class, ToscaNodeTypesDefinition.class); return typeDescription; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java index dc3c40751c..e3051515cd 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java @@ -35,17 +35,17 @@ public class ToscaGroupsTopologyTemplateDefinition { private Map<String, Object> interfaces; private List<String> members; // private Map<String, String> metadata; - private ToscaGroupsMetadataDefinition metadata; + private ToscaServiceGroupsMetadataDefinition metadata; public ToscaGroupsTopologyTemplateDefinition() { super(); } - public ToscaGroupsMetadataDefinition getMetadata() { + public ToscaServiceGroupsMetadataDefinition getMetadata() { return metadata; } - public void setMetadata(ToscaGroupsMetadataDefinition metadata) { + public void setMetadata(ToscaServiceGroupsMetadataDefinition metadata) { this.metadata = metadata; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaImportsDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaImportsDefinition.java index d62e33e1dd..a5070b8662 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaImportsDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaImportsDefinition.java @@ -20,8 +20,11 @@ package org.openecomp.sdc.ci.tests.tosca.datatypes; +import org.yaml.snakeyaml.TypeDescription; + public class ToscaImportsDefinition { + private String name; private String file; private String repository; private String namespace_uri; @@ -32,17 +35,21 @@ public class ToscaImportsDefinition { // TODO Auto-generated constructor stub } - public ToscaImportsDefinition(String file, String repository, String namespace_uri, String namespace_prefix) { + public ToscaImportsDefinition(String name, String file, String repository, String namespace_uri, String namespace_prefix) { super(); + this.name = name; this.file = file; this.repository = repository; this.namespace_uri = namespace_uri; this.namespace_prefix = namespace_prefix; } - @Override - public String toString() { - return "ToscaImportsDefinition [file=" + file + ", repository=" + repository + ", namespace_uri=" + namespace_uri + ", namespace_prefix=" + namespace_prefix + "]"; + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; } public String getFile() { @@ -76,6 +83,13 @@ public class ToscaImportsDefinition { public void setNamespace_prefix(String namespace_prefix) { this.namespace_prefix = namespace_prefix; } + + //gets Type description for Yaml snake + public static TypeDescription getTypeDescription(){ + TypeDescription typeDescription = new TypeDescription(ToscaImportsDefinition.class); + return typeDescription; + } + } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java index 6f9590f0ae..45feadecca 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java @@ -22,6 +22,8 @@ package org.openecomp.sdc.ci.tests.tosca.datatypes; import java.util.Map; +import org.yaml.snakeyaml.TypeDescription; + public class ToscaInputsTopologyTemplateDefinition { private Map<String,Map<String,Object>> inputs; @@ -40,6 +42,10 @@ public class ToscaInputsTopologyTemplateDefinition { } - + //gets Type description for Yaml snake + public static TypeDescription getTypeDescription(){ + TypeDescription typeDescription = new TypeDescription(ToscaInputsTopologyTemplateDefinition.class); + return typeDescription; + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaMetadataDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaMetadataDefinition.java new file mode 100644 index 0000000000..ceba7adbe4 --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaMetadataDefinition.java @@ -0,0 +1,196 @@ +/*- + * ============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.tosca.datatypes; + +import org.yaml.snakeyaml.TypeDescription; + +public class ToscaMetadataDefinition { + + private String invariantUUID; + private String UUID; + private String name; + private String description; + private String type; + private String category; + private String subcategory; + private String resourceVendor; + private String resourceVendorRelease; + private String resourceVendorModelNumber; + private String serviceType; + private String serviceRole; + private String serviceEcompNaming; + private String ecompGeneratedNaming; + private String namingPolicy; + + public ToscaMetadataDefinition(String invariantUUID, String uUID, String name, String description, String type, String category, String subcategory, String resourceVendor, String resourceVendorRelease, String resourceVendorModelNumber, + String serviceType, String serviceRole, String serviceEcompNaming, String ecompGeneratedNaming, String namingPolicy) { + super(); + this.invariantUUID = invariantUUID; + UUID = uUID; + this.name = name; + this.description = description; + this.type = type; + this.category = category; + this.subcategory = subcategory; + this.resourceVendor = resourceVendor; + this.resourceVendorRelease = resourceVendorRelease; + this.resourceVendorModelNumber = resourceVendorModelNumber; + this.serviceType = serviceType; + this.serviceRole = serviceRole; + this.serviceEcompNaming = serviceEcompNaming; + this.ecompGeneratedNaming = ecompGeneratedNaming; + this.namingPolicy = namingPolicy; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getUUID() { + return UUID; + } + + public void setUUID(String uUID) { + UUID = uUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubcategory() { + return subcategory; + } + + public void setSubcategory(String subcategory) { + this.subcategory = subcategory; + } + + public String getResourceVendor() { + return resourceVendor; + } + + public void setResourceVendor(String resourceVendor) { + this.resourceVendor = resourceVendor; + } + + public String getResourceVendorRelease() { + return resourceVendorRelease; + } + + public void setResourceVendorRelease(String resourceVendorRelease) { + this.resourceVendorRelease = resourceVendorRelease; + } + + public String getResourceVendorModelNumber() { + return resourceVendorModelNumber; + } + + public void setResourceVendorModelNumber(String resourceVendorModelNumber) { + this.resourceVendorModelNumber = resourceVendorModelNumber; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceRole() { + return serviceRole; + } + + public void setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + } + + public String getServiceEcompNaming() { + return serviceEcompNaming; + } + + public void setServiceEcompNaming(String serviceEcompNaming) { + this.serviceEcompNaming = serviceEcompNaming; + } + + public String getEcompGeneratedNaming() { + return ecompGeneratedNaming; + } + + public void setEcompGeneratedNaming(String ecompGeneratedNaming) { + this.ecompGeneratedNaming = ecompGeneratedNaming; + } + + public String getNamingPolicy() { + return namingPolicy; + } + + public void setNamingPolicy(String namingPolicy) { + this.namingPolicy = namingPolicy; + } + + @Override + public String toString() { + return "ToscaMetadataDefinition [invariantUUID=" + invariantUUID + ", UUID=" + UUID + ", name=" + name + ", description=" + description + ", type=" + type + ", category=" + category + ", subcategory=" + subcategory + + ", resourceVendor=" + resourceVendor + ", resourceVendorRelease=" + resourceVendorRelease + ", resourceVendorModelNumber=" + resourceVendorModelNumber + ", serviceType=" + serviceType + ", serviceRole=" + serviceRole + + ", serviceEcompNaming=" + serviceEcompNaming + ", ecompGeneratedNaming=" + ecompGeneratedNaming + ", namingPolicy=" + namingPolicy + "]"; + } + + //gets Type description for Yaml snake + public static TypeDescription getTypeDescription(){ + TypeDescription typeDescription = new TypeDescription(ToscaMetadataDefinition.class); + return typeDescription; + } + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsMetadataDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java index eec057ed52..86ca8f56cf 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsMetadataDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java @@ -20,7 +20,7 @@ package org.openecomp.sdc.ci.tests.tosca.datatypes; -public class ToscaGroupsMetadataDefinition { +public class ToscaServiceGroupsMetadataDefinition { private String vfModuleModelName; private String vfModuleModelInvariantUUID; @@ -28,7 +28,7 @@ public class ToscaGroupsMetadataDefinition { private String vfModuleModelUUID; private String vfModuleModelVersion; - public ToscaGroupsMetadataDefinition() { + public ToscaServiceGroupsMetadataDefinition() { super(); // TODO Auto-generated constructor stub } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java new file mode 100644 index 0000000000..cdea2ff69c --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java @@ -0,0 +1,74 @@ +package org.openecomp.sdc.ci.tests.tosca.model; + +public class ToscaMetadataFieldsPresentationEnum { + + public enum ToscaMetadataFieldsEnum { +// general + INVARIANT_UUID ("invariantUUID", ComponentTypeEnum.RESOURCE_SERVICE_NODE_TEMPLATE.value), + UUID ("UUID", ComponentTypeEnum.RESOURCE_SERVICE_NODE_TEMPLATE.value), + NAME ("name", ComponentTypeEnum.RESOURCE_SERVICE_NODE_TEMPLATE.value), + DESCRIPTION ("description", ComponentTypeEnum.RESOURCE_SERVICE_NODE_TEMPLATE.value), + CATEGORY ("category", ComponentTypeEnum.RESOURCE_SERVICE_NODE_TEMPLATE.value), + TYPE ("type", ComponentTypeEnum.RESOURCE_SERVICE_NODE_TEMPLATE.value), + +// resource + SUBCATEGORY ("subcategory", ComponentTypeEnum.RESOURCE_NODE_TEMPLATE.value), + RESOURCE_VENDOR_NAME ("resourceVendor", ComponentTypeEnum.RESOURCE_NODE_TEMPLATE.value), + RESOURCE_VENDOR_RELEASE ("resourceVendorRelease", ComponentTypeEnum.RESOURCE_NODE_TEMPLATE.value), + RESOURCE_VENDOR_MODEL_NUMBER ("resourceVendorModelNumber", ComponentTypeEnum.RESOURCE_NODE_TEMPLATE.value), + +// service + SERVICE_TYPE ("serviceType", ComponentTypeEnum.SERVICE.value), + SERVICE_ROLE ("serviceRole", ComponentTypeEnum.SERVICE.value), + SERVICE_ECOMP_NAMING ("serviceEcompNaming", ComponentTypeEnum.SERVICE.value), + ECOMP_GENERATED_NAMING ("ecompGeneratedNaming", ComponentTypeEnum.SERVICE.value), + NAMING_POLICY ("namingPolicy", ComponentTypeEnum.SERVICE.value), + +// node_template + CUSTOMIZATION_UUID ("customizationUUID", ComponentTypeEnum.NODE_TEMPLATE.value), + VERSION ("version", ComponentTypeEnum.RESOURCE_GROUP_NODE_TEMPLATE.value), + +// service group: + VF_MODULE_MODEL_NAME ("vfModuleModelName", ComponentTypeEnum.RESOURCE_GROUP_SERVICE_GROUP.value), + VF_MODULE_MODEL_INVARIANT_UUID ("vfModuleModelInvariantUUID", ComponentTypeEnum.RESOURCE_GROUP_SERVICE_GROUP.value), + VF_MODULE_MODEL_UUID ("vfModuleModelUUID", ComponentTypeEnum.RESOURCE_GROUP_SERVICE_GROUP.value), + VF_MODULE_MODEL_VERSION ("vfModuleModelVersion", ComponentTypeEnum.RESOURCE_GROUP_SERVICE_GROUP.value), + + VF_MODULE_MODEL_CUSTOMIZATION_UUID ("vfModuleModelCustomizationUUID", ComponentTypeEnum.SERVICE_GROUP.value) + ; + + + + public String value; + public String componentTypes; + + private ToscaMetadataFieldsEnum(String value, String componentTypes) { + this.value = value; + this.componentTypes = componentTypes; + } + + } + + + public enum ComponentTypeEnum { +// RESOURCE_SERVICE_NODE_TEMPLATE_RESOURCE_GROUP("resource, service, nodeTemplate, resourceGroup"), + RESOURCE_SERVICE_NODE_TEMPLATE("resource, service, nodeTemplate"), + RESOURCE_NODE_TEMPLATE("resource, nodeTemplate"), + SERVICE("service"), + NODE_TEMPLATE("nodeTemplate"), + RESOURCE_GROUP_NODE_TEMPLATE("resourceGroup, nodeTemplate"), + SERVICE_GROUP("serviceGroup"), + RESOURCE_GROUP_SERVICE_GROUP("resourceGroup, serviceGroup"), + + ; + + private String value; + + private ComponentTypeEnum(String value) { + this.value = value; + } + + } + + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java index 3bae41fc57..5926798ceb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java @@ -29,12 +29,13 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Map; -import java.util.Set; -import org.openecomp.sdc.ci.tests.datatypes.enums.ToscaKeysEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupsTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaImportsDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaInputsTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaMetadataDefinition; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaNodeTemplatesTopologyTemplateDefinition; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaParameterConstants; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaSubstitutionMappingsDefinition; @@ -42,12 +43,10 @@ import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinitio import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils; import org.openecomp.sdc.common.rest.api.RestResponseAsByteArray; import org.openecomp.sdc.common.util.ZipUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.TypeDescription; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.introspector.PropertyUtils; @@ -158,7 +157,9 @@ public class ToscaParserUtils { toscaStructure.addTypeDescription(ToscaNodeTemplatesTopologyTemplateDefinition.getTypeDescription()); toscaStructure.addTypeDescription(ToscaGroupsTopologyTemplateDefinition.getTypeDescription()); toscaStructure.addTypeDescription(ToscaSubstitutionMappingsDefinition.getTypeDescription()); - + toscaStructure.addTypeDescription(ToscaImportsDefinition.getTypeDescription()); + toscaStructure.addTypeDescription(ToscaMetadataDefinition.getTypeDescription()); + toscaStructure.addTypeDescription(ToscaInputsTopologyTemplateDefinition.getTypeDescription()); // Skip properties which are found in YAML, but not found in POJO PropertyUtils propertyUtils = new PropertyUtils(); propertyUtils.setSkipMissingProperties(true); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java index 17148ce8a9..58ab9f353e 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java @@ -39,6 +39,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.aspectj.apache.bcel.classfile.Code; import org.json.JSONException; import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; @@ -50,6 +51,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; 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.ComponentInstanceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; @@ -67,6 +69,7 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.utils.Utils; 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; @@ -134,6 +137,25 @@ public final class AtomicOperationUtils { } } + public static Either<Resource, RestResponse> createResourceByResourceDetails(ResourceReqDetails resourceDetails, UserRoleEnum userRole, Boolean validateState) { + try { + User defaultUser = ElementFactory.getDefaultUser(userRole); + RestResponse resourceResp = ResourceRestUtils.createResource(resourceDetails, defaultUser); + + if (validateState) { + assertTrue(resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); + } + + if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { + Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse()); + return Either.left(resourceResponseObject); + } + return Either.right(resourceResp); + } catch (Exception e) { + throw new AtomicOperationException(e); + } + } + public static Either<Resource, RestResponse> createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum resourceType, NormativeTypesEnum normativeTypes, ResourceCategoryEnum resourceCategory, UserRoleEnum userRole, Boolean validateState) throws Exception { User defaultUser = ElementFactory.getDefaultUser(userRole); @@ -206,6 +228,20 @@ public final class AtomicOperationUtils { return Either.right(createServiceResp); } + public static Either<Service, RestResponse> createCustomService(ServiceReqDetails serviceDetails, UserRoleEnum userRole, Boolean validateState) throws Exception { + User defaultUser = ElementFactory.getDefaultUser(userRole); + RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser); + + if (validateState) { + assertTrue(createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); + } + + if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { + Service serviceResponseObject = ResponseParser.convertServiceResponseToJavaObject(createServiceResp.getResponse()); + return Either.left(serviceResponseObject); + } + return Either.right(createServiceResp); + } // *********** PRODUCT **************** public static Either<Product, RestResponse> createDefaultProduct(UserRoleEnum userRole, Boolean validateState) throws Exception { @@ -713,16 +749,21 @@ public final class AtomicOperationUtils { } } - public static Either<String, RestResponse> getServiceToscaArtifactPayload(Service service, String artifactType) throws Exception { + public static Either<String, RestResponse> getComponenetArtifactPayload(Component component, String artifactType) throws Exception { - String url = String.format(Urls.UI_DOWNLOAD_SERVICE_ARTIFACT, "localhost", "8080", service.getUniqueId(), service.getToscaArtifacts().get(artifactType).getUniqueId()); - String userId = service.getLastUpdaterUserId(); + String url; + Config config = Utils.getConfig(); + if(component.getComponentType().toString().toUpperCase().equals(ComponentTypeEnum.SERVICE.getValue().toUpperCase())){ + url = String.format(Urls.UI_DOWNLOAD_SERVICE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), component.getToscaArtifacts().get(artifactType).getUniqueId()); + }else{ + url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), component.getToscaArtifacts().get(artifactType).getUniqueId()); + } + String userId = component.getLastUpdaterUserId(); Map<String, String> headersMap = new HashMap<String, String>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), "no-cache"); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication); headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); -// headersMap.put("X-ECOMP-InstanceID", "test"); if (userId != null) { headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId); } @@ -735,4 +776,6 @@ public final class AtomicOperationUtils { } + + } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java index 5c23b5f3fe..ddca429f2c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java @@ -293,7 +293,7 @@ public class ElementFactory { tags.add("serviceTag1"); tags.add(serviceName); String description = "service Description"; - String icon = "myIcon"; + String icon = "defaulticon"; ServiceReqDetails serviceDetails = new ServiceReqDetails(serviceName, category.getValue(), tags, description, contactId, icon); @@ -979,7 +979,7 @@ public class ElementFactory { return requirementDef; } - private static String generateUUIDforSufix() { + public static String generateUUIDforSufix() { String uniqueSufix = UUID.randomUUID().toString(); String[] split = uniqueSufix.split("-"); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java index e08ef6523f..ec8fd4089a 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java @@ -78,7 +78,7 @@ public class ResourceRestUtils extends BaseRestUtils { Gson gson = new Gson(); String userBodyJson = gson.toJson(resourceDetails); - String calculateMD5 = GeneralUtility.calculateMD5ByString(userBodyJson); + String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson); headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5); HttpRequest http = new HttpRequest(); // System.out.println(url); @@ -490,7 +490,7 @@ public class ResourceRestUtils extends BaseRestUtils { Gson gson = new Gson(); String userBodyJson = gson.toJson(resourceDetails); - String calculateMD5 = GeneralUtility.calculateMD5ByString(userBodyJson); + String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson); headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5); HttpRequest http = new HttpRequest(); RestResponse updateResourceResponse = http.httpSendPut(url, userBodyJson, headersMap); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java index 10f573cf0e..19d7d728fe 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java @@ -48,7 +48,7 @@ public class ResourceRestUtilsExternalAPI extends BaseRestUtils { Gson gson = new Gson(); String userBodyJson = gson.toJson(resourceDetails); - String calculateMD5 = GeneralUtility.calculateMD5ByString(userBodyJson); + String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson); headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java index 61b7ea18d2..9ba6953bb3 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java @@ -3377,7 +3377,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { httppost.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); httppost.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId()); if (addMd5Header) { - httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5ByString(jsonBody)); + httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5Base64EncodedByString(jsonBody)); } StringEntity input = new StringEntity(jsonBody); input.setContentType("application/json"); |