summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java55
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}, " +