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