2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.sdc.impl;
23 import org.junit.jupiter.api.extension.ExtendWith;
24 import org.onap.sdc.tosca.parser.config.ErrorConfiguration;
25 import org.onap.sdc.tosca.parser.config.JtoscaValidationIssueConfiguration;
26 import org.junit.jupiter.api.Test;
27 import org.onap.sdc.tosca.parser.config.Configuration;
28 import org.onap.sdc.tosca.parser.config.ConfigurationManager;
30 import static org.junit.jupiter.api.Assertions.assertEquals;
31 import static org.junit.jupiter.api.Assertions.assertNotNull;
33 @ExtendWith({SdcToscaParserBasicTest.class})
34 class ToscaParserConfigurationTest extends SdcToscaParserBasicTest {
37 public void testConfigurationConformanceLevel() {
38 Configuration config = ConfigurationManager.getInstance().getConfiguration();
39 assertNotNull(config);
40 assertNotNull(config.getConformanceLevel());
41 assertNotNull(config.getConformanceLevel().getMaxVersion());
42 assertNotNull(config.getConformanceLevel().getMinVersion());
47 public void testErrorConfigurations() {
48 ErrorConfiguration errorConfig = ConfigurationManager.getInstance().getErrorConfiguration();
49 assertNotNull(errorConfig);
50 assertNotNull(errorConfig.getErrors());
54 public void testSetErrorConfiguration() {
55 ConfigurationManager configurationManager = ConfigurationManager.getInstance();
57 configurationManager.setErrorConfiguration("error-configuration-test.yaml");
58 ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration();
60 errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError());
61 assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError());
64 // Reset the configuration for other tests
65 configurationManager.setErrorConfiguration("error-configuration.yaml");
70 public void testSetJtoscaValidationIssueConfiguration() {
71 ConfigurationManager configurationManager = ConfigurationManager.getInstance();
73 configurationManager.setJtoscaValidationIssueConfiguration(
74 "jtosca-validation-issue-configuration-test.yaml");
75 JtoscaValidationIssueConfiguration issueConfig = configurationManager
76 .getJtoscaValidationIssueConfiguration();
77 assertNotNull(issueConfig);
80 // Reset the configuration for other tests
81 configurationManager.setJtoscaValidationIssueConfiguration
82 ("jtosca-validation-issue-configuration.yaml");