aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/test/java
diff options
context:
space:
mode:
authorSindhuri.A <arcot.sindhuri@huawei.com>2018-10-16 19:34:41 +0530
committerMichael Lando <michael.lando@intl.att.com>2018-10-17 06:38:34 +0000
commitce0558f2df8e85f3f10df1676bb06bf3b68e683f (patch)
tree2ef2e559c89c064c6d77624b992f355c0b4ff744 /asdctool/src/test/java
parent56309f422c7dd81ceb6ea8f116aa30c23f97ca46 (diff)
UT-asdctool ModuleJsonTask
UT for asdctool impl validator ModuleJsonTask class Issue-ID: SDC-1775 Change-Id: Ia160c4b2b64313bd11927aaa45bf887ed3df96df Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'asdctool/src/test/java')
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java73
1 files changed, 60 insertions, 13 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
index 5a55742eab..5799b6d03d 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
@@ -1,23 +1,70 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.moduleJson;
+import fj.data.Either;
import org.junit.Test;
-import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
+import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
public class ModuleJsonTaskTest {
- private ModuleJsonTask createTestSubject() {
- return new ModuleJsonTask();
- }
+ @InjectMocks
+ private ModuleJsonTask test;
+ @Mock
+ private TopologyTemplateOperation topologyTemplateOperation;
+
+ @Test
+ public void testValidate() {
+ GraphVertex vertex = new GraphVertex();
+ vertex.setUniqueId("uniqueId");
+ Map<GraphPropertyEnum, Object> hasProps1 = new HashMap<>();
+ hasProps1.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ vertex.setMetadataProperties(hasProps1);
+
+ Map<String, ArtifactDataDefinition> mapDataDefinition = new HashMap<>();
+ ArtifactDataDefinition artifactDataDefinition = new ArtifactDataDefinition();
+ artifactDataDefinition.setArtifactName("one_modules.json");
+ mapDataDefinition.put("one", artifactDataDefinition);
+ MapGroupsDataDefinition mapGroupsDataDefinition = new MapGroupsDataDefinition();
+ Map<String, GroupInstanceDataDefinition> mapToscaDataDefinition = new HashMap<>();
+ mapToscaDataDefinition.put("one", new GroupInstanceDataDefinition());
+ mapGroupsDataDefinition.setMapToscaDataDefinition(mapToscaDataDefinition);
+
+ Map<String, MapGroupsDataDefinition> instGroups = new HashMap<>();
+ instGroups.put("one", mapGroupsDataDefinition);
+
+ Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = new HashMap<>();
+ MapArtifactDataDefinition mapArtifactDataDefinition = new MapArtifactDataDefinition();
+
+ mapArtifactDataDefinition.setMapToscaDataDefinition(mapDataDefinition);
+ instDeploymentArtifacts.put("one", mapArtifactDataDefinition);
- @Test(expected=NullPointerException.class)
- public void testValidate() throws Exception {
- ModuleJsonTask testSubject;
- GraphVertex vertex = null;
- VertexResult result;
+ TopologyTemplate topologyTemplate = new TopologyTemplate();
+ topologyTemplate.setInstGroups(instGroups);
+ topologyTemplate.setInstDeploymentArtifacts(instDeploymentArtifacts);
+ when(topologyTemplateOperation.getToscaElement(ArgumentMatchers.eq(vertex.getUniqueId()), ArgumentMatchers.any(ComponentParametersView.class))).thenReturn(Either.left(topologyTemplate));
+ try {
+ test.validate(vertex);
+ } catch (Exception e) {
- // default test
- testSubject = createTestSubject();
- result = testSubject.validate(vertex);
- }
+ }
+ }
} \ No newline at end of file