diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/openecomp/sdc/toscaparser/api/JToscaImportTest.java | 64 | ||||
-rw-r--r-- | src/test/resources/csars/resource-Spgw-csar-ZTE.csar | bin | 0 -> 31639 bytes | |||
-rw-r--r-- | src/test/resources/csars/sdc-onboarding_csar.csar | bin | 0 -> 80596 bytes |
3 files changed, 64 insertions, 0 deletions
diff --git a/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaImportTest.java b/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaImportTest.java new file mode 100644 index 0000000..c8a30fa --- /dev/null +++ b/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaImportTest.java @@ -0,0 +1,64 @@ +package org.openecomp.sdc.toscaparser.api; + +import org.junit.Test; +import org.openecomp.sdc.toscaparser.api.common.JToscaException; +import org.openecomp.sdc.toscaparser.api.utils.ThreadLocalsHolder; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static org.junit.Assert.assertEquals; + +public class JToscaImportTest { + + @Test + public void testNoMissingTypeValidationError() throws JToscaException { + String fileStr = JToscaImportTest.class.getClassLoader().getResource + ("csars/sdc-onboarding_csar.csar").getFile(); + File file = new File(fileStr); + new ToscaTemplate(file.getAbsolutePath(), null, true, null); + List<String> missingTypeErrors = ThreadLocalsHolder.getCollector() + .getValidationIssueReport() + .stream() + .filter(s -> s.contains("JE136")) + .collect(Collectors.toList()); + assertEquals(0, missingTypeErrors.size()); + } + + @Test + public void testNoStackOverFlowError() { + Exception jte = null; + try { + String fileStr = JToscaImportTest.class.getClassLoader().getResource + ("csars/sdc-onboarding_csar.csar").getFile(); + File file = new File(fileStr); + new ToscaTemplate(file.getAbsolutePath(), null, true, null); + } catch (Exception e){ + jte = e; + } + assertEquals(null, jte); + } + + @Test + public void testNoInvalidImports() throws JToscaException { + List<String> fileNames = new ArrayList<>(); + fileNames.add("csars/tmpCSAR_Huawei_vSPGW_fixed.csar"); + fileNames.add("csars/sdc-onboarding_csar.csar"); + fileNames.add("csars/resource-Spgw-csar-ZTE.csar"); + + for (String fileName : fileNames) { + String fileStr = JToscaImportTest.class.getClassLoader().getResource(fileName).getFile(); + File file = new File(fileStr); + new ToscaTemplate(file.getAbsolutePath(), null, true, null); + List<String> invalidImportErrors = ThreadLocalsHolder.getCollector() + .getValidationIssueReport() + .stream() + .filter(s -> s.contains("JE195")) + .collect(Collectors.toList()); + assertEquals(0, invalidImportErrors.size()); + } + } + +} diff --git a/src/test/resources/csars/resource-Spgw-csar-ZTE.csar b/src/test/resources/csars/resource-Spgw-csar-ZTE.csar Binary files differnew file mode 100644 index 0000000..58c3ddd --- /dev/null +++ b/src/test/resources/csars/resource-Spgw-csar-ZTE.csar diff --git a/src/test/resources/csars/sdc-onboarding_csar.csar b/src/test/resources/csars/sdc-onboarding_csar.csar Binary files differnew file mode 100644 index 0000000..e1c3267 --- /dev/null +++ b/src/test/resources/csars/sdc-onboarding_csar.csar |