2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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.onap.sdc.impl;
24 import java.io.IOException;
25 import java.lang.reflect.Method;
26 import java.util.Arrays;
27 import java.util.HashMap;
28 import java.util.List;
31 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
32 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
33 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
34 import org.onap.sdc.toscaparser.api.common.JToscaException;
35 import org.testng.annotations.AfterMethod;
36 import org.testng.annotations.BeforeMethod;
37 import org.testng.annotations.BeforeSuite;
39 public abstract class SdcToscaParserBasicTest {
41 public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73";
42 static SdcToscaParserFactory factory;
43 static ISdcCsarHelper rainyCsarHelperSingleVf;
44 static ISdcCsarHelper rainyCsarHelperMultiVfs;
45 static ISdcCsarHelper fdntCsarHelper;
46 static ISdcCsarHelper fdntCsarHelperWithInputs;
47 static ISdcCsarHelper nfodCsarHlper;
48 static ISdcCsarHelper ipAssignCsarHelper;
49 static ISdcCsarHelper nestedVfcCsarHlper;
50 static ISdcCsarHelper nfodNEWCsarHlper;
51 static ISdcCsarHelper QAServiceForToscaParserTests;
52 static ISdcCsarHelper resolveGetInputCsar;
53 static ISdcCsarHelper resolveGetInputCsarFalse;
54 static ISdcCsarHelper resolveGetInputCsarQA;
55 static ISdcCsarHelper resolveReqsCapsCsarQA;
56 static ISdcCsarHelper portMirroring;
57 static ISdcCsarHelper csarHelperServiceWithCrs;
58 static ISdcCsarHelper csarHelperServicePolicy;
59 static ISdcCsarHelper csarHelperVfPolicy;
60 static ISdcCsarHelper csarHelperServiceGroups;
61 static ISdcCsarHelper csarHelperServiceGroupsInputs;
62 static ISdcCsarHelper csarHelperServiceGroupsCapabilities;
63 static ISdcCsarHelper csarHelperVfGroupsPolicies;
64 static ISdcCsarHelper csarHelperServiceGroupsPolicies;
65 static ISdcCsarHelper csarHelperVfInterfaces;
66 static ISdcCsarHelper csarHelperServiceAnnotations;
67 static ISdcCsarHelper csarHelperServiceAdiodAnnotations;
68 static ISdcCsarHelper csarHelperServiceNetworkCloud;
70 static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
73 public static void init() throws SdcToscaParserException, JToscaException, IOException {
75 factory = SdcToscaParserFactory.getInstance();
76 fdntCsarHelper = getCsarHelper("csars/service-sunny-flow.csar", false);
77 rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar", false);
78 rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar", false);
79 fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar", false);
80 nfodCsarHlper = getCsarHelper("csars/service-NfodService-csar.csar", false);
81 ipAssignCsarHelper = getCsarHelper("csars/service-Ipassignservice-csar.csar", false);
82 nestedVfcCsarHlper = getCsarHelper("csars/service-nested-vfc-csar.csar", false);
83 nfodNEWCsarHlper = getCsarHelper("csars/service-Nfod2images-csar.csar", false);
84 resolveGetInputCsar = getCsarHelper("csars/service-resolve-get-input-csar.csar");
85 resolveGetInputCsarFalse = getCsarHelper("csars/service-resolve-get-input-csar.csar",false);
86 resolveGetInputCsarQA = getCsarHelper("csars/service-resolve-get-input-csar_QA.csar");
87 QAServiceForToscaParserTests = getCsarHelper("csars/service-ServiceForToscaParserTests-csar.csar");
88 resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar");
89 portMirroring = getCsarHelper("csars/service-PortMirroring.csar");
90 csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar");
91 csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar");
92 csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar");
93 csarHelperServiceGroups = getCsarHelper("csars/service-Groupstest-csar.csar");
94 csarHelperServiceGroupsInputs = getCsarHelper("csars/service-VdbeSrv-csar.csar");
95 csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar");
96 csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar");
97 csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar");
98 csarHelperServiceAnnotations = getCsarHelper("csars/resource-Sirovinputannotation-csar.csar");
99 csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar");
100 csarHelperServiceAdiodAnnotations = getCsarHelper("csars/service-AdiodVmxVpeBvService-csar.csar");
101 csarHelperServiceNetworkCloud = getCsarHelper("csars/service-NetworkCloudVnfServiceMock-csar.csar");
103 fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
105 HashMap<String, List<String>> FDNT ;
107 FDNT = new HashMap<String, List<String>>();
108 FDNT.put("VF Name", Arrays.asList("FDNT 1"));
109 FDNT.put("capabilities", Arrays.asList(
110 "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI",
111 "dnt_fw_rhrg.host_DNT_FW_SERVER",
112 "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
113 "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
114 "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
115 "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
116 "dnt_fw_rhrg.os_DNT_FW_SERVER",
117 "dnt_fw_rhrg.feature",
118 "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
119 "dnt_fw_rhrg.binding_DNT_FW_SERVER",
120 "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
121 "dnt_fw_rsg_si_1.feature"));
122 FDNT.put("requirements", Arrays.asList(
123 "DNT_FW_RSG_SI_1.dependency",
124 "DNT_FW_RHRG.dependency",
125 "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
126 "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI",
127 "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI",
128 "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI",
129 "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI",
130 "DNT_FW_RSG_SI_1.port",
131 "DNT_FW_RHRG.local_storage_DNT_FW_SERVER"));
132 FDNT.put("capabilitiesTypes", Arrays.asList(
133 "tosca.capabilities.network.Bindable",
134 "tosca.capabilities.OperatingSystem",
135 "tosca.capabilities.network.Bindable",
136 "tosca.capabilities.Scalable",
137 "tosca.capabilities.Endpoint.Admin",
138 "tosca.capabilities.network.Bindable",
139 "tosca.capabilities.network.Bindable",
140 "tosca.capabilities.network.Bindable",
141 "tosca.capabilities.Node",
142 "tosca.capabilities.Container",
143 "tosca.nodes.SoftwareComponent",
144 "tosca.capabilities.network.Bindable"));
145 FDNT.put("capabilityProperties", Arrays.asList(
146 "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none",
147 "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;",
148 "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
149 "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
150 "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
151 "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
152 "dnt_fw_rhrg.os_DNT_FW_SERVER",
153 "dnt_fw_rhrg.feature",
154 "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
155 "dnt_fw_rhrg.binding_DNT_FW_SERVER",
156 "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
157 "dnt_fw_rsg_si_1.feature"));
165 protected static ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException {
166 System.out.println("Parsing CSAR "+path+"...");
167 String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
168 File file1 = new File(fileStr1);
169 ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
170 return sdcCsarHelper;
173 protected static ISdcCsarHelper getCsarHelper(String path, boolean resolveGetInput) throws SdcToscaParserException {
174 System.out.println("Parsing CSAR "+path+"...");
175 String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
176 File file1 = new File(fileStr1);
177 ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath(), resolveGetInput);
178 return sdcCsarHelper;
182 public void setupTest(Method method) {
183 System.out.println("#### Starting Test " + method.getName() + " ###########");
187 public void tearDown(Method method){
188 System.out.println("#### Ended test " + method.getName() + " ###########");