Upgrade SDC from Titan to Janus Graph
[sdc.git] / asdctool / src / test / java / org / openecomp / sdc / asdctool / UtilsTest.java
1 package org.openecomp.sdc.asdctool;
2
3 import org.janusgraph.core.JanusGraph;
4 import org.apache.commons.configuration.Configuration;
5 import org.apache.tinkerpop.gremlin.structure.Element;
6 import org.junit.Assert;
7 import org.junit.Test;
8
9 import javax.ws.rs.core.Response;
10 import java.util.HashMap;
11 import java.util.Map;
12
13 public class UtilsTest {
14
15         @Test
16         public void testBuildOkResponse() throws Exception {
17                 int status = 0;
18                 Object entity = null;
19                 Map<String, String> additionalHeaders = null;
20                 Response result;
21
22                 // test with mock entity
23                 Object mockEntity = new Object();
24                 result = Utils.buildOkResponse(status, entity, additionalHeaders);
25                 Assert.assertNotNull(result);
26
27                 // test with mock headers
28                 Map<String, String> mockAdditionalHeaders = new HashMap<>();
29                 mockAdditionalHeaders.put("stam", "stam");
30                 result = Utils.buildOkResponse(status, mockEntity, mockAdditionalHeaders);
31                 Assert.assertNotNull(result);
32         }
33
34         @Test
35         public void testOpenGraph() throws Exception {
36                 Configuration conf = null;
37                 JanusGraph result;
38
39                 // default test with null
40                 result = Utils.openGraph(conf);
41         }
42
43         @Test
44         public void testVertexLeftContainsRightProps() throws Exception {
45                 Map<String, Object> leftProps = new HashMap<>();
46                 Map<String, Object> rightProps = null;
47                 boolean result;
48
49                 // test 1 with null
50                 rightProps = null;
51                 result = Utils.vertexLeftContainsRightProps(leftProps, rightProps);
52                 Assert.assertEquals(true, result);
53
54                 // test 2 with mocks
55                 Map<String, Object> mockLeftProps = new HashMap<>();
56                 mockLeftProps.put("stam", new Object());
57                 Map<String, Object> mockRightProps = new HashMap<>();
58                 mockRightProps.put("stam", new Object());
59                 result = Utils.vertexLeftContainsRightProps(mockLeftProps, mockRightProps);
60                 Assert.assertEquals(false, result);
61
62                 // test 3 with mocks
63                 Object mockObject = new Object();
64                 mockLeftProps = new HashMap<>();
65                 mockLeftProps.put("stam", mockObject);
66                 mockRightProps = new HashMap<>();
67                 mockRightProps.put("stam", mockObject);
68                 result = Utils.vertexLeftContainsRightProps(mockLeftProps, mockRightProps);
69                 Assert.assertEquals(true, result);
70         }
71
72         @Test(expected=IllegalArgumentException.class)
73         public void testSetProperties() throws Exception {
74                 Element element = null;
75                 Map<String, Object> properties = null;
76
77                 // test 1
78                 properties = null;
79                 Utils.setProperties(element, properties);
80                 
81                 // test 2
82                 properties = new HashMap<>();
83                 properties.put("stam", new Object());
84                 Utils.setProperties(element, properties);
85         }
86
87         @Test(expected=NullPointerException.class)
88         public void testGetProperties() throws Exception {
89                 Element element = null;
90                 Map<String, Object> result;
91
92                 // default test
93                 result = Utils.getProperties(element);
94         }
95 }