summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/test/java
diff options
context:
space:
mode:
authorojasdubey <ojas.dubey@amdocs.com>2019-07-08 13:07:18 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-07-08 12:00:38 +0000
commitda8b24151295d923cc632dfa2d296b3c67f6cce2 (patch)
tree28e104919c9506d38229cb437bf31cb50d86f46f /openecomp-be/lib/openecomp-tosca-lib/src/test/java
parent3b72874a95ce734f555334fb0fba987a069664d0 (diff)
Move import handling to service template
Moving the handling of all import formats parsing to ServiceTemplate class to make it generic and reusable Change-Id: I80595c3654a625275549a3bb3afe8ba7c9455aff Issue-ID: SDC-2421 Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test/java')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java53
1 files changed, 1 insertions, 52 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 a915b9b131..f8e6759555 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
@@ -30,6 +30,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+
import org.apache.commons.io.IOUtils;
import org.hamcrest.core.StringContains;
import org.junit.Assert;
@@ -62,7 +63,6 @@ import org.onap.sdc.tosca.datatypes.model.Status;
import org.onap.sdc.tosca.datatypes.model.SubstitutionMapping;
import org.onap.sdc.tosca.datatypes.model.TopologyTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
-import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.tosca.TestUtil;
@@ -1177,57 +1177,6 @@ public class ToscaAnalyzerServiceImplTest {
}
@Test
- public void testConvertToscaImport() throws Exception {
- String inputResourceName = "/mock/analyzerService/importConvertTest.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.assertNotNull(serviceTemplate.getImports().get(0).get("data"));
- Assert.assertNotNull(serviceTemplate.getImports().get(1).get("artifacts"));
- Assert.assertNotNull(serviceTemplate.getImports().get(2).get("capabilities"));
- Assert.assertNotNull(serviceTemplate.getImports().get(3).get("api_interfaces"));
- Assert.assertNotNull(serviceTemplate.getImports().get(4).get("api_util_relationships"));
- Assert.assertNotNull(serviceTemplate.getImports().get(5).get("common"));
- Assert.assertNotNull(serviceTemplate.getImports().get(6).get("api_util"));
- Assert.assertNotNull(serviceTemplate.getImports().get(7).get("relationshipsExt"));
- }
-
- @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));