From 67e400cc929314f1d66accb2f2f47d489f6b0c4f Mon Sep 17 00:00:00 2001 From: sheetalm Date: Tue, 12 Jun 2018 17:32:56 +0530 Subject: Fix for nfcparameters in component questionnaire issue - nfc naming code and nfc function fields' values are wiped out with a VSP update Moved the above fields from composition to questionnaire Add BDD test. Add license to java files Change-Id: I2b746fedc17c19b716df35bf0dad2c212f15df30 Issue-ID: SDC-1419 Signed-off-by: sheetalm --- .../tosca/AbstractSubstituteToscaEnricher.java | 14 ++++----- .../impl/tosca/ComponentQuestionnaireData.java | 34 +++++++++++++++------- .../enrichment/impl/util/EnrichmentConstants.java | 24 +++++++++++++-- .../tosca/AbstractSubstituteToscaEnricherTest.java | 12 ++++---- 4 files changed, 58 insertions(+), 26 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl') 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 add04164c2..80e469771d 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 @@ -21,8 +21,8 @@ import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATO import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_FUNCTION; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_FUNCTION; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_NAMING_CODE; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VM_TYPE_TAG; import static org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType.NATIVE_NODE; import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_ABSTRACT_SUBSTITUTE; @@ -70,7 +70,7 @@ public class AbstractSubstituteToscaEnricher { final Map> sourceToTargetDependencies = componentQuestionnaireData .populateDependencies(vspId, version, componentQuestionnaireData - .getSourceToTargetComponent()); + .getSourceToTargetComponent()); Map> errors = new HashMap<>(); final ServiceTemplate serviceTemplate = @@ -124,15 +124,15 @@ public class AbstractSubstituteToscaEnricher { getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, HIGH_AVAIL_MODE)); - setProperty(nodeTemplate, VFC_NAMING_CODE, + setProperty(nodeTemplate, NFC_NAMING_CODE, getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, - VFC_NAMING_CODE)); + NFC_NAMING_CODE)); setProperty(nodeTemplate, VFC_CODE, getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, VFC_CODE)); - setProperty(nodeTemplate, VFC_FUNCTION, - getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, VFC_FUNCTION)); + setProperty(nodeTemplate, NFC_FUNCTION, + getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, NFC_FUNCTION)); if (componentProperties.get(componentDisplayName).get(MIN_INSTANCES) != null) { nodeTemplate.getProperties().put(MIN_INSTANCES, diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java index 9ebe9e5e67..78242a6c61 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java @@ -1,5 +1,20 @@ -package org.openecomp.sdc.enrichment.impl.tosca; +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openecomp.sdc.enrichment.impl.tosca; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants; @@ -23,7 +38,7 @@ import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AV import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_NAMING_CODE; public class ComponentQuestionnaireData { @@ -64,16 +79,13 @@ public class ComponentQuestionnaireData { sourceToTarget.put(component.getId(), componentData.getDisplayName()); - String vfc_code = componentData != null ? componentData.getVfcCode() : null; - questionnaireParams.put(VFC_NAMING_CODE, vfc_code); - - String nfcCode = componentData.getNfcCode() != null ? componentData.getNfcCode() : null; - questionnaireParams.put(EnrichmentConstants.VFC_CODE, nfcCode); + String nfcNamingCode = componentQuestionnaire.getGeneral().getNfcNamingCode() != null ? + componentQuestionnaire.getGeneral().getNfcNamingCode() : null; + questionnaireParams.put(NFC_NAMING_CODE, nfcNamingCode); - String vfcDescription = - componentData.getNfcFunction() != null ? componentData.getNfcFunction() : - null; - questionnaireParams.put(EnrichmentConstants.VFC_FUNCTION, vfcDescription); + String vfcDescription = componentQuestionnaire.getGeneral().getNfcFunction() != null ? + componentQuestionnaire.getGeneral().getNfcFunction() : null; + questionnaireParams.put(EnrichmentConstants.NFC_FUNCTION, vfcDescription); if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null) { diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java index 036d64014a..18d28afb07 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java @@ -1,14 +1,34 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.openecomp.sdc.enrichment.impl.util; public class EnrichmentConstants { - public static final String VFC_NAMING_CODE = "nfc_naming_code"; + public static final String NFC_NAMING_CODE = "nfc_naming_code"; public static final String MANDATORY = "mandatory"; public static final String HIGH_AVAIL_MODE = "high_availablity"; public static final String MIN_INSTANCES = "min_instances"; public static final String MAX_INSTANCES = "max_instances"; public static final String VM_TYPE_TAG = "vm_type_tag"; public static final String VFC_CODE = "nfc_code"; - public static final String VFC_FUNCTION = "nfc_function"; + public static final String NFC_FUNCTION = "nfc_function"; + + private EnrichmentConstants() { + + } } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java index 11cab5f0a5..d2fb48cb7d 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java @@ -7,8 +7,8 @@ import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATO import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_FUNCTION; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_FUNCTION; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_NAMING_CODE; import org.apache.commons.collections.map.HashedMap; import org.mockito.InjectMocks; @@ -57,9 +57,9 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest Map innerProps = new HashMap<>(); innerProps.put(MANDATORY, "YES"); innerProps.put(HIGH_AVAIL_MODE, "geo-activestandby"); - innerProps.put(VFC_NAMING_CODE, "Code1"); + innerProps.put(NFC_NAMING_CODE, "Code1"); innerProps.put(VFC_CODE, "pd_server_code"); - innerProps.put(VFC_FUNCTION, "pd_server_description"); + innerProps.put(NFC_FUNCTION, "pd_server_description"); innerProps.put(MIN_INSTANCES, 1); innerProps.put(MAX_INSTANCES, 2); @@ -99,9 +99,9 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest Map innerProps = new HashedMap(); innerProps.put(MANDATORY, "NO"); innerProps.put(HIGH_AVAIL_MODE, ""); - innerProps.put(VFC_NAMING_CODE, "pd_server_code1"); + innerProps.put(NFC_NAMING_CODE, "pd_server_code1"); innerProps.put(VFC_CODE, "pd_server_code"); - innerProps.put(VFC_FUNCTION, "pd_server_description"); + innerProps.put(NFC_FUNCTION, "pd_server_description"); innerProps.put(MIN_INSTANCES, null); innerProps.put(MAX_INSTANCES, null); -- cgit 1.2.3-korg