summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java6
4 files changed, 14 insertions, 16 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
index fb0622cd67..ffc27106bb 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.enrichment.impl.external.artifact;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.enrichment.inter.Enricher;
import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
@@ -30,7 +29,6 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Collection;
import java.util.HashMap;
@@ -48,11 +46,9 @@ public class ExternalArtifactEnricher extends Enricher {
private static Logger logger = LoggerFactory.getLogger(ExternalArtifactEnricher.class);
private static Collection<String> getExternalArtifactEnrichedImplClassesList() {
- InputStream externalArtifactEnrichConfigurationJson =
- FileUtils.getFileInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE);
@SuppressWarnings("unchecked")
- Map<String, String> confFileAsMap =
- JsonUtil.json2Object(externalArtifactEnrichConfigurationJson, Map.class);
+ Map<String, String> confFileAsMap = FileUtils.readViaInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE,
+ stream -> JsonUtil.json2Object(stream, Map.class));
return confFileAsMap.values();
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java
index 32df165eb3..a7762e86ca 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java
@@ -77,7 +77,7 @@ public class AbstractSubstituteToscaEnricher {
if (toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate,
toscaModel)) {
- String componentDisplayName = getComponentDisplayName(nodeTemplateId);
+ String componentDisplayName = getComponentDisplayName(nodeTemplateId, nodeTemplate);
setProperty(nodeTemplate, VM_TYPE_TAG, componentDisplayName);
@@ -157,7 +157,7 @@ public class AbstractSubstituteToscaEnricher {
if (toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate,
toscaModel)) {
- String componentDisplayName = getComponentDisplayName(nodeTemplateId);
+ String componentDisplayName = getComponentDisplayName(nodeTemplateId, nodeTemplate);
if (componentDisplayNameToNodeTempalteIds.containsKey(componentDisplayName)) {
componentDisplayNameToNodeTempalteIds.get(componentDisplayName).add(nodeTemplateId);
@@ -206,12 +206,17 @@ public class AbstractSubstituteToscaEnricher {
nodeTemplate.setRequirements(requirements);
}
- private String getComponentDisplayName(String nodeTemplateId ) {
+ private String getComponentDisplayName(String nodeTemplateId, NodeTemplate nodeTemplate) {
String componentDisplayName = null;
if (nodeTemplateId.contains(ABSTRACT_NODE_TEMPLATE_ID_PREFIX)) {
String removedPrefix = nodeTemplateId.split(ABSTRACT_NODE_TEMPLATE_ID_PREFIX)[1];
final String[] removedSuffix = removedPrefix.split("_\\d");
componentDisplayName = removedSuffix[0];
+ } else {
+ final String type = nodeTemplate.getType();
+ final String[] splitted = type.split("\\.");
+ componentDisplayName = splitted[splitted.length - 1];
+
}
return componentDisplayName;
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
index 38f7a1c56e..5f1a67138d 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
@@ -42,7 +42,6 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
-import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
@@ -159,8 +158,8 @@ public class MonitoringMibEnricherTest {
}
private ByteBuffer getMibByteBuffer(String fileName) {
- InputStream mibFile = FileUtils.getFileInputStream(this.getClass().getResource(fileName));
- byte[] mibBytes = FileUtils.toByteArray(mibFile);
+ byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
+ stream -> FileUtils.toByteArray(stream));
return ByteBuffer.wrap(mibBytes);
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
index aeefc91aa3..2f839a7946 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
@@ -21,14 +21,12 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
-import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
public class ProcessArtifactEnricherTest {
@@ -112,8 +110,8 @@ public class ProcessArtifactEnricherTest {
}
private ByteBuffer getMibByteBuffer(String fileName) {
- InputStream mibFile = FileUtils.getFileInputStream(this.getClass().getResource(fileName));
- byte[] mibBytes = FileUtils.toByteArray(mibFile);
+ byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
+ stream -> FileUtils.toByteArray(stream));
return ByteBuffer.wrap(mibBytes);
}
}