From d5e341bc22977beac2cc2c9d4b9368245cefda3a Mon Sep 17 00:00:00 2001 From: Yuli Shlosberg Date: Tue, 28 Nov 2017 15:55:44 +0200 Subject: add tests Change-Id: Ifa5f6891a06d6bf5ae82d0dd73ee01aa60967afe Issue-ID: SDC-695 Signed-off-by: Yuli Shlosberg --- .../JToscaMetadataParse.java | 26 ------------- .../sdc/toscaparser/api/JToscaMetadataParse.java | 41 +++++++++++++++++++++ .../csars/tmpCSAR_Huawei_vSPGW_fixed.csar.csar | Bin 0 -> 44576 bytes 3 files changed, 41 insertions(+), 26 deletions(-) delete mode 100644 src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java create mode 100644 src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java create mode 100644 src/test/resources/csars/tmpCSAR_Huawei_vSPGW_fixed.csar.csar (limited to 'src/test') diff --git a/src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java b/src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java deleted file mode 100644 index 584a0fd..0000000 --- a/src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.openecomp.sdc.toscaparser; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.util.LinkedHashMap; - -import org.junit.Test; -import org.openecomp.sdc.toscaparser.api.ToscaTemplate; -import org.openecomp.sdc.toscaparser.api.common.JToscaException; - -public class JToscaMetadataParse { - - @Test - public void testMetadataParsedCorrectly() throws JToscaException { - String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/csar_hello_world.csar").getFile(); - File file = new File(fileStr); - ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null); - LinkedHashMap metadataProperties = toscaTemplate.getMetaProperties("TOSCA.meta"); - assertNotNull(metadataProperties); - Object entryDefinition = metadataProperties.get("Entry-Definitions"); - assertNotNull(entryDefinition); - assertEquals("tosca_helloworld.yaml", entryDefinition); - } -} diff --git a/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java b/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java new file mode 100644 index 0000000..79d166f --- /dev/null +++ b/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java @@ -0,0 +1,41 @@ +package org.openecomp.sdc.toscaparser.api; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.Collection; +import java.util.LinkedHashMap; + +import org.junit.Test; +import org.openecomp.sdc.toscaparser.api.common.JToscaException; +import org.openecomp.sdc.toscaparser.api.common.JToscaValidationIssue; +import org.openecomp.sdc.toscaparser.api.utils.ThreadLocalsHolder; + +public class JToscaMetadataParse { + + @Test + public void testMetadataParsedCorrectly() throws JToscaException { + String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/csar_hello_world.csar").getFile(); + File file = new File(fileStr); + ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null); + LinkedHashMap metadataProperties = toscaTemplate.getMetaProperties("TOSCA.meta"); + assertNotNull(metadataProperties); + Object entryDefinition = metadataProperties.get("Entry-Definitions"); + assertNotNull(entryDefinition); + assertEquals("tosca_helloworld.yaml", entryDefinition); + } + + @Test + public void noWarningsAfterParse() throws JToscaException { + String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/tmpCSAR_Huawei_vSPGW_fixed.csar.csar").getFile(); + File file = new File(fileStr); + ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null); + + +// Collection issues = ThreadLocalsHolder.getCollector().getValidationIssues().values(); +// assertTrue(issues.size() == 0 ); + } + +} diff --git a/src/test/resources/csars/tmpCSAR_Huawei_vSPGW_fixed.csar.csar b/src/test/resources/csars/tmpCSAR_Huawei_vSPGW_fixed.csar.csar new file mode 100644 index 0000000..70f8cc4 Binary files /dev/null and b/src/test/resources/csars/tmpCSAR_Huawei_vSPGW_fixed.csar.csar differ -- cgit 1.2.3-korg