From a772738447edd9bd743c854cf54988424de95b5f Mon Sep 17 00:00:00 2001 From: Pavel Aharoni Date: Wed, 19 Jul 2017 14:27:56 +0300 Subject: [SDC-141] improving CsarToscaTester Change-Id: Ia8b5c78cceb3148894805111bcee156655dc0ba3 Signed-off-by: Pavel Aharoni --- sdc-distribution-ci/pom.xml | 2 +- .../java/org/openecomp/test/CsarToscaTester.java | 58 +++++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/sdc-distribution-ci/pom.xml b/sdc-distribution-ci/pom.xml index e4c2152..8cfc4a1 100644 --- a/sdc-distribution-ci/pom.xml +++ b/sdc-distribution-ci/pom.xml @@ -32,7 +32,7 @@ org.openecomp.sdc.sdc-tosca sdc-tosca - 1.1.31-SNAPSHOT + 1.1.32-SNAPSHOT compile diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java index 8690257..1ce3619 100644 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java @@ -7,10 +7,16 @@ import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.Map; +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; +import org.openecomp.sdc.tosca.parser.impl.SdcTypes; +import org.openecomp.sdc.toscaparser.api.Group; +import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; +import org.openecomp.sdc.toscaparser.api.parameters.Input; import org.openecomp.sdc.toscaparser.api.utils.ThreadLocalsHolder; public class CsarToscaTester { @@ -36,7 +42,7 @@ public class CsarToscaTester { dir = new File(currentCsarDir); dir.mkdir(); try { - factory.getSdcCsarHelper(file.getAbsolutePath()); + processCsar(factory, file); } catch (SdcToscaParserException e){ System.out.println("SdcToscaParserException caught. Code: "+e.getCode()+", message: "+ e.getMessage()); } @@ -60,6 +66,54 @@ public class CsarToscaTester { } } + private static void processCsar(SdcToscaParserFactory factory, File file) throws SdcToscaParserException { + ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file.getAbsolutePath()); + //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 serviceInputs = sdcCsarHelper.getServiceInputs(); + System.out.println("getServiceInputs() - service inputs are "+serviceInputs); + Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata(); + System.out.println("getServiceMetadata() - service metadata is "+serviceMetadata); + Map serviceMetadataProperties = sdcCsarHelper.getServiceMetadataProperties(); + System.out.println("getServiceMetadataProperties() - service metadata properties is "+serviceMetadataProperties); + List allottedResources = sdcCsarHelper.getAllottedResources(); + System.out.println("getAllottedResources() - service allotted resources are "+allottedResources); + List serviceVfList = sdcCsarHelper.getServiceVfList(); + System.out.println("getServiceVfList() - VF list is "+serviceVfList); + List serviceNodeTemplateBySdcType = sdcCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF); + System.out.println("getServiceNodeTemplateBySdcType() - VF list is "+serviceNodeTemplateBySdcType); + List 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 vfModulesByVf = sdcCsarHelper.getVfModulesByVf(nodeTemplateCustomizationUuid); + System.out.println("getVfModulesByVf() - VF modules list is "+vfModulesByVf); + vfModulesByVf.forEach(y -> { + List membersOfVfModule = sdcCsarHelper.getMembersOfVfModule(x, y); + System.out.println("getMembersOfVfModule() - members of VfModule are "+membersOfVfModule); + }); + List vfcListByVf = sdcCsarHelper.getVfcListByVf(nodeTemplateCustomizationUuid); + System.out.println("getVfcListByVf() - VFC list is "+vfcListByVf); + vfcListByVf.forEach(z -> { + List nodeTemplateBySdcType = sdcCsarHelper.getNodeTemplateBySdcType(z, SdcTypes.CP); + System.out.println("getNodeTemplateBySdcType() - CP children node templates of this VFC are "+nodeTemplateBySdcType); + Map> 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 criticalsReport, String type) throws IOException { FileWriter fw; -- cgit 1.2.3-korg