1 package org.openecomp.sdc.asdctool;
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;
9 import javax.ws.rs.core.Response;
10 import java.util.HashMap;
13 public class UtilsTest {
16 public void testBuildOkResponse() throws Exception {
19 Map<String, String> additionalHeaders = null;
22 // test with mock entity
23 Object mockEntity = new Object();
24 result = Utils.buildOkResponse(status, entity, additionalHeaders);
25 Assert.assertNotNull(result);
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);
35 public void testOpenGraph() throws Exception {
36 Configuration conf = null;
39 // default test with null
40 result = Utils.openGraph(conf);
44 public void testVertexLeftContainsRightProps() throws Exception {
45 Map<String, Object> leftProps = new HashMap<>();
46 Map<String, Object> rightProps = null;
51 result = Utils.vertexLeftContainsRightProps(leftProps, rightProps);
52 Assert.assertEquals(true, result);
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);
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);
72 @Test(expected=IllegalArgumentException.class)
73 public void testSetProperties() throws Exception {
74 Element element = null;
75 Map<String, Object> properties = null;
79 Utils.setProperties(element, properties);
82 properties = new HashMap<>();
83 properties.put("stam", new Object());
84 Utils.setProperties(element, properties);
87 @Test(expected=NullPointerException.class)
88 public void testGetProperties() throws Exception {
89 Element element = null;
90 Map<String, Object> result;
93 result = Utils.getProperties(element);