summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main
diff options
context:
space:
mode:
authorojasdubey <ojas.dubey@amdocs.com>2018-12-13 18:02:21 +0530
committerojasdubey <ojas.dubey@amdocs.com>2018-12-13 18:04:56 +0530
commitc9e7a45f31a60ec51b770febae2213f5b7668960 (patch)
tree459b469702a4a54e32ea32569c6de82fb541f6cf /openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main
parenta15d4951fe5f3aa243ceed45d3250f8fe722143b (diff)
Fix - nfc_naming_code and nfc_function
1. Fix for nfc_naming code not getting populated for more than one instance of same vm type 2. Added and updated the unit test cases and test data 3. Sonar fixes Change-Id: I50ddb7d388a5e6b2d4370dedfbbe23ba31a4b61d Issue-ID: SDC-2001 Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main')
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java40
1 files changed, 21 insertions, 19 deletions
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 afc5bd2bdc..658fc98725 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
@@ -29,7 +29,6 @@ import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.MULTIDEPLOYMENTFLA
import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_ABSTRACT_SUBSTITUTE;
import static org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType.NATIVE_DEPENDS_ON;
import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.ABSTRACT_NODE_TEMPLATE_ID_PREFIX;
import static org.openecomp.sdc.translator.services.heattotosca.Constants.VNF_NODE_TEMPLATE_ID_SUFFIX;
import java.util.ArrayList;
@@ -38,6 +37,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
@@ -92,7 +92,8 @@ public class AbstractSubstituteToscaEnricher {
final NodeTemplate nodeTemplate =
toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId).orElse(null);
- if (toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate, toscaModel)) {
+ if (nodeTemplate != null && toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE,
+ serviceTemplate, toscaModel)) {
String componentDisplayName = getComponentDisplayName(nodeTemplateId, nodeTemplate);
@@ -115,15 +116,17 @@ public class AbstractSubstituteToscaEnricher {
boolean isServiceTemplateFilterNotExists = false;
if (!StringUtils.isEmpty(mandatory)) {
- Map innerProps = (Map<String, Object>) nodeTemplate.getProperties()
+ Map<String, Object> innerProps = (Map<String, Object>) nodeTemplate.getProperties()
.get(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
if (innerProps == null) {
- innerProps = new HashMap<String, Object>();
+ innerProps = new HashMap<>();
isServiceTemplateFilterNotExists = true;
}
-
- innerProps.put(MANDATORY, getValue(mandatory));
+ Optional<Boolean> mandatoryValue = getValue(mandatory);
+ if (mandatoryValue.isPresent()) {
+ innerProps.put(MANDATORY, mandatoryValue.get());
+ }
if (isServiceTemplateFilterNotExists) {
nodeTemplate.getProperties().put(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME, innerProps);
@@ -168,7 +171,8 @@ public class AbstractSubstituteToscaEnricher {
final NodeTemplate nodeTemplate =
toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId).orElse(null);
- if (toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate, toscaModel)) {
+ if (nodeTemplate != null &&
+ toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate, toscaModel)) {
String componentDisplayName = getComponentDisplayName(nodeTemplateId, nodeTemplate);
@@ -238,15 +242,13 @@ public class AbstractSubstituteToscaEnricher {
private String getComponentDisplayName(String nodeTemplateId, NodeTemplate nodeTemplate) {
String componentDisplayName;
- 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];
+ final String type = nodeTemplate.getType();
+ if (MULTIDEPLOYMENTFLAVOR_NODE_TYPE.equals(type)) {
+ componentDisplayName = nodeTemplateId.substring(0, nodeTemplateId.lastIndexOf(VNF_NODE_TEMPLATE_ID_SUFFIX));
} else {
- final String type = nodeTemplate.getType();
- componentDisplayName = MULTIDEPLOYMENTFLAVOR_NODE_TYPE.equals(type)
- ? nodeTemplateId.substring(0, nodeTemplateId.lastIndexOf(VNF_NODE_TEMPLATE_ID_SUFFIX))
- : type.substring(type.lastIndexOf('.') + 1);
+ String vmType = DataModelUtil.getNamespaceSuffix(type);
+ final String[] removedSuffix = vmType.split("_\\d+");
+ componentDisplayName = removedSuffix[0];
}
return componentDisplayName;
}
@@ -265,14 +267,14 @@ public class AbstractSubstituteToscaEnricher {
}
}
- private Boolean getValue(String value) {
+ private Optional<Boolean> getValue(String value) {
switch (value) {
case "YES":
- return true;
+ return Optional.of(Boolean.TRUE);
case "NO":
- return false;
+ return Optional.of(Boolean.FALSE);
default:
- return null;
+ return Optional.empty();
}
}