1 package org.openecomp.sdc.asdctool;
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;
9 import javax.ws.rs.core.Response;
10 import java.util.HashMap;
13 public class UtilsTest {
16 * private Utils createTestSubject() { return new Utils(); }
20 public void testBuildOkResponse() throws Exception {
23 Map<String, String> additionalHeaders = null;
26 // test with mock entity
27 Object mockEntity = new Object();
28 result = Utils.buildOkResponse(status, entity, additionalHeaders);
29 Assert.assertNotNull(result);
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);
39 public void testOpenGraph() throws Exception {
40 Configuration conf = null;
43 // default test with null
44 result = Utils.openGraph(conf);
48 public void testVertexLeftContainsRightProps() throws Exception {
49 Map<String, Object> leftProps = new HashMap<>();
50 Map<String, Object> rightProps = null;
55 result = Utils.vertexLeftContainsRightProps(leftProps, rightProps);
56 Assert.assertEquals(true, result);
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);
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);
76 @Test(expected=IllegalArgumentException.class)
77 public void testSetProperties() throws Exception {
78 Element element = null;
79 Map<String, Object> properties = null;
83 Utils.setProperties(element, properties);
86 properties = new HashMap<>();
87 properties.put("stam", new Object());
88 Utils.setProperties(element, properties);
91 @Test(expected=NullPointerException.class)
92 public void testGetProperties() throws Exception {
93 Element element = null;
94 Map<String, Object> result;
97 result = Utils.getProperties(element);