Added oparent to sdc main
[sdc.git] / catalog-dao / src / test / java / org / openecomp / sdc / be / dao / graph / GraphElementFactoryTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.dao.graph;
22
23 import mockit.Deencapsulation;
24 import org.junit.Test;
25 import org.mockito.Mockito;
26 import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
27 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
28 import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
29 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
30
31 import java.util.HashMap;
32 import java.util.Map;
33
34 public class GraphElementFactoryTest {
35
36         @Test
37         public void testCreateElement() throws Exception {
38                 String label = "mock";
39                 Map<String, Object> properties = new HashMap<>();
40                 Class<GraphNode> clazz = (Class<GraphNode>) (Mockito.mock(GraphNode.class)).getClass();
41
42                 // default test
43                 GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
44         }
45
46         @Test
47         public void testCreateElement_1() throws Exception {
48                 String label = "mock";
49                 GraphElementTypeEnum type = null;
50                 Map<String, Object> properties = new HashMap<>();
51                 GraphNode result;
52
53                 // default test
54                 result = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties);
55         }
56
57         @Test
58         public void testCreateRelation() throws Exception {
59                 String type = "";
60                 Map<String, Object> properties = new HashMap<>();
61                 GraphNode from = Mockito.mock(GraphNode.class);
62                 GraphNode to = Mockito.mock(GraphNode.class);
63                 ;
64                 GraphRelation result;
65
66                 // default test
67                 result = GraphElementFactory.createRelation(type, properties, from, to);
68         }
69
70         @Test
71         public void testCreateNode() throws Exception {
72                 Map<String, Object> properties = new HashMap<>();
73                 GraphNode result;
74
75                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.User.getName(),
76                                 properties);
77                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
78                                 NodeTypeEnum.ResourceCategory.getName(), properties);
79                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.ServiceCategory.getName(),
80                                 properties);
81                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Tag.getName(),
82                                 properties);
83                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Service.getName(),
84                                 properties);
85                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Property.getName(),
86                                 properties);
87                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.HeatParameter.getName(),
88                                 properties);
89                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
90                                 NodeTypeEnum.HeatParameterValue.getName(), properties);
91         }
92 }