2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.devCI;
24 import java.io.IOException;
25 import java.text.SimpleDateFormat;
26 import java.util.ArrayList;
27 import java.util.Date;
28 import java.util.LinkedHashMap;
29 import java.util.List;
31 import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition;
32 import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
33 import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition;
34 import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
35 import org.openecomp.sdc.ci.tests.utils.CsarParserUtils;
36 import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
37 import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
38 import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
39 import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
40 //import org.openecomp.sdc.toscaparser.api.Metadata;
41 import org.openecomp.sdc.toscaparser.api.Capability;
42 import org.openecomp.sdc.toscaparser.api.NodeTemplate;
43 import org.openecomp.sdc.toscaparser.api.common.JToscaException;
44 import org.testng.annotations.Test;
46 public class AndreyTest {
48 private static ToscaDefinition parseToscaYamlToJavaObject;
51 public static void main(String[] args) throws Exception {
52 ToscaDefinition toscaDefinition;
53 System.out.println("start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
54 // File path = new File("C:/Data/D2.0/TOSCA_Ex/Definitions/tosca_definition_version.yaml");
55 // File path = new File("C:/Data/D2.0/TOSCA_Ex/resource-Vl11Vl10-template.yml");
56 // File path = new File("C:/Data/D2.0/TOSCA_Ex/service-Servicepxtc-template US822998.yml");
57 // File path = new File("C:/Data/FileToParse/Definitions/service-Ciservice513e6fa67d07-template.yml");
58 toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:/Data/FileToParse/LDSA/LDSA_amdocs.csar"));
59 // File path = new File("C:/Data/FileToParse/Definitions/resource-Civfonboarded2016006VvmVvm301607E2100a9b04-template.yml");
60 // File csarPath = new File("C:/Data/D2.0/TOSCA_Ex/Nested.csar");
63 // toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path);
64 System.out.println("listTypeHeatMetaDefinition start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
65 // List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(csarPath);
66 System.out.println("get service start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
67 // System.out.println(listTypeHeatMetaDefinition);
68 // for(TypeHeatMetaDefinition typeHeatMetaDefinition : listTypeHeatMetaDefinition){
69 // for(GroupHeatMetaDefinition groupHeatMetaDefinition : typeHeatMetaDefinition.getGroupHeatMetaDefinition()){
70 // List<HeatMetaFirstLevelDefinition> artifactList = groupHeatMetaDefinition.getArtifactList();
71 // boolean isBase = groupHeatMetaDefinition.getPropertyHeatMetaDefinition().getValue();
75 System.out.println("Finished");
76 System.out.println("get service start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
81 public void distributionTest() throws SdcToscaParserException, JToscaException, IOException {
82 //String serviceName = import and create().getName();
84 //parseServiceObject();
88 SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
89 long startTime = System.currentTimeMillis();
90 long estimatedTime = System.currentTimeMillis() - startTime;
91 System.out.println("Time to init factory " + estimatedTime);
92 String fileStr1 = "C:\\Users\\ys9693\\NewDownload\\2016-006_vvm_vvm_30_1607_e2e.zip.csar";//ToscaParserStubsTest.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar-0904-2.csar").getFile();
93 File file1 = new File(fileStr1);
94 String name = file1.getName();
95 String absolutePath = file1.getAbsolutePath();
96 ISdcCsarHelper fdntCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
98 List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
99 System.out.println("serviceVfList----->" + serviceVfList);
101 List<NodeTemplate> serviceNodeTemplatesByTypeVF = fdntCsarHelper.getServiceNodeTemplatesByType("VF");
102 System.out.println("serviceNodeTemplatesByTypeVF----->" + serviceNodeTemplatesByTypeVF);
103 List<NodeTemplate> serviceNodeTemplatesByTypeVFC = fdntCsarHelper.getServiceNodeTemplatesByType("VFC");
104 System.out.println("serviceNodeTemplatesByTypeVFC -------->" + serviceNodeTemplatesByTypeVFC);
105 List<NodeTemplate> serviceNodeTemplatesByTypeVL = fdntCsarHelper.getServiceNodeTemplatesByType("VL");
106 System.out.println("serviceNodeTemplatesByTypeVL------>" +serviceNodeTemplatesByTypeVL);
107 List<NodeTemplate> serviceNodeTemplatesByTypeCP = fdntCsarHelper.getServiceNodeTemplatesByType("CP");
108 System.out.println("serviceNodeTemplatesByTypeCP ---------->" + serviceNodeTemplatesByTypeCP);
110 System.out.println("getMetaData"+ serviceVfList.get(0).getMetaData());
111 System.out.println("UUID"+ serviceVfList.get(0).getMetaData().getValue("UUID"));
112 System.out.println("customizationUUID"+ serviceVfList.get(0).getMetaData().getValue("customizationUUID"));
113 System.out.println("serviceVfList.size()------->"+ serviceVfList.size());
114 System.out.println("getCpListByVf--------->" + fdntCsarHelper.getCpListByVf(serviceVfList.get(0).getMetaData().getValue("customizationUUID")));
115 List<NodeTemplate> vfcListByVf = fdntCsarHelper.getVfcListByVf(serviceVfList.get(0).getMetaData().getValue("customizationUUID"));
116 System.out.println("getVfcListByVf--------->" + vfcListByVf);
117 for (NodeTemplate nodeTemplate : vfcListByVf) {
119 System.out.println("----> getCpPropertiesFromVfc--------->" + fdntCsarHelper.getCpPropertiesFromVfc(nodeTemplate));
122 for (NodeTemplate nodeTemplate : serviceVfList) {
123 System.out.println("NodeName---->"+nodeTemplate.getName());
124 System.out.println("getTypeOfNodeTemplate--------->" + fdntCsarHelper.getTypeOfNodeTemplate(nodeTemplate));
125 System.out.println("getServiceInputLeafValueOfDefault--------->" + fdntCsarHelper.getServiceInputLeafValueOfDefault(serviceVfList.get(0).getMetaData().getValue("customizationUUID")));
126 System.out.println("getVfModulesByVf--------->" + fdntCsarHelper.getVfModulesByVf(nodeTemplate.getMetaData().getValue("customizationUUID")));
127 ArrayList<Object> requirements = nodeTemplate.getRequirements();
129 LinkedHashMap<String, Capability> capabilities = nodeTemplate.getCapabilities();
130 ArrayList<Object> requirements2 = nodeTemplate.getRequirements();