diff options
author | talio <tali.orenbach@amdocs.com> | 2017-11-19 09:35:13 +0200 |
---|---|---|
committer | talio <tali.orenbach@amdocs.com> | 2017-11-19 11:10:19 +0200 |
commit | b91470aaf45ccd77c56a7882f0babc9b4a2b9637 (patch) | |
tree | 2cff08e3ad0d8679d65de9ef20051ecf0c083cba /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org | |
parent | 3e54d3de51fa86255ca5059c59fd68aea0f59488 (diff) |
import tosca bug
fix bug when converting parameters, when importing CSAR file
Issue - Id : SDC-646
Change-Id: Ie9c38f5e51e673a7c89add9e4e42fad93f966aa4
Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org')
-rw-r--r-- | openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java index 471e3891c7..5ee96aba07 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java @@ -2,6 +2,7 @@ package org.openecomp.core.converter.impl; import org.apache.commons.collections.CollectionUtils; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.core.converter.ToscaConverter; import org.openecomp.core.impl.ToscaConverterImpl; @@ -40,24 +41,39 @@ public class ToscaConverterImplTest { private static final ToscaConverter toscaConverter = new ToscaConverterImpl(); private static final String VIRTUAL_LINK = "virtualLink"; private static final String UNBOUNDED = "UNBOUNDED"; + private static final String BASE_DIR = "/mock/toscaConverter"; @Test public void testConvertMainSt() throws IOException { - String inputFilesPath = "/mock/toscaConverter/convertMainSt/in"; - String outputFilesPath = "/mock/toscaConverter/convertMainSt/out"; + String inputFilesPath = BASE_DIR + "/convertMainSt/in"; + String outputFilesPath = BASE_DIR + "/convertMainSt/out"; - FileContentHandler fileContentHandler = - createFileContentHandlerFromInput(inputFilesPath); + convertAndValidate(inputFilesPath, outputFilesPath); + } - Map<String, ServiceTemplate> expectedOutserviceTemplates = new HashMap<>(); - loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(), - expectedOutserviceTemplates); + @Test + public void testNodesConversion() throws IOException { + String inputFilesPath = BASE_DIR + "/convertCsar/in"; + String outputFilesPath = BASE_DIR + "/convertCsar/out"; - ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler); - ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(mainStName); + convertAndValidate(inputFilesPath, outputFilesPath); + } - checkSTResults(expectedOutserviceTemplates, null, mainSt); + @Test + public void testParameterConversion() throws IOException { + String inputFilesPath = BASE_DIR + "/convertParameters/in"; + String outputFilesPath = BASE_DIR + "/convertParameters/out"; + + convertAndValidate(inputFilesPath, outputFilesPath); + } + + @Test + public void testConversionWithInt() throws IOException { + String inputFilesPath = BASE_DIR + "/conversionWithInt/in"; + String outputFilesPath = BASE_DIR + "/conversionWithInt/out"; + + convertAndValidate(inputFilesPath, outputFilesPath); } @Test @@ -115,6 +131,25 @@ public class ToscaConverterImplTest { return buildOccurrences(Arrays.asList(bounds)); } + private void convertAndValidate(String inputFilesPath, String outputFilesPath) + throws IOException { + FileContentHandler fileContentHandler = + createFileContentHandlerFromInput(inputFilesPath); + + ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler); + validateConvertorOutput(outputFilesPath, toscaServiceModel); + } + + private void validateConvertorOutput(String outputFilesPath, ToscaServiceModel toscaServiceModel) + throws IOException { + ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(mainStName); + Map<String, ServiceTemplate> expectedOutserviceTemplates = new HashMap<>(); + loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(), + expectedOutserviceTemplates); + + checkSTResults(expectedOutserviceTemplates, null, mainSt); + } + private Object[] buildOccurrences(List<String> bounds) { NodeType nodeType = JsonUtil.json2Object("{derived_from=tosca.nodes.Root, description=MME_VFC, " + "properties={vendor={type=string, default=ERICSSON}, " + |