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.asdctool;
23 import org.janusgraph.core.JanusGraph;
24 import org.apache.commons.configuration.Configuration;
25 import org.apache.tinkerpop.gremlin.structure.Element;
26 import org.junit.Assert;
27 import org.junit.Test;
29 import javax.ws.rs.core.Response;
30 import java.util.HashMap;
33 public class UtilsTest {
36 public void testBuildOkResponse() throws Exception {
39 Map<String, String> additionalHeaders = null;
42 // test with mock entity
43 Object mockEntity = new Object();
44 result = Utils.buildOkResponse(status, entity, additionalHeaders);
45 Assert.assertNotNull(result);
47 // test with mock headers
48 Map<String, String> mockAdditionalHeaders = new HashMap<>();
49 mockAdditionalHeaders.put("stam", "stam");
50 result = Utils.buildOkResponse(status, mockEntity, mockAdditionalHeaders);
51 Assert.assertNotNull(result);
55 public void testOpenGraph() throws Exception {
56 Configuration conf = null;
59 // default test with null
60 result = Utils.openGraph(conf);
64 public void testVertexLeftContainsRightProps() throws Exception {
65 Map<String, Object> leftProps = new HashMap<>();
66 Map<String, Object> rightProps = null;
71 result = Utils.vertexLeftContainsRightProps(leftProps, rightProps);
72 Assert.assertEquals(true, result);
75 Map<String, Object> mockLeftProps = new HashMap<>();
76 mockLeftProps.put("stam", new Object());
77 Map<String, Object> mockRightProps = new HashMap<>();
78 mockRightProps.put("stam", new Object());
79 result = Utils.vertexLeftContainsRightProps(mockLeftProps, mockRightProps);
80 Assert.assertEquals(false, result);
83 Object mockObject = new Object();
84 mockLeftProps = new HashMap<>();
85 mockLeftProps.put("stam", mockObject);
86 mockRightProps = new HashMap<>();
87 mockRightProps.put("stam", mockObject);
88 result = Utils.vertexLeftContainsRightProps(mockLeftProps, mockRightProps);
89 Assert.assertEquals(true, result);
92 @Test(expected=IllegalArgumentException.class)
93 public void testSetProperties() throws Exception {
94 Element element = null;
95 Map<String, Object> properties = null;
99 Utils.setProperties(element, properties);
102 properties = new HashMap<>();
103 properties.put("stam", new Object());
104 Utils.setProperties(element, properties);
107 @Test(expected=NullPointerException.class)
108 public void testGetProperties() throws Exception {
109 Element element = null;
110 Map<String, Object> result;
113 result = Utils.getProperties(element);