Migrate TestNG to Junit5
[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.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;
29
30 import static org.junit.jupiter.api.Assertions.assertEquals;
31 import static org.junit.jupiter.api.Assertions.assertNotNull;
32
33 @ExtendWith({SdcToscaParserBasicTest.class})
34  class ToscaParserConfigurationTest extends SdcToscaParserBasicTest {
35
36     @Test
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());
43     }
44
45
46     @Test
47     public void testErrorConfigurations()  {
48         ErrorConfiguration errorConfig = ConfigurationManager.getInstance().getErrorConfiguration();
49         assertNotNull(errorConfig);
50         assertNotNull(errorConfig.getErrors());
51     }
52
53     @Test
54     public void testSetErrorConfiguration() {
55         ConfigurationManager configurationManager = ConfigurationManager.getInstance();
56         try {
57             configurationManager.setErrorConfiguration("error-configuration-test.yaml");
58             ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration();
59             assertEquals(false,
60                 errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError());
61             assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError());
62         }
63         finally {
64             // Reset the configuration for other tests
65             configurationManager.setErrorConfiguration("error-configuration.yaml");
66         }
67     }
68
69     @Test
70     public void testSetJtoscaValidationIssueConfiguration() {
71         ConfigurationManager configurationManager = ConfigurationManager.getInstance();
72         try {
73             configurationManager.setJtoscaValidationIssueConfiguration(
74                 "jtosca-validation-issue-configuration-test.yaml");
75             JtoscaValidationIssueConfiguration issueConfig = configurationManager
76                 .getJtoscaValidationIssueConfiguration();
77             assertNotNull(issueConfig);
78         }
79         finally {
80             // Reset the configuration for other tests
81             configurationManager.setJtoscaValidationIssueConfiguration
82                 ("jtosca-validation-issue-configuration.yaml");
83         }
84     }
85 }