Resolve get_input for list change
[sdc/sdc-tosca.git] / src / test / java / org / onap / sdc / impl / SdcToscaParserBasicTest.java
1 package org.onap.sdc.impl;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.lang.reflect.Method;
6 import java.util.Arrays;
7 import java.util.HashMap;
8 import java.util.List;
9 import java.util.Map;
10
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;
18
19 public abstract class SdcToscaParserBasicTest {
20
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;
46         static ISdcCsarHelper csarHelperServiceAnnotations;
47         static ISdcCsarHelper csarHelperServiceAdiodAnnotations;
48         static ISdcCsarHelper csarHelperServiceNetworkCloud;
49
50         static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
51     
52     @BeforeSuite
53     public static void init() throws SdcToscaParserException, JToscaException, IOException {
54
55         factory = SdcToscaParserFactory.getInstance();
56         fdntCsarHelper = getCsarHelper("csars/service-sunny-flow.csar", false);
57         rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar", false);
58         rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar", false);
59                 fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar", false);
60                 nfodCsarHlper =  getCsarHelper("csars/service-NfodService-csar.csar", false);
61                 ipAssignCsarHelper =  getCsarHelper("csars/service-Ipassignservice-csar.csar", false);
62                 nestedVfcCsarHlper = getCsarHelper("csars/service-nested-vfc-csar.csar", false);
63                 nfodNEWCsarHlper =  getCsarHelper("csars/service-Nfod2images-csar.csar", false);
64                 resolveGetInputCsar = getCsarHelper("csars/service-resolve-get-input-csar.csar");
65                 resolveGetInputCsarFalse = getCsarHelper("csars/service-resolve-get-input-csar.csar",false);
66                 resolveGetInputCsarQA = getCsarHelper("csars/service-resolve-get-input-csar_QA.csar");
67                 QAServiceForToscaParserTests = getCsarHelper("csars/service-ServiceForToscaParserTests-csar.csar");
68                 resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar");
69                 portMirroring = getCsarHelper("csars/service-PortMirroring.csar");
70                 csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar");
71                 csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar");
72                 csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar");
73                 csarHelperServiceGroups = getCsarHelper("csars/service-Groupstest-csar.csar");
74                 csarHelperServiceGroupsInputs = getCsarHelper("csars/service-VdbeSrv-csar.csar");
75                 csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar");
76                 csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar");
77                 csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar");
78                 csarHelperServiceAnnotations = getCsarHelper("csars/resource-Sirovinputannotation-csar.csar");
79                 csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar");
80                 csarHelperServiceAdiodAnnotations = getCsarHelper("csars/service-AdiodVmxVpeBvService-csar.csar");
81                 csarHelperServiceNetworkCloud = getCsarHelper("csars/service-NetworkCloudVnfServiceMock-csar.csar");
82
83                 fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
84                 {
85                         HashMap<String, List<String>> FDNT ;
86                         
87                         FDNT = new HashMap<String, List<String>>();
88                         FDNT.put("VF Name", Arrays.asList("FDNT 1"));
89                         FDNT.put("capabilities", Arrays.asList(
90                                         "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI",
91                                         "dnt_fw_rhrg.host_DNT_FW_SERVER",
92                                         "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
93                                         "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
94                                         "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
95                                         "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",                                  
96                                         "dnt_fw_rhrg.os_DNT_FW_SERVER",
97                                         "dnt_fw_rhrg.feature",
98                                         "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
99                                         "dnt_fw_rhrg.binding_DNT_FW_SERVER",
100                                         "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
101                                         "dnt_fw_rsg_si_1.feature"));
102                         FDNT.put("requirements", Arrays.asList(
103                                         "DNT_FW_RSG_SI_1.dependency",
104                                         "DNT_FW_RHRG.dependency",
105                                         "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
106                                         "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI",
107                                         "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI",
108                                         "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI", 
109                                         "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI",
110                                         "DNT_FW_RSG_SI_1.port",
111                                         "DNT_FW_RHRG.local_storage_DNT_FW_SERVER"));
112                         FDNT.put("capabilitiesTypes", Arrays.asList(
113                                         "tosca.capabilities.network.Bindable",
114                                         "tosca.capabilities.OperatingSystem",
115                                         "tosca.capabilities.network.Bindable",                                  
116                                         "tosca.capabilities.Scalable",
117                                         "tosca.capabilities.Endpoint.Admin",
118                                         "tosca.capabilities.network.Bindable",
119                                         "tosca.capabilities.network.Bindable",
120                                         "tosca.capabilities.network.Bindable",
121                                         "tosca.capabilities.Node",
122                                         "tosca.capabilities.Container",
123                                         "tosca.nodes.SoftwareComponent",
124                                         "tosca.capabilities.network.Bindable"));
125                         FDNT.put("capabilityProperties", Arrays.asList(
126                                         "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none",
127                                         "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;",
128                                         "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
129                                         "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
130                                         "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
131                                         "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",                                  
132                                         "dnt_fw_rhrg.os_DNT_FW_SERVER",
133                                         "dnt_fw_rhrg.feature",
134                                         "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
135                                         "dnt_fw_rhrg.binding_DNT_FW_SERVER",
136                                         "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
137                                         "dnt_fw_rsg_si_1.feature"));
138                         
139                         
140                         put("FDNT", FDNT);                      
141                 }
142         };
143     };
144
145         protected static ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException {
146                 System.out.println("Parsing CSAR "+path+"...");
147                 String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
148         File file1 = new File(fileStr1);
149         ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
150                 return sdcCsarHelper;
151         }
152
153         protected static ISdcCsarHelper getCsarHelper(String path, boolean resolveGetInput) throws SdcToscaParserException {
154                 System.out.println("Parsing CSAR "+path+"...");
155                 String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
156                 File file1 = new File(fileStr1);
157                 ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath(), resolveGetInput);
158                 return sdcCsarHelper;
159         }
160
161     @BeforeMethod
162     public void setupTest(Method method) {
163         System.out.println("#### Starting Test " + method.getName() + " ###########");
164     }
165
166     @AfterMethod
167     public void tearDown(Method method){
168         System.out.println("#### Ended test " + method.getName() + " ###########");
169     }
170 }