2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.dao.graph;
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;
31 import java.util.HashMap;
34 public class GraphElementFactoryTest {
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();
43 GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
47 public void testCreateElement_1() throws Exception {
48 String label = "mock";
49 GraphElementTypeEnum type = null;
50 Map<String, Object> properties = new HashMap<>();
54 result = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties);
58 public void testCreateRelation() throws Exception {
60 Map<String, Object> properties = new HashMap<>();
61 GraphNode from = Mockito.mock(GraphNode.class);
62 GraphNode to = Mockito.mock(GraphNode.class);
67 result = GraphElementFactory.createRelation(type, properties, from, to);
71 public void testCreateNode() throws Exception {
72 Map<String, Object> properties = new HashMap<>();
75 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.User.getName(),
77 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
78 NodeTypeEnum.ResourceCategory.getName(), properties);
79 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.ServiceCategory.getName(),
81 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Tag.getName(),
83 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Service.getName(),
85 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Property.getName(),
87 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.HeatParameter.getName(),
89 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
90 NodeTypeEnum.HeatParameterValue.getName(), properties);