summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java')
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java128
1 files changed, 64 insertions, 64 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java
index 931186d336..4156c41ce1 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,81 +20,81 @@
package org.openecomp.sdc.be.dao.graph;
-import mockit.Deencapsulation;
-import org.junit.Test;
+import static org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum.AnnotationType;
+import static org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum.Component;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
+import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import java.util.HashMap;
-import java.util.Map;
-
-public class GraphElementFactoryTest {
-
- private static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
- "src/test/resources/config/catalog-dao");
- private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
-
- @Test
- public void testCreateElement() throws Exception {
- String label = "mock";
- Map<String, Object> properties = new HashMap<>();
- Class<GraphNode> clazz = (Class<GraphNode>) (Mockito.mock(GraphNode.class)).getClass();
-
- // default test
- GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
- }
-
- @Test
- public void testCreateElement_1() throws Exception {
- String label = "mock";
- GraphElementTypeEnum type = null;
- Map<String, Object> properties = new HashMap<>();
- GraphNode result;
+class GraphElementFactoryTest {
- // default test
- result = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties);
- }
+ private static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+ "src/test/resources/config/catalog-dao");
+ private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
- @Test
- public void testCreateRelation() throws Exception {
- String type = "";
- Map<String, Object> properties = new HashMap<>();
- GraphNode from = Mockito.mock(GraphNode.class);
- GraphNode to = Mockito.mock(GraphNode.class);
- ;
- GraphRelation result;
+ @Test
+ void testCreateElement() throws Exception {
+ Map<String, Object> properties = new HashMap<>();
+ Arrays.stream(NodeTypeEnum.values()).filter(nodeTypeEnum -> !nodeTypeEnum.equals(AnnotationType) && !nodeTypeEnum.equals(Component))
+ .forEach(nodeTypeEnum -> {
+ Assertions.assertTrue(GraphElementFactory
+ .createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, GraphNode.class) instanceof GraphNode);
+ });
+ Assertions.assertNull(GraphElementFactory.createElement(Component.getName(), GraphElementTypeEnum.Node, properties, GraphNode.class));
+ Assertions.assertThrows(NullPointerException.class,
+ () -> GraphElementFactory.createElement(AnnotationType.getName(), GraphElementTypeEnum.Node, properties, GraphNode.class));
+ }
- // default test
- result = GraphElementFactory.createRelation(type, properties, from, to);
- }
+ @Test
+ void testCreateRelation() throws Exception {
+ GraphRelation result = GraphElementFactory.createRelation("", new HashMap<>(), Mockito.mock(GraphNode.class), Mockito.mock(GraphNode.class));
+ Assertions.assertTrue(result instanceof GraphRelation);
+ Assertions.assertTrue(result.getFrom() instanceof RelationEndPoint);
+ Assertions.assertTrue(result.getTo() instanceof RelationEndPoint);
+ }
- @Test
- public void testCreateNode() throws Exception {
- Map<String, Object> properties = new HashMap<>();
- GraphNode result;
+ @Test
+ void testCreateNode() throws Exception {
+ Map<String, Object> properties = new HashMap<>();
+ GraphNode result;
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.User.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
- NodeTypeEnum.ResourceCategory.getName(), properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.ServiceCategory.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Tag.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Service.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Property.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.HeatParameter.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
- NodeTypeEnum.HeatParameterValue.getName(), properties);
- }
+ result = GraphElementFactory.createElement(NodeTypeEnum.User.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.ResourceCategory.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.ServiceCategory.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Tag.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertTrue(result instanceof GraphNode);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Service.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Property.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Resource.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertTrue(result instanceof GraphNode);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.HeatParameter.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.HeatParameterValue.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ }
}