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.jsongraph;
23 import org.janusgraph.core.JanusGraphVertex;
24 import org.junit.Test;
25 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
26 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
27 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
28 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
29 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
31 import java.util.HashMap;
35 public class GraphVertexTest {
37 private GraphVertex createTestSubject() {
38 return new GraphVertex();
42 public void testCtor() throws Exception {
43 new GraphVertex(VertexTypeEnum.ADDITIONAL_INFORMATION);
47 public void testGetUniqueId() throws Exception {
48 GraphVertex testSubject;
52 testSubject = createTestSubject();
53 result = testSubject.getUniqueId();
58 public void testSetUniqueId() throws Exception {
59 GraphVertex testSubject;
63 testSubject = createTestSubject();
64 testSubject.setUniqueId(uniqueId);
69 public void testGetJson() throws Exception {
70 GraphVertex testSubject;
71 Map<String, ? extends ToscaDataDefinition> result;
74 testSubject = createTestSubject();
75 result = testSubject.getJson();
80 public void testSetJson() throws Exception {
81 GraphVertex testSubject;
82 Map<String, ? extends ToscaDataDefinition> json = null;
85 testSubject = createTestSubject();
86 testSubject.setJson(json);
91 public void testGetVertex() throws Exception {
92 GraphVertex testSubject;
93 JanusGraphVertex result;
96 testSubject = createTestSubject();
97 result = testSubject.getVertex();
102 public void testSetVertex() throws Exception {
103 GraphVertex testSubject;
104 JanusGraphVertex vertex = null;
107 testSubject = createTestSubject();
108 testSubject.setVertex(vertex);
113 public void testGetLabel() throws Exception {
114 GraphVertex testSubject;
115 VertexTypeEnum result;
118 testSubject = createTestSubject();
119 result = testSubject.getLabel();
124 public void testSetLabel() throws Exception {
125 GraphVertex testSubject;
126 VertexTypeEnum label = null;
129 testSubject = createTestSubject();
130 testSubject.setLabel(label);
136 public void testAddMetadataProperty() throws Exception {
137 GraphVertex testSubject;
138 GraphPropertyEnum propName = null;
139 Object propValue = null;
142 testSubject = createTestSubject();
144 testSubject.addMetadataProperty(propName, propValue);
149 public void testGetMetadataProperty() throws Exception {
150 GraphVertex testSubject;
151 GraphPropertyEnum metadataProperty = null;
155 testSubject = createTestSubject();
156 result = testSubject.getMetadataProperty(metadataProperty);
161 public void testGetMetadataProperties() throws Exception {
162 GraphVertex testSubject;
163 Map<GraphPropertyEnum, Object> result;
166 testSubject = createTestSubject();
167 result = testSubject.getMetadataProperties();
172 public void testSetMetadataProperties() throws Exception {
173 GraphVertex testSubject;
174 Map<GraphPropertyEnum, Object> metadataProperties = null;
177 testSubject = createTestSubject();
178 testSubject.setMetadataProperties(metadataProperties);
183 public void testGetMetadataJson() throws Exception {
184 GraphVertex testSubject;
185 Map<String, Object> result;
188 testSubject = createTestSubject();
189 result = testSubject.getMetadataJson();
194 public void testSetMetadataJson() throws Exception {
195 GraphVertex testSubject;
196 Map<String, Object> metadataJson = null;
199 testSubject = createTestSubject();
200 testSubject.setMetadataJson(metadataJson);
207 public void testGetJsonMetadataField() throws Exception {
208 GraphVertex testSubject;
212 testSubject = createTestSubject();
213 result = testSubject.getJsonMetadataField(JsonPresentationFields.API_URL);
214 testSubject = createTestSubject();
215 testSubject.setType(ComponentTypeEnum.RESOURCE);
216 result = testSubject.getJsonMetadataField(JsonPresentationFields.API_URL);
221 public void testUpdateMetadataJsonWithCurrentMetadataProperties() throws Exception {
222 GraphVertex testSubject;
225 testSubject = createTestSubject();
226 testSubject.updateMetadataJsonWithCurrentMetadataProperties();
227 Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
228 metadataProperties.put(GraphPropertyEnum.COMPONENT_TYPE, "mock");
229 testSubject.setMetadataProperties(metadataProperties );
230 testSubject.updateMetadataJsonWithCurrentMetadataProperties();
234 public void testGetType() throws Exception {
235 GraphVertex testSubject;
238 testSubject = createTestSubject();
239 testSubject.setType(ComponentTypeEnum.RESOURCE);
240 testSubject.getType();
244 public void testCloneData() throws Exception {
245 GraphVertex testSubject;
248 testSubject = createTestSubject();
249 testSubject.cloneData(new GraphVertex());
253 public void testSetJsonMetadataField() throws Exception {
254 GraphVertex testSubject;
257 testSubject = createTestSubject();
258 testSubject.setJsonMetadataField(JsonPresentationFields.API_URL, "mock");