re base code
[sdc.git] / asdctool / src / test / java / org / openecomp / sdc / asdctool / UtilsTest.java
1 package org.openecomp.sdc.asdctool;
2
3 import com.thinkaurelius.titan.core.TitanGraph;
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         /*
16          * private Utils createTestSubject() { return new Utils(); }
17          */
18
19         @Test
20         public void testBuildOkResponse() throws Exception {
21                 int status = 0;
22                 Object entity = null;
23                 Map<String, String> additionalHeaders = null;
24                 Response result;
25
26                 // test with mock entity
27                 Object mockEntity = new Object();
28                 result = Utils.buildOkResponse(status, entity, additionalHeaders);
29                 Assert.assertNotNull(result);
30
31                 // test with mock headers
32                 Map<String, String> mockAdditionalHeaders = new HashMap<>();
33                 mockAdditionalHeaders.put("stam", "stam");
34                 result = Utils.buildOkResponse(status, mockEntity, mockAdditionalHeaders);
35                 Assert.assertNotNull(result);
36         }
37
38         @Test
39         public void testOpenGraph() throws Exception {
40                 Configuration conf = null;
41                 TitanGraph result;
42
43                 // default test with null
44                 result = Utils.openGraph(conf);
45         }
46
47         @Test
48         public void testVertexLeftContainsRightProps() throws Exception {
49                 Map<String, Object> leftProps = new HashMap<>();
50                 Map<String, Object> rightProps = null;
51                 boolean result;
52
53                 // test 1 with null
54                 rightProps = null;
55                 result = Utils.vertexLeftContainsRightProps(leftProps, rightProps);
56                 Assert.assertEquals(true, result);
57
58                 // test 2 with mocks
59                 Map<String, Object> mockLeftProps = new HashMap<>();
60                 mockLeftProps.put("stam", new Object());
61                 Map<String, Object> mockRightProps = new HashMap<>();
62                 mockRightProps.put("stam", new Object());
63                 result = Utils.vertexLeftContainsRightProps(mockLeftProps, mockRightProps);
64                 Assert.assertEquals(false, result);
65
66                 // test 3 with mocks
67                 Object mockObject = new Object();
68                 mockLeftProps = new HashMap<>();
69                 mockLeftProps.put("stam", mockObject);
70                 mockRightProps = new HashMap<>();
71                 mockRightProps.put("stam", mockObject);
72                 result = Utils.vertexLeftContainsRightProps(mockLeftProps, mockRightProps);
73                 Assert.assertEquals(true, result);
74         }
75
76         @Test(expected=IllegalArgumentException.class)
77         public void testSetProperties() throws Exception {
78                 Element element = null;
79                 Map<String, Object> properties = null;
80
81                 // test 1
82                 properties = null;
83                 Utils.setProperties(element, properties);
84                 
85                 // test 2
86                 properties = new HashMap<>();
87                 properties.put("stam", new Object());
88                 Utils.setProperties(element, properties);
89         }
90
91         @Test(expected=NullPointerException.class)
92         public void testGetProperties() throws Exception {
93                 Element element = null;
94                 Map<String, Object> result;
95
96                 // default test
97                 result = Utils.getProperties(element);
98         }
99 }