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