From b91470aaf45ccd77c56a7882f0babc9b4a2b9637 Mon Sep 17 00:00:00 2001 From: talio Date: Sun, 19 Nov 2017 09:35:13 +0200 Subject: import tosca bug fix bug when converting parameters, when importing CSAR file Issue - Id : SDC-646 Change-Id: Ie9c38f5e51e673a7c89add9e4e42fad93f966aa4 Signed-off-by: talio --- .../converter/impl/ToscaConverterImplTest.java | 55 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java') 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 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 expectedOutserviceTemplates = new HashMap<>(); + loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(), + expectedOutserviceTemplates); + + checkSTResults(expectedOutserviceTemplates, null, mainSt); + } + private Object[] buildOccurrences(List bounds) { NodeType nodeType = JsonUtil.json2Object("{derived_from=tosca.nodes.Root, description=MME_VFC, " + "properties={vendor={type=string, default=ERICSSON}, " + -- cgit 1.2.3-korg