1 package org.onap.sdc.impl;
4 import java.io.IOException;
5 import java.lang.reflect.Method;
6 import java.util.Arrays;
7 import java.util.HashMap;
11 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
12 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
13 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
14 import org.onap.sdc.toscaparser.api.common.JToscaException;
15 import org.testng.annotations.AfterMethod;
16 import org.testng.annotations.BeforeMethod;
17 import org.testng.annotations.BeforeSuite;
19 public abstract class SdcToscaParserBasicTest {
21 public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73";
22 static SdcToscaParserFactory factory;
23 static ISdcCsarHelper rainyCsarHelperSingleVf;
24 static ISdcCsarHelper rainyCsarHelperMultiVfs;
25 static ISdcCsarHelper fdntCsarHelper;
26 static ISdcCsarHelper fdntCsarHelperWithInputs;
27 static ISdcCsarHelper nfodCsarHlper;
28 static ISdcCsarHelper ipAssignCsarHelper;
29 static ISdcCsarHelper nestedVfcCsarHlper;
30 static ISdcCsarHelper nfodNEWCsarHlper;
31 static ISdcCsarHelper QAServiceForToscaParserTests;
32 static ISdcCsarHelper resolveGetInputCsar;
33 static ISdcCsarHelper resolveGetInputCsarFalse;
34 static ISdcCsarHelper resolveGetInputCsarQA;
35 static ISdcCsarHelper resolveReqsCapsCsarQA;
36 static ISdcCsarHelper portMirroring;
37 static ISdcCsarHelper csarHelperServiceWithCrs;
38 static ISdcCsarHelper csarHelperServicePolicy;
39 static ISdcCsarHelper csarHelperVfPolicy;
40 static ISdcCsarHelper csarHelperServiceGroups;
41 static ISdcCsarHelper csarHelperServiceGroupsInputs;
42 static ISdcCsarHelper csarHelperServiceGroupsCapabilities;
43 static ISdcCsarHelper csarHelperVfGroupsPolicies;
44 static ISdcCsarHelper csarHelperServiceGroupsPolicies;
45 static ISdcCsarHelper csarHelperVfInterfaces;
47 static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
50 public static void init() throws SdcToscaParserException, JToscaException, IOException {
52 factory = SdcToscaParserFactory.getInstance();
53 fdntCsarHelper = getCsarHelper("csars/service-sunny-flow.csar", false);
54 rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar", false);
55 rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar", false);
56 fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar", false);
57 nfodCsarHlper = getCsarHelper("csars/service-NfodService-csar.csar", false);
58 ipAssignCsarHelper = getCsarHelper("csars/service-Ipassignservice-csar.csar", false);
59 nestedVfcCsarHlper = getCsarHelper("csars/service-nested-vfc-csar.csar", false);
60 nfodNEWCsarHlper = getCsarHelper("csars/service-Nfod2images-csar.csar", false);
61 resolveGetInputCsar = getCsarHelper("csars/service-resolve-get-input-csar.csar");
62 resolveGetInputCsarFalse = getCsarHelper("csars/service-resolve-get-input-csar.csar",false);
63 resolveGetInputCsarQA = getCsarHelper("csars/service-resolve-get-input-csar_QA.csar");
64 QAServiceForToscaParserTests = getCsarHelper("csars/service-ServiceForToscaParserTests-csar.csar");
65 resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar");
66 portMirroring = getCsarHelper("csars/service-PortMirroring.csar");
67 csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar");
68 csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar");
69 csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar");
70 csarHelperServiceGroups = getCsarHelper("csars/service-Groupstest-csar.csar");
71 csarHelperServiceGroupsInputs = getCsarHelper("csars/service-VdbeSrv-csar.csar");
72 csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar");
73 csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar");
74 csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar");
75 csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar");
77 fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
79 HashMap<String, List<String>> FDNT ;
81 FDNT = new HashMap<String, List<String>>();
82 FDNT.put("VF Name", Arrays.asList("FDNT 1"));
83 FDNT.put("capabilities", Arrays.asList(
84 "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI",
85 "dnt_fw_rhrg.host_DNT_FW_SERVER",
86 "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
87 "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
88 "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
89 "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
90 "dnt_fw_rhrg.os_DNT_FW_SERVER",
91 "dnt_fw_rhrg.feature",
92 "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
93 "dnt_fw_rhrg.binding_DNT_FW_SERVER",
94 "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
95 "dnt_fw_rsg_si_1.feature"));
96 FDNT.put("requirements", Arrays.asList(
97 "DNT_FW_RSG_SI_1.dependency",
98 "DNT_FW_RHRG.dependency",
99 "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
100 "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI",
101 "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI",
102 "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI",
103 "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI",
104 "DNT_FW_RSG_SI_1.port",
105 "DNT_FW_RHRG.local_storage_DNT_FW_SERVER"));
106 FDNT.put("capabilitiesTypes", Arrays.asList(
107 "tosca.capabilities.network.Bindable",
108 "tosca.capabilities.OperatingSystem",
109 "tosca.capabilities.network.Bindable",
110 "tosca.capabilities.Scalable",
111 "tosca.capabilities.Endpoint.Admin",
112 "tosca.capabilities.network.Bindable",
113 "tosca.capabilities.network.Bindable",
114 "tosca.capabilities.network.Bindable",
115 "tosca.capabilities.Node",
116 "tosca.capabilities.Container",
117 "tosca.nodes.SoftwareComponent",
118 "tosca.capabilities.network.Bindable"));
119 FDNT.put("capabilityProperties", Arrays.asList(
120 "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none",
121 "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;",
122 "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
123 "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
124 "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
125 "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
126 "dnt_fw_rhrg.os_DNT_FW_SERVER",
127 "dnt_fw_rhrg.feature",
128 "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
129 "dnt_fw_rhrg.binding_DNT_FW_SERVER",
130 "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
131 "dnt_fw_rsg_si_1.feature"));
139 protected static ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException {
140 System.out.println("Parsing CSAR "+path+"...");
141 String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
142 File file1 = new File(fileStr1);
143 ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
144 return sdcCsarHelper;
147 protected static ISdcCsarHelper getCsarHelper(String path, boolean resolveGetInput) throws SdcToscaParserException {
148 System.out.println("Parsing CSAR "+path+"...");
149 String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
150 File file1 = new File(fileStr1);
151 ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath(), resolveGetInput);
152 return sdcCsarHelper;
156 public void setupTest(Method method) {
157 System.out.println("#### Starting Test " + method.getName() + " ###########");
161 public void tearDown(Method method){
162 System.out.println("#### Ended test " + method.getName() + " ###########");