30f85e8176d876b8357a6394bd30b4cae9228a89
[sdc/sdc-tosca.git] / sdc-tosca / src / test / java / org / onap / sdc / impl / ToscaParserConfigurationTest.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 org.onap.sdc.tosca.parser.config.ErrorConfiguration;
24 import org.onap.sdc.tosca.parser.config.JtoscaValidationIssueConfiguration;
25 import org.testng.annotations.Test;
26 import org.onap.sdc.tosca.parser.config.Configuration;
27 import org.onap.sdc.tosca.parser.config.ConfigurationManager;
28
29 import static org.testng.Assert.assertEquals;
30 import static org.testng.Assert.assertNotNull;
31
32 public class ToscaParserConfigurationTest extends SdcToscaParserBasicTest {
33
34     @Test
35     public void testConfigurationConformanceLevel()  {
36         Configuration config = ConfigurationManager.getInstance().getConfiguration();
37         assertNotNull(config);
38         assertNotNull(config.getConformanceLevel());
39         assertNotNull(config.getConformanceLevel().getMaxVersion());
40         assertNotNull(config.getConformanceLevel().getMinVersion());
41     }
42
43
44     @Test
45     public void testErrorConfigurations()  {
46         ErrorConfiguration errorConfig = ConfigurationManager.getInstance().getErrorConfiguration();
47         assertNotNull(errorConfig);
48         assertNotNull(errorConfig.getErrors());
49     }
50
51     @Test
52     public void testSetErrorConfiguration() {
53         ConfigurationManager configurationManager = ConfigurationManager.getInstance();
54         try {
55             configurationManager.setErrorConfiguration("error-configuration-test.yaml");
56             ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration();
57             assertEquals(false,
58                 errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError());
59             assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError());
60         }
61         finally {
62             // Reset the configuration for other tests
63             configurationManager.setErrorConfiguration("error-configuration.yaml");
64         }
65     }
66
67     @Test
68     public void testSetJtoscaValidationIssueConfiguration() {
69         ConfigurationManager configurationManager = ConfigurationManager.getInstance();
70         try {
71             configurationManager.setJtoscaValidationIssueConfiguration(
72                 "jtosca-validation-issue-configuration-test.yaml");
73             JtoscaValidationIssueConfiguration issueConfig = configurationManager
74                 .getJtoscaValidationIssueConfiguration();
75             assertNotNull(issueConfig);
76         }
77         finally {
78             // Reset the configuration for other tests
79             configurationManager.setJtoscaValidationIssueConfiguration
80                 ("jtosca-validation-issue-configuration.yaml");
81         }
82     }
83 }