2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.sdc.impl;
23 import static org.testng.Assert.assertNotNull;
24 import static org.testng.Assert.assertNull;
27 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
28 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
29 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
30 import org.testng.annotations.Test;
32 public class ToscaParserSimpleYaml12Test {
34 private static final SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
37 public void testVersion() throws Exception {
39 verify("csars/resource-Networkfunction-tosca_simple_yaml_1_2.csar");
40 verify("csars/resource-Networkservice-tosca_simple_yaml_1_2.csar");
41 verify("csars/resource-Amf-tosca_simple_yaml_1_2.csar");
42 verify("csars/resource-Resource-tosca_simple_yaml_1_2.csar");
45 private void verify(final String resourceFileName) throws Exception {
46 final ISdcCsarHelper fdntCsarHelper = getCsarHelper(resourceFileName);
48 assertNotNull(fdntCsarHelper.getServiceMetadata());
49 assertNull(fdntCsarHelper.getServiceSubstitutionMappingsTypeName());
50 assertNotNull(fdntCsarHelper.getServiceMetadataAllProperties());
51 assertNull(fdntCsarHelper.getServiceInputs());
52 assertNotNull(fdntCsarHelper.getConformanceLevel());
53 assertNotNull(fdntCsarHelper.getDataTypes());
54 assertNull(fdntCsarHelper.getInputsWithAnnotations());
55 assertNotNull(fdntCsarHelper.getVFModule());
58 private ISdcCsarHelper getCsarHelper(final String path) throws SdcToscaParserException {
59 System.out.println("Parsing CSAR " + path + "...");
60 final String fileName = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
61 return factory.getSdcCsarHelper((new File(fileName)).getAbsolutePath());