summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java28
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/importConvertTestNoImport.yml4
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/invalidToscaImport.yml5
3 files changed, 37 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
index d2c1ed8a17..a915b9b131 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
@@ -1200,6 +1200,34 @@ public class ToscaAnalyzerServiceImplTest {
}
@Test
+ public void testConvertToscaImportForEmptyImport() throws Exception {
+ String inputResourceName = "/mock/analyzerService/importConvertTestNoImport.yml";
+ byte[] uploadedFileData = IOUtils.toByteArray(this.getClass().getResource(inputResourceName));
+
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ ToscaAnalyzerServiceImpl toscaAnalyzerServiceImpl = new ToscaAnalyzerServiceImpl();
+ String convertServiceTemplateImport =
+ toscaAnalyzerServiceImpl.convertServiceTemplateImport(toscaExtensionYamlUtil, uploadedFileData);
+
+ Assert.assertNotNull(convertServiceTemplateImport);
+ ServiceTemplate serviceTemplate =
+ new YamlUtil().yamlToObject(convertServiceTemplateImport, ServiceTemplate.class);
+ Assert.assertNull(serviceTemplate.getImports());
+ }
+
+ @Test
+ public void testInvalidToscaImportSection() throws Exception {
+ thrown.expect(SdcRuntimeException.class);
+ thrown.expectMessage("Invalid TOSCA import section");
+ String inputResourceName = "/mock/analyzerService/invalidToscaImport.yml";
+ byte[] uploadedFileData = IOUtils.toByteArray(this.getClass().getResource(inputResourceName));
+
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ ToscaAnalyzerServiceImpl toscaAnalyzerServiceImpl = new ToscaAnalyzerServiceImpl();
+ toscaAnalyzerServiceImpl.convertServiceTemplateImport(toscaExtensionYamlUtil, uploadedFileData);
+ }
+
+ @Test
public void loadValidToscaYamlFileTest() throws Exception {
String inputResourceName = "/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml";
byte[] uploadedFileData = IOUtils.toByteArray(this.getClass().getResource(inputResourceName));
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/importConvertTestNoImport.yml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/importConvertTestNoImport.yml
new file mode 100644
index 0000000000..536e1367e5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/importConvertTestNoImport.yml
@@ -0,0 +1,4 @@
+tosca_definitions_version: tosca_simple_yaml_1_1
+node_types:
+ tosca.nodes.Root:
+ description: The TOSCA Node Type all other TOSCA base Node Types derive from \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/invalidToscaImport.yml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/invalidToscaImport.yml
new file mode 100644
index 0000000000..8a5cfaa9ac
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/invalidToscaImport.yml
@@ -0,0 +1,5 @@
+tosca_definitions_version: tosca_simple_yaml_1_1
+imports: abc
+node_types:
+ tosca.nodes.Root:
+ description: The TOSCA Node Type all other TOSCA base Node Types derive from \ No newline at end of file