Catalog alignment
[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.config.ConfigurationManager;
27 import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
28 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
29 import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
30 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
31 import org.openecomp.sdc.common.api.ConfigurationSource;
32 import org.openecomp.sdc.common.impl.ExternalConfiguration;
33 import org.openecomp.sdc.common.impl.FSConfigurationSource;
34
35 import java.util.HashMap;
36 import java.util.Map;
37
38 public class GraphElementFactoryTest {
39
40         private static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
41                         "src/test/resources/config/catalog-dao");
42         private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
43
44         @Test
45         public void testCreateElement() throws Exception {
46                 String label = "mock";
47                 Map<String, Object> properties = new HashMap<>();
48                 Class<GraphNode> clazz = (Class<GraphNode>) (Mockito.mock(GraphNode.class)).getClass();
49
50                 // default test
51                 GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
52         }
53
54         @Test
55         public void testCreateElement_1() throws Exception {
56                 String label = "mock";
57                 GraphElementTypeEnum type = null;
58                 Map<String, Object> properties = new HashMap<>();
59                 GraphNode result;
60
61                 // default test
62                 result = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties);
63         }
64
65         @Test
66         public void testCreateRelation() throws Exception {
67                 String type = "";
68                 Map<String, Object> properties = new HashMap<>();
69                 GraphNode from = Mockito.mock(GraphNode.class);
70                 GraphNode to = Mockito.mock(GraphNode.class);
71                 ;
72                 GraphRelation result;
73
74                 // default test
75                 result = GraphElementFactory.createRelation(type, properties, from, to);
76         }
77
78         @Test
79         public void testCreateNode() throws Exception {
80                 Map<String, Object> properties = new HashMap<>();
81                 GraphNode result;
82
83                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.User.getName(),
84                                 properties);
85                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
86                                 NodeTypeEnum.ResourceCategory.getName(), properties);
87                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.ServiceCategory.getName(),
88                                 properties);
89                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Tag.getName(),
90                                 properties);
91                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Service.getName(),
92                                 properties);
93                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Property.getName(),
94                                 properties);
95                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.HeatParameter.getName(),
96                                 properties);
97                 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
98                                 NodeTypeEnum.HeatParameterValue.getName(), properties);
99         }
100 }