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