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.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;
35 import java.util.HashMap;
38 public class GraphElementFactoryTest {
40 private static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
41 "src/test/resources/config/catalog-dao");
42 private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
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();
51 GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
55 public void testCreateElement_1() throws Exception {
56 String label = "mock";
57 GraphElementTypeEnum type = null;
58 Map<String, Object> properties = new HashMap<>();
62 result = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties);
66 public void testCreateRelation() throws Exception {
68 Map<String, Object> properties = new HashMap<>();
69 GraphNode from = Mockito.mock(GraphNode.class);
70 GraphNode to = Mockito.mock(GraphNode.class);
75 result = GraphElementFactory.createRelation(type, properties, from, to);
79 public void testCreateNode() throws Exception {
80 Map<String, Object> properties = new HashMap<>();
83 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.User.getName(),
85 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
86 NodeTypeEnum.ResourceCategory.getName(), properties);
87 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.ServiceCategory.getName(),
89 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Tag.getName(),
91 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Service.getName(),
93 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Property.getName(),
95 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.HeatParameter.getName(),
97 result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
98 NodeTypeEnum.HeatParameterValue.getName(), properties);