diff options
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java | 20 | ||||
-rw-r--r-- | src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java | 30 |
2 files changed, 49 insertions, 1 deletions
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java index 8c96303..b815064 100644 --- a/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java +++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java @@ -1,12 +1,14 @@ package org.openecomp.sdc.impl; import org.openecomp.sdc.tosca.parser.config.ErrorConfiguration; +import org.openecomp.sdc.tosca.parser.config.JtoscaValidationIssueConfiguration; import org.testng.annotations.Test; import org.openecomp.sdc.tosca.parser.config.Configuration; import org.openecomp.sdc.tosca.parser.config.ConfigurationManager; import java.io.IOException; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; public class ToscaParserConfigurationTest extends SdcToscaParserBasicTest { @@ -28,4 +30,22 @@ public class ToscaParserConfigurationTest extends SdcToscaParserBasicTest { assertNotNull(errorConfig.getErrors()); } + @Test + public void testSetErrorConfiguration() throws IOException { + ConfigurationManager configurationManager = ConfigurationManager.getInstance(); + configurationManager.setErrorConfiguration("error-configuration-test.yaml"); + ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration(); + assertEquals(false, errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError()); + assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError()); + } + + @Test + public void testSetJtoscaValidationIssueConfiguration() throws IOException { + ConfigurationManager configurationManager = ConfigurationManager.getInstance(); + configurationManager.setJtoscaValidationIssueConfiguration( + "jtosca-validation-issue-configuration-test.yaml"); + JtoscaValidationIssueConfiguration issueConfig = configurationManager + .getJtoscaValidationIssueConfiguration(); + assertNotNull(issueConfig); + } } diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java index 4e5c9bc..65c013a 100644 --- a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java +++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java @@ -1,8 +1,11 @@ package org.openecomp.sdc.impl; +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.tosca.parser.config.ConfigurationManager; +import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.openecomp.sdc.toscaparser.api.NodeTemplate; -import org.testng.annotations.Test; import org.openecomp.sdc.toscaparser.api.elements.Metadata; +import org.testng.annotations.Test; import java.util.List; import java.util.Map; @@ -187,5 +190,30 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest { assertEquals(serviceEcompNaming, "true"); } //endregion + + @Test + public void testCSARMissingConformanceLevelWithCustomErrorConfig() throws + SdcToscaParserException { + ConfigurationManager configurationManager = ConfigurationManager.getInstance(); + configurationManager.setErrorConfiguration("error-configuration-test.yaml"); + factory.setConfigurationManager(configurationManager); + + ISdcCsarHelper missingCSARMetaCsarCustomConfig = getCsarHelper + ("csars/service-missing-csar-meta-file.csar"); + String conformanceLevel = missingCSARMetaCsarCustomConfig.getConformanceLevel(); + assertNotNull(conformanceLevel); + assertEquals(conformanceLevel, configurationManager.getConfiguration().getConformanceLevel() + .getMaxVersion()); + + configurationManager.setErrorConfiguration("error-configuration.yaml"); + factory.setConfigurationManager(configurationManager); + } + + @Test(expectedExceptions = SdcToscaParserException.class) + public void testCSARMissingConformanceLevelWithDefaultErrorConfig() throws + SdcToscaParserException { + ISdcCsarHelper missingCSARMetaCsarDefaultConfig = getCsarHelper("csars/service-missing-csar-meta-file.csar"); + missingCSARMetaCsarDefaultConfig.getConformanceLevel(); + } } |