diff options
author | ojasdubey <ojas.dubey@amdocs.com> | 2018-12-13 18:02:21 +0530 |
---|---|---|
committer | ojasdubey <ojas.dubey@amdocs.com> | 2018-12-13 18:04:56 +0530 |
commit | c9e7a45f31a60ec51b770febae2213f5b7668960 (patch) | |
tree | 459b469702a4a54e32ea32569c6de82fb541f6cf /openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java | |
parent | a15d4951fe5f3aa243ceed45d3250f8fe722143b (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/test/java')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java | 71 |
1 files changed, 54 insertions, 17 deletions
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 8430556f87..f185116598 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 @@ -30,7 +30,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.collections.map.HashedMap; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -49,8 +49,8 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest @InjectMocks AbstractSubstituteToscaEnricher toscaEnricher; - String vspId = null; - Version version = new Version(); + private String vspId = null; + private Version version = new Version(); @Before public void injectDoubles() { @@ -83,9 +83,9 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest when(utilMock.getPropertiesfromCompQuestionnaire(vspId,version)).thenReturn (componentTypetoParams); - Map<String,String> map = new HashMap<String,String>(); - Map<String, List<String>> sourceToTargetDependencies = new HashMap<String, List<String>>(); - List<String> targets = new ArrayList<String>(); + Map<String,String> map = new HashMap<>(); + Map<String, List<String>> sourceToTargetDependencies = new HashMap<>(); + List<String> targets = new ArrayList<>(); targets.add("fe"); targets.add("be"); sourceToTargetDependencies.put("pd_server", targets); @@ -110,8 +110,8 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest "/mock/toscaGlobalServiceTemplates/", "MainServiceTemplate.yaml"); - Map<String, Map<String, Object>> componentTypetoParams = new HashMap(); - Map<String, Object> innerProps = new HashedMap(); + Map<String, Map<String, Object>> componentTypetoParams = new HashMap<>(); + Map<String, Object> innerProps = new HashMap<>(); innerProps.put(MANDATORY, "NO"); innerProps.put(HIGH_AVAIL_MODE, ""); innerProps.put(NFC_NAMING_CODE, "pd_server_code1"); @@ -125,8 +125,8 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest when(utilMock.getPropertiesfromCompQuestionnaire(vspId,version)).thenReturn (componentTypetoParams); - Map<String,String> map = new HashMap<String,String>(); - Map<String, List<String>> sourceToTargetDependencies = new HashMap<String, List<String>>(); + Map<String,String> map = new HashMap<>(); + Map<String, List<String>> sourceToTargetDependencies = new HashMap<>(); when(utilMock.getSourceToTargetComponent()).thenReturn(map); when(utilMock.populateDependencies(vspId,version,map)).thenReturn(sourceToTargetDependencies); @@ -148,23 +148,23 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest "/mock/toscaGlobalServiceTemplates/", "MainServiceTemplate.yaml"); - Map<String, Map<String, Object>> componentTypetoParams = new HashMap(); - Map<String, Object> innerProps = new HashedMap(); + Map<String, Map<String, Object>> componentTypetoParams = new HashMap<>(); + Map<String, Object> innerProps = new HashMap<>(); innerProps.put(MANDATORY, ""); innerProps.put(MIN_INSTANCES, 1); innerProps.put(MAX_INSTANCES, 5); - componentTypetoParams.put("pd_server_vm", innerProps); + componentTypetoParams.put("pd_server", innerProps); when(utilMock.getPropertiesfromCompQuestionnaire(vspId,version)).thenReturn (componentTypetoParams); - Map<String,String> map = new HashMap<String,String>(); - Map<String, List<String>> sourceToTargetDependencies = new HashMap<String, List<String>>(); - List<String> targets = new ArrayList<String>(); + Map<String,String> map = new HashMap<>(); + Map<String, List<String>> sourceToTargetDependencies = new HashMap<>(); + List<String> targets = new ArrayList<>(); targets.add("fe"); - sourceToTargetDependencies.put("pd_server_vm", targets); + sourceToTargetDependencies.put("pd_server", targets); when(utilMock.getSourceToTargetComponent()).thenReturn(map); @@ -233,4 +233,41 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest Assert.assertEquals(errors.size(), 0); } + + @Test + public void testEnrichComponentSameVmTypeNfcNamingFunction() throws Exception { + outputFilesPath = "/mock/enrichNfcNamingFunction/out"; + ToscaServiceModel toscaServiceModel = + loadToscaServiceModel("/mock/enrichNfcNamingFunction/in", + "/mock/toscaGlobalServiceTemplates/", + "MainServiceTemplate.yaml"); + + Map<String, Map<String, Object>> componentTypetoParams = new HashMap<>(); + Map<String, Object> innerProps = new HashMap<>(); + innerProps.put(MANDATORY, "NO"); + innerProps.put(HIGH_AVAIL_MODE, ""); + innerProps.put(NFC_NAMING_CODE, "cfed_changed_from_ui"); + innerProps.put(VFC_CODE, "pd_server_code"); + innerProps.put(NFC_FUNCTION, "cfed_naming_function"); + innerProps.put(MIN_INSTANCES, null); + innerProps.put(MAX_INSTANCES, null); + + componentTypetoParams.put("cfed", innerProps); + + when(utilMock.getPropertiesfromCompQuestionnaire(vspId,version)).thenReturn + (componentTypetoParams); + + Map<String,String> map = new HashMap<>(); + Map<String, List<String>> sourceToTargetDependencies = new HashMap<>(); + + when(utilMock.getSourceToTargetComponent()).thenReturn(map); + when(utilMock.populateDependencies(vspId,version,map)).thenReturn(sourceToTargetDependencies); + + Map<String, List<ErrorMessage>> errors = + toscaEnricher.enrich(toscaServiceModel, vspId, version ); + + compareActualAndExpectedModel(toscaServiceModel); + + Assert.assertEquals(errors.size(), 0); + } } |