summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml10
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml10
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java101
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml13
4 files changed, 51 insertions, 83 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml
index 1292586816..1853916aab 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml
@@ -9,16 +9,6 @@
<artifactId>onap-tosca-datatype</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-tosca-lib</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-facade-core</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
<parent>
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
index eba914a79b..9d63529c72 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
@@ -10,16 +10,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-tosca-lib</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-facade-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-translator-core</artifactId>
<version>${project.version}</version>
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java
index 1eb09a8b44..dfca19b96e 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java
@@ -19,7 +19,13 @@
package org.openecomp.core.converter.impl.pnfd;
-import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.onap.sdc.tosca.services.YamlUtil;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.converter.pnfd.PnfdTransformationEngine;
+import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
import java.io.IOException;
import java.io.InputStream;
@@ -31,20 +37,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
-import org.onap.sdc.tosca.services.YamlUtil;
-import org.openecomp.core.converter.ServiceTemplateReaderService;
-import org.openecomp.core.converter.pnfd.PnfdTransformationEngine;
-import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
-@RunWith(Parameterized.class)
+import static org.junit.Assert.assertEquals;
+
public class PnfTransformationEngineParameterizedTest {
private static final String TEST_CASES_PATH = "transformation/pnfParseEngine";
@@ -52,38 +49,9 @@ public class PnfTransformationEngineParameterizedTest {
private static final String OUTPUT_FOLDER = "expectedOutput";
private static final String DEFAULT_OUTPUT_FILE_NAME = "defaultOutput.yaml";
- private final String inputFileName;
- private final Path inputFilePath;
- private final String outputFileName;
- private final Path outputFilePath;
- private final String transformationDescriptorFileName;
- private final Path transformationDescriptorFilePath;
private final YamlUtil yamlUtil = new YamlUtil();
private final ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- public PnfTransformationEngineParameterizedTest(final String inputFileName, final Path inputFilePath,
- final String outputFileName, final Path outputFilePath,
- final String transformationDescriptorFileName, final Path transformationDescriptorFilePath) {
- this.inputFileName = inputFileName;
- this.inputFilePath = inputFilePath;
- this.outputFileName = outputFileName;
- this.outputFilePath = outputFilePath;
- this.transformationDescriptorFileName = transformationDescriptorFileName;
- this.transformationDescriptorFilePath = transformationDescriptorFilePath;
- }
-
-
- @Parameterized.Parameters(name = "{index}: input: {0}, descriptor: {4}, output: {2}")
- public static Collection<Object> input() throws IOException, URISyntaxException {
- return Files.list(getPathFromClasspath(TEST_CASES_PATH)).map(path -> {
- try {
- return buildTestCase(path);
- } catch (final IOException e) {
- return null;
- }
- }).filter(Objects::nonNull).flatMap(Collection::stream).collect(Collectors.toList());
- }
-
private static Collection<Object[]> buildTestCase(final Path testCasePath) throws IOException {
final Path inputFilePath = Files.list(testCasePath)
.filter(path -> path.toFile().getName().endsWith("yaml"))
@@ -94,7 +62,7 @@ public class PnfTransformationEngineParameterizedTest {
}
final List<Path> transformationDescriptorList;
try (final Stream<Path> files = Files.walk(testCasePath.resolve(TRANSFORMATION_DESCRIPTOR_FOLDER))) {
- transformationDescriptorList = files.filter(path -> Files.isRegularFile(path))
+ transformationDescriptorList = files.filter(Files::isRegularFile)
.map(path -> Paths.get(TEST_CASES_PATH, testCasePath.getFileName().toString()
, TRANSFORMATION_DESCRIPTOR_FOLDER, path.getFileName().toString()))
.collect(Collectors.toList());
@@ -102,7 +70,7 @@ public class PnfTransformationEngineParameterizedTest {
final List<Path> outputList;
try (final Stream<Path> files = Files.walk(testCasePath.resolve(OUTPUT_FOLDER))) {
- outputList = files.filter(path -> Files.isRegularFile(path)).collect(Collectors.toList());
+ outputList = files.filter(Files::isRegularFile).collect(Collectors.toList());
}
final Path defaultOutput = outputList.stream()
.filter(path -> path.toFile().getName().equals(DEFAULT_OUTPUT_FILE_NAME))
@@ -115,29 +83,38 @@ public class PnfTransformationEngineParameterizedTest {
.filter(path -> path.toFile().getName().equals(transformationDescriptorPath.toFile().getName()))
.findFirst().orElse(defaultOutput);
if (outputPath != null) {
- testCaseList.add(new Object[] {inputFilePath.toFile().getName(), inputFilePath,
- outputPath.toFile().getName(), outputPath,
- transformationDescriptorPath.toFile().getName(), transformationDescriptorPath});
+ testCaseList.add(new Object[]{ inputFilePath, outputPath, transformationDescriptorPath});
}
}
-
return testCaseList;
-
}
@Test
- public void testTopologyTemplateConversions() throws IOException {
- final byte[] descriptor = Files.readAllBytes(inputFilePath);
- final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(descriptor);
- final ServiceTemplate serviceTemplate = new ServiceTemplate();
-
- final PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTemplateTransformationEngine(
- serviceTemplateReaderService, serviceTemplate, transformationDescriptorFilePath.toString());
- pnfdTransformationEngine.transform();
-
- final String result = yamlUtil.objectToYaml(serviceTemplate);
- final String expectedResult = parseToYaml(outputFilePath);
- assertEquals(expectedResult, result);
+ public void testTopologyTemplateConversions() throws IOException, URISyntaxException {
+ Files.list(getPathFromClasspath()).forEach(testCasePath -> {
+ try {
+ var paths = buildTestCase(testCasePath);
+ paths.forEach(p -> {
+ try {
+ final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(Files.readAllBytes((Path) p[0]));
+ final ServiceTemplate serviceTemplate = new ServiceTemplate();
+
+ final PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTemplateTransformationEngine(
+ serviceTemplateReaderService, serviceTemplate, p[2].toString());
+ pnfdTransformationEngine.transform();
+
+ final String result = yamlUtil.objectToYaml(serviceTemplate);
+ final String expectedResult = parseToYaml((Path) p[1]);
+ assertEquals(expectedResult, result);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ );
}
private String parseToYaml(final Path filePath) throws IOException {
@@ -147,7 +124,7 @@ public class PnfTransformationEngineParameterizedTest {
}
}
- private static Path getPathFromClasspath(final String location) throws URISyntaxException {
- return Paths.get(PnfTransformationEngineParameterizedTest.class.getClassLoader().getResource(location).toURI());
+ private static Path getPathFromClasspath() throws URISyntaxException {
+ return Paths.get(PnfTransformationEngineParameterizedTest.class.getClassLoader().getResource(PnfTransformationEngineParameterizedTest.TEST_CASES_PATH).toURI());
}
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml
index 843923aa12..24a0866208 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml
@@ -18,5 +18,16 @@
<module>openecomp-tosca-converter-core</module>
</modules>
-
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-tosca-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project> \ No newline at end of file