5b3a4d95294d52fca4c7297cc0fc12d3d03745cd
[sdc/sdc-tosca.git] / sdc-tosca / src / test / java / org / onap / sdc / impl / SdcToscaParserBasicTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdc-tosca
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.sdc.impl;
22
23 import java.io.File;
24 import java.util.Arrays;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
29 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
30 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
31
32
33 public class SdcToscaParserBasicTest extends BaseSetupExtension {
34
35     public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73";
36     static SdcToscaParserFactory factory;
37     static ISdcCsarHelper rainyCsarHelperSingleVf;
38     static ISdcCsarHelper rainyCsarHelperMultiVfs;
39     static ISdcCsarHelper fdntCsarHelper;
40     static ISdcCsarHelper fdntCsarHelperWithInputs;
41     static ISdcCsarHelper nfodCsarHlper;
42     static ISdcCsarHelper ipAssignCsarHelper;
43     static ISdcCsarHelper nestedVfcCsarHlper;
44     static ISdcCsarHelper nfodNEWCsarHlper;
45     static ISdcCsarHelper QAServiceForToscaParserTests;
46     static ISdcCsarHelper resolveGetInputCsar;
47     static ISdcCsarHelper resolveGetInputCsarFalse;
48     static ISdcCsarHelper resolveGetInputCsarQA;
49     static ISdcCsarHelper resolveReqsCapsCsarQA;
50     static ISdcCsarHelper portMirroring;
51     static ISdcCsarHelper csarHelperServiceWithCrs;
52     static ISdcCsarHelper csarHelperServicePolicy;
53     static ISdcCsarHelper csarHelperVfPolicy;
54     static ISdcCsarHelper csarHelperServiceGroups;
55     static ISdcCsarHelper csarHelperServiceGroupsInputs;
56     static ISdcCsarHelper csarHelperServiceGroupsCapabilities;
57     static ISdcCsarHelper csarHelperVfGroupsPolicies;
58     static ISdcCsarHelper csarHelperServiceGroupsPolicies;
59     static ISdcCsarHelper csarHelperVfInterfaces;
60     static ISdcCsarHelper csarHelperServiceAnnotations;
61     static ISdcCsarHelper csarHelperServiceAdiodAnnotations;
62     static ISdcCsarHelper csarHelperServiceNetworkCloud;
63     static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
64
65     @Override
66     void setup() throws SdcToscaParserException {
67         factory = SdcToscaParserFactory.getInstance();
68         fdntCsarHelper = getCsarHelper("csars/service-sunny-flow.csar", false);
69         rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar", false);
70         rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar", false);
71         fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar", false);
72         nfodCsarHlper = getCsarHelper("csars/service-NfodService-csar.csar", false);
73         ipAssignCsarHelper = getCsarHelper("csars/service-Ipassignservice-csar.csar", false);
74         nestedVfcCsarHlper = getCsarHelper("csars/service-nested-vfc-csar.csar", false);
75         nfodNEWCsarHlper = getCsarHelper("csars/service-Nfod2images-csar.csar", false);
76         resolveGetInputCsar = getCsarHelper("csars/service-resolve-get-input-csar.csar");
77         resolveGetInputCsarFalse = getCsarHelper("csars/service-resolve-get-input-csar.csar", false);
78         resolveGetInputCsarQA = getCsarHelper("csars/service-resolve-get-input-csar_QA.csar");
79         QAServiceForToscaParserTests = getCsarHelper("csars/service-ServiceForToscaParserTests-csar.csar");
80         resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar");
81         portMirroring = getCsarHelper("csars/service-PortMirroring.csar");
82         csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar");
83         csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar");
84         csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar");
85         csarHelperServiceGroups = getCsarHelper("csars/service-Groupstest-csar.csar");
86         csarHelperServiceGroupsInputs = getCsarHelper("csars/service-VdbeSrv-csar.csar");
87         csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar");
88         csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar");
89         csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar");
90         csarHelperServiceAnnotations = getCsarHelper("csars/resource-Sirovinputannotation-csar.csar");
91         csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar");
92         csarHelperServiceAdiodAnnotations = getCsarHelper("csars/service-AdiodVmxVpeBvService-csar.csar");
93         csarHelperServiceNetworkCloud = getCsarHelper("csars/service-NetworkCloudVnfServiceMock-csar.csar");
94
95         fdntCsarHelper_Data = new HashMap<>() {
96             {
97                 HashMap<String, List<String>> FDNT;
98
99                 FDNT = new HashMap<>();
100                 FDNT.put("VF Name", Arrays.asList("FDNT 1"));
101                 FDNT.put("capabilities", Arrays.asList(
102                     "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI",
103                     "dnt_fw_rhrg.host_DNT_FW_SERVER",
104                     "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
105                     "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
106                     "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
107                     "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
108                     "dnt_fw_rhrg.os_DNT_FW_SERVER",
109                     "dnt_fw_rhrg.feature",
110                     "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
111                     "dnt_fw_rhrg.binding_DNT_FW_SERVER",
112                     "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
113                     "dnt_fw_rsg_si_1.feature"));
114                 FDNT.put("requirements", Arrays.asList(
115                     "DNT_FW_RSG_SI_1.dependency",
116                     "DNT_FW_RHRG.dependency",
117                     "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
118                     "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI",
119                     "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI",
120                     "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI",
121                     "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI",
122                     "DNT_FW_RSG_SI_1.port",
123                     "DNT_FW_RHRG.local_storage_DNT_FW_SERVER"));
124                 FDNT.put("capabilitiesTypes", Arrays.asList(
125                     "tosca.capabilities.network.Bindable",
126                     "tosca.capabilities.OperatingSystem",
127                     "tosca.capabilities.network.Bindable",
128                     "tosca.capabilities.Scalable",
129                     "tosca.capabilities.Endpoint.Admin",
130                     "tosca.capabilities.network.Bindable",
131                     "tosca.capabilities.network.Bindable",
132                     "tosca.capabilities.network.Bindable",
133                     "tosca.capabilities.Node",
134                     "tosca.capabilities.Container",
135                     "tosca.nodes.SoftwareComponent",
136                     "tosca.capabilities.network.Bindable"));
137                 FDNT.put("capabilityProperties", Arrays.asList(
138                     "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none",
139                     "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;",
140                     "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
141                     "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
142                     "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
143                     "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
144                     "dnt_fw_rhrg.os_DNT_FW_SERVER",
145                     "dnt_fw_rhrg.feature",
146                     "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
147                     "dnt_fw_rhrg.binding_DNT_FW_SERVER",
148                     "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
149                     "dnt_fw_rsg_si_1.feature"));
150
151                 put("FDNT", FDNT);
152             }
153         };
154
155     }
156
157     protected ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException {
158         System.out.println("Parsing CSAR " + path + "...");
159         String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
160         File file1 = new File(fileStr1);
161         ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
162         return sdcCsarHelper;
163     }
164
165     protected ISdcCsarHelper getCsarHelper(String path, boolean resolveGetInput) 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(), resolveGetInput);
170         return sdcCsarHelper;
171     }
172
173     @Override
174     public void close() {
175         // Your "after all tests" logic goes here
176     }
177 }