diff options
author | 2020-08-19 11:12:59 +0200 | |
---|---|---|
committer | 2020-08-22 20:22:02 +0000 | |
commit | b16794663103fe5716af7627e1d420bf4bbd1aa2 (patch) | |
tree | 9d2050a6096a708f87e4e31b2eac399b965b9e5b /integration-tests/src/test/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java | |
parent | 056998c45c0f1e320a0adb1cb23318b6435ac11a (diff) |
Add sdc startup in IT
Move the Api tests code in the integration-test module, and remove the need to have a container
Issue-ID: SDC-3232
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: Ia2b5d94d958e975867c600597ab5e56dffcd06ab
Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
Diffstat (limited to 'integration-tests/src/test/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java')
-rw-r--r-- | integration-tests/src/test/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java new file mode 100644 index 0000000000..be337ba379 --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 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.utils; + +import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.tosca.parser.enums.SdcTypes; +import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; +import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; +import org.onap.sdc.toscaparser.api.Group; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.elements.Metadata; +import org.onap.sdc.toscaparser.api.parameters.Input; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class CsarToscaTester { + + public static void processCsar(SdcToscaParserFactory factory, File file) throws SdcToscaParserException { + ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file.getAbsolutePath()); + processCsarImpl(sdcCsarHelper); + + } + + public static void processCsar(ISdcCsarHelper sdcCsarHelper) throws SdcToscaParserException { + processCsarImpl(sdcCsarHelper); + + } + + private static void processCsarImpl(ISdcCsarHelper sdcCsarHelper) { + + //Service level + System.out.println("Invoking sdc-tosca methods on this CSAR...."); + String conformanceLevel = sdcCsarHelper.getConformanceLevel(); + System.out.println("getConformanceLevel() - conformance level is "+conformanceLevel); + String serviceSubstitutionMappingsTypeName = sdcCsarHelper.getServiceSubstitutionMappingsTypeName(); + System.out.println("serviceSubstitutionMappingsTypeName() - subst mappings type of service is "+serviceSubstitutionMappingsTypeName); + List<Input> serviceInputs = sdcCsarHelper.getServiceInputs(); + System.out.println("getServiceInputs() - service inputs are "+serviceInputs); + Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata(); + System.out.println("getServiceMetadata() - service metadata is "+serviceMetadata); + Map<String, Object> serviceMetadataProperties = sdcCsarHelper.getServiceMetadataProperties(); + System.out.println("getServiceMetadataProperties() - service metadata properties is "+serviceMetadataProperties); + List<NodeTemplate> allottedResources = sdcCsarHelper.getAllottedResources(); + System.out.println("getAllottedResources() - service allotted resources are "+allottedResources); + List<NodeTemplate> serviceVfList = sdcCsarHelper.getServiceVfList(); + System.out.println("getServiceVfList() - VF list is "+serviceVfList); + List<NodeTemplate> serviceNodeTemplateBySdcType = sdcCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF); + System.out.println("getServiceNodeTemplateBySdcType() - VF list is "+serviceNodeTemplateBySdcType); + List<NodeTemplate> serviceNodeTemplates = sdcCsarHelper.getServiceNodeTemplates(); + System.out.println("getServiceNodeTemplates() - all node templates list of service is "+serviceNodeTemplates); + + serviceVfList.forEach(x -> { + String nodeTemplateCustomizationUuid = sdcCsarHelper.getNodeTemplateCustomizationUuid(x); + System.out.println("getNodeTemplateCustomizationUuid() - VF ID is "+nodeTemplateCustomizationUuid); + String typeOfNodeTemplate = sdcCsarHelper.getTypeOfNodeTemplate(x); + System.out.println("getTypeOfNodeTemplate() - VF tosca type is "+typeOfNodeTemplate); + List<Group> vfModulesByVf = sdcCsarHelper.getVfModulesByVf(nodeTemplateCustomizationUuid); + System.out.println("getVfModulesByVf() - VF modules list is "+vfModulesByVf); + vfModulesByVf.forEach(y -> { + List<NodeTemplate> membersOfVfModule = sdcCsarHelper.getMembersOfVfModule(x, y); + System.out.println("getMembersOfVfModule() - members of VfModule are "+membersOfVfModule); + }); + List<NodeTemplate> vfcListByVf = sdcCsarHelper.getVfcListByVf(nodeTemplateCustomizationUuid); + System.out.println("getVfcListByVf() - VFC list is "+vfcListByVf); + vfcListByVf.forEach(z -> { + List<NodeTemplate> nodeTemplateBySdcType = sdcCsarHelper.getNodeTemplateBySdcType(z, SdcTypes.CP); + System.out.println("getNodeTemplateBySdcType() - CP children node templates of this VFC are "+nodeTemplateBySdcType); + Map<String, Map<String, Object>> cpPropertiesFromVfcAsObject = sdcCsarHelper.getCpPropertiesFromVfcAsObject(z); + System.out.println("getCpPropertiesFromVfcAsObject() - consolidated CP properties for this VFC are "+cpPropertiesFromVfcAsObject); + boolean hasTopology = sdcCsarHelper.hasTopology(z); + System.out.println("hasTopology() - this VFC is "+(hasTopology ? "nested" : "not nested")); + }); + }); + } + + private static void generateReport(String time, String name, String currentCsarDir, List<String> criticalsReport, String type) + throws IOException { + FileWriter fw; + try (FileWriter fileWriter = fw = new FileWriter(new File(currentCsarDir + "/" + criticalsReport.size() + "-" + type + "-" + name + "-" + time + ".txt"))) { + } + for (String exception : criticalsReport) { + fw.write(exception); + fw.write("\r\n"); + } + fw.close(); + } +} |