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