diff options
author | Pavel Aharoni <pa0916@att.com> | 2017-12-13 17:01:19 +0200 |
---|---|---|
committer | Pavel Aharoni <pa0916@att.com> | 2017-12-13 17:01:19 +0200 |
commit | 7dd51a2e187a6cfea05ed46004a25152d687197f (patch) | |
tree | 55becadeb979807820a71f2dc6cf536a97d51f9b /src/test/java | |
parent | 05b2a83f8c47883fba48b1d8c2586752aef9192f (diff) |
sdc-tosca tests change and refactoring
Change-Id: Ibffb597a5197675499c7fe544fba953065f2f9bf
Issue-ID: SDC-752
Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java | 3 | ||||
-rw-r--r-- | src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java | 54 |
2 files changed, 46 insertions, 11 deletions
diff --git a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java index 90124c5..74e52db 100644 --- a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java +++ b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java @@ -15,6 +15,7 @@ import org.openecomp.sdc.toscaparser.api.common.JToscaException; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; public abstract class SdcToscaParserBasicTest { @@ -38,7 +39,7 @@ public abstract class SdcToscaParserBasicTest { static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data; - @BeforeClass + @BeforeSuite public static void init() throws SdcToscaParserException, JToscaException, IOException { factory = SdcToscaParserFactory.getInstance(); diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java index 288cea6..87d8f09 100644 --- a/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java +++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java @@ -1,16 +1,40 @@ package org.openecomp.sdc.impl; -import static org.testng.Assert.assertEquals; - -import java.util.List; -import java.util.stream.Collectors; - +import org.apache.commons.io.IOUtils; import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.tosca.parser.config.ConfigurationManager; +import org.openecomp.sdc.tosca.parser.config.JtoscaValidationIssueConfiguration; import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.openecomp.sdc.toscaparser.api.common.JToscaValidationIssue; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.stream.Collectors; + +import static org.testng.Assert.assertEquals; + public class ToscaParserValidationIssueTest extends SdcToscaParserBasicTest { + protected static ConfigurationManager configurationManager = ConfigurationManager.getInstance(); + + @BeforeClass + public void loadJtoscaValidationIssueConfiguration() throws IOException { + //load the tests dedicated configuration + configurationManager.setJtoscaValidationIssueConfiguration( "jtosca-validation-issue-configuration-test.yaml"); + factory.setConfigurationManager(configurationManager); + } + + @AfterClass + public void loadJtoscaValidationIssueOriginalConfiguration() throws IOException { + //load the tests dedicated configuration + configurationManager.setJtoscaValidationIssueConfiguration("jtosca-validation-issue-configuration.yaml"); + factory.setConfigurationManager(configurationManager); + + } + @Test public void testNoValidationIssues() throws SdcToscaParserException { @@ -42,15 +66,25 @@ public class ToscaParserValidationIssueTest extends SdcToscaParserBasicTest { List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions(); assertEquals( criticalsReport.size(),0); } + + @Test(expectedExceptions = SdcToscaParserException.class) + public void testCriticalIssueThrowsSdcToscaParserException() throws SdcToscaParserException { + getCsarHelper("csars/service-Nfod2images-csar.csar");//conformance level 4.0 + } + @Test - public void testMultiSinceConformanceLevelIssues() throws SdcToscaParserException { - ISdcCsarHelper Nfod2images = getCsarHelper("csars/service-Nfod2images-csar.csar");//conformance level 4.0 + public void testMultiSinceConformanceLevelIssues() { + try { + ISdcCsarHelper Nfod2images = getCsarHelper("csars/service-Nfod2images-csar.csar");//conformance level 4.0 + } catch (SdcToscaParserException e) { + System.out.println("SdcToscaParserException is caught here - this is WAD in this specific test."); + } List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions(); - assertEquals( notAnalyzedReport.size(),2); + assertEquals(2, notAnalyzedReport.size()); List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions(); - assertEquals( warningsReport.size(),0); + assertEquals( 0, warningsReport.size()); List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions(); - assertEquals( criticalsReport.size(),24); + assertEquals( 24, criticalsReport.size()); //JE006 multy values sinceCsarConformanceLevel assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE006")).collect(Collectors.toList()).size(), 18); assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE003")).collect(Collectors.toList()).size(), 6); |