aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-06-24 14:09:30 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2021-07-05 09:20:43 +0000
commit47f2be812ff98c6d9d3862deb55638330e8db4f3 (patch)
treed0c86a1db92532c80b130ce205d896854c18f414 /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core
parentf9f5f68caee795d97221071fb26ebe0f572bae0d (diff)
Remove usage of outdated library JMockit (openecomp-be)
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3379 Change-Id: I7430deaa5993e67293e0f290700274dc2fff2db1
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java15
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java73
2 files changed, 34 insertions, 54 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java
index f97b1d37b2..94f7531310 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java
@@ -16,12 +16,14 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.core.converter.impl.pnfd;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
+import lombok.Getter;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.core.converter.ServiceTemplateReaderService;
import org.openecomp.core.converter.pnfd.PnfdTransformationEngine;
@@ -37,19 +39,23 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
public abstract class AbstractPnfdTransformationEngine implements PnfdTransformationEngine {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPnfdTransformationEngine.class);
+
protected final ServiceTemplate templateTo;
protected final ServiceTemplateReaderService templateFrom;
private final PnfdTransformationDescriptorReader pnfdTransformationDescriptorReader = new PnfdTransformationDescriptorReader();
- private final String descriptorResourcePath;
protected TransformationDescription transformationDescription;
protected Map<TransformationBlock, List<Transformation>> transformationGroupByBlockMap;
+ @Getter
+ private final String descriptorResourcePath;
- public AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo) {
+ public AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom,
+ final ServiceTemplate templateTo) {
this(templateFrom, templateTo, "pnfdTransformationTemplate/model-driven-conversion.yaml");
}
//used for tests purposes
- AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo,
+ AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom,
+ final ServiceTemplate templateTo,
final String descriptorResourcePath) {
this.templateFrom = templateFrom;
this.templateTo = templateTo;
@@ -61,7 +67,7 @@ public abstract class AbstractPnfdTransformationEngine implements PnfdTransforma
*/
protected void readDefinition() {
try (final InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(descriptorResourcePath)) {
- if (resourceAsStream == null) {
+ if (resourceAsStream == null) {
if (LOGGER.isErrorEnabled()) {
LOGGER.error("Could not find resource '{}'", descriptorResourcePath);
}
@@ -77,4 +83,5 @@ public abstract class AbstractPnfdTransformationEngine implements PnfdTransforma
* Executes all transformations specified in the descriptor.
*/
protected abstract void executeTransformations();
+
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
index 63a7d890d0..e5a10105a3 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
@@ -19,65 +19,46 @@
package org.openecomp.core.converter.impl.pnfd;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.spy;
-
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
+import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import mockit.Deencapsulation;
import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
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.impl.pnfd.parser.PnfdCustomNodeTypeBlockParser;
import org.openecomp.core.converter.pnfd.PnfdTransformationEngine;
-import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
-@RunWith(Parameterized.class)
-public class PnfTransformationEngineTest {
+class PnfTransformationEngineTest {
- public static final String INPUT_DIR = "pnfDescriptor/in/";
- public static final String OUTPUT_DIR = "pnfDescriptor/out/";
- private String inputFilename;
+ private static final String INPUT_DIR = "pnfDescriptor/in/";
+ private static final String OUTPUT_DIR = "pnfDescriptor/out/";
private final YamlUtil yamlUtil = new YamlUtil();
private final ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- public PnfTransformationEngineTest(final String inputFilename) {
- this.inputFilename = inputFilename;
- }
-
- @Parameterized.Parameters(name = "{index}: {0}")
- public static Collection<String> input() throws IOException {
+ private static List<String> input() throws IOException {
try (final Stream<Path> files = Files.list(getPathFromClasspath(INPUT_DIR))) {
- return files.map(path -> path.getFileName().toString())
- .collect(Collectors.toList());
+ return files.map(path -> path.getFileName().toString()).collect(Collectors.toList());
}
}
- @Test
- public void testTopologyTemplateConversions() throws IOException {
+ @ParameterizedTest(name = "{index}: {0}")
+ @MethodSource("input")
+ void testTopologyTemplateConversions(final String inputFilename) throws IOException {
final byte[] descriptor = getInputFileResource(inputFilename);
final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(descriptor);
final ServiceTemplate serviceTemplate = new ServiceTemplate();
- PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTypeTransformationEngine(
- serviceTemplateReaderService, serviceTemplate);
+ PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTypeTransformationEngine(serviceTemplateReaderService, serviceTemplate);
pnfdTransformationEngine.transform();
pnfdTransformationEngine = new PnfdNodeTemplateTransformationEngine(serviceTemplateReaderService, serviceTemplate);
pnfdTransformationEngine.transform();
@@ -85,26 +66,18 @@ public class PnfTransformationEngineTest {
final String yamlContent = yamlUtil.objectToYaml(serviceTemplate);
final String result = yamlUtil.objectToYaml(yamlUtil.yamlToObject(yamlContent, ServiceTemplate.class));
final String expectedResult = getExpectedResultFor(inputFilename);
- assertEquals(expectedResult, result);
- }
-
- @Test
- public void testBuildParseBlock() {
- final PnfdCustomNodeTypeBlockParser blockParser = spy(new PnfdCustomNodeTypeBlockParser(null));
- final ConversionDefinition conversionDefinition = Mockito.mock(ConversionDefinition.class);
- final Map<String, Object> stringObjectMap = new HashMap<>();
- stringObjectMap.put("type", null);
- stringObjectMap.put("name", null);
- assertEquals(Optional.empty(), Deencapsulation.invoke(blockParser, "buildParsedBlock",
- stringObjectMap, stringObjectMap, conversionDefinition));
+ Assertions.assertEquals(expectedResult, result);
}
- @Test
- public void testReadDefinition() {
- final PnfdTransformationEngine engine = spy(
- new PnfdNodeTemplateTransformationEngine(null, null, "test.txt"));
- Deencapsulation.invoke(engine, "readDefinition");
- assertNull(Deencapsulation.getField(engine, "transformationDescription"));
+ @ParameterizedTest(name = "{index}: {0}")
+ @MethodSource("input")
+ void testReadDefinition(final String inputFilename) throws IOException {
+ final byte[] descriptor = getInputFileResource(inputFilename);
+ final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(descriptor);
+ final ServiceTemplate serviceTemplate = new ServiceTemplate();
+ AbstractPnfdTransformationEngine engine = new PnfdNodeTemplateTransformationEngine(serviceTemplateReaderService, serviceTemplate, "test.txt");
+ engine.transform();
+ Assertions.assertNotNull(engine.getDescriptorResourcePath());
}
private String getExpectedResultFor(final String inputFilename) throws IOException {