summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java
diff options
context:
space:
mode:
authorojasdubey <ojas.dubey@amdocs.com>2018-03-29 11:41:55 +0530
committerOren Kleks <orenkle@amdocs.com>2018-03-29 11:55:39 +0000
commita26e2683d10fdd4484d67bb8b7d6a2e0a41ab753 (patch)
tree3ab830c719cfe867ce1028da75e8c1566ea69898 /openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java
parent589c480ce6c51e92f8e22ae9c0d4548067a37948 (diff)
Component Dependency create VF bug fix
1. Fixed create VF issues for scenarios where dependencies were added from the UI 2. Added supporting tests and fixed existing Change-Id: Ib8bb0074183567c263855f8723028646c9629038 Issue-ID: SDC-1184 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.java71
1 files changed, 62 insertions, 9 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 ca116a9ae3..11cab5f0a5 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
@@ -1,6 +1,15 @@
package org.openecomp.sdc.enrichment.impl.tosca;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE;
+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_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 org.apache.commons.collections.map.HashedMap;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -17,15 +26,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE;
-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_CODE;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_FUNCTION;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE;
-
public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest {
@Mock
@@ -165,4 +165,57 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest
Assert.assertEquals(errors.size(), 0);
}
+
+ @Test
+ public void testEnrichComponentAddDependencies() throws Exception {
+ outputFilesPath = "/mock/enrichComponentAddDependencies/out";
+ ToscaServiceModel toscaServiceModel =
+ loadToscaServiceModel("/mock/enrichComponentAddDependencies/in",
+ "/mock/toscaGlobalServiceTemplates/",
+ "MainServiceTemplate.yaml");
+
+ Map<String,String> map = new HashMap<>();
+ Map<String, List<String>> sourceToTargetDependencies = new HashMap<>();
+ List<String> targets = new ArrayList<>();
+ targets.add("ps_server");
+ sourceToTargetDependencies.put("pd_server", targets);
+
+ when(utilMock.getSourceToTargetComponent()).thenReturn(map);
+
+ when(utilMock.populateDependencies(vspId,version,map)).thenReturn(sourceToTargetDependencies);
+ 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);
+ }
+
+ @Test
+ public void testEnrichComponentNoDependencies() throws Exception {
+ outputFilesPath = "/mock/enrichComponentNoDependencies/out";
+ ToscaServiceModel toscaServiceModel =
+ loadToscaServiceModel("/mock/enrichComponentNoDependencies/in",
+ "/mock/toscaGlobalServiceTemplates/",
+ "MainServiceTemplate.yaml");
+
+ 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);
+ 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);
+ }
}