1 package org.openecomp.sdc.asdctool;
3 import java.util.HashMap;
6 import javax.ws.rs.core.Response;
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;
13 import com.thinkaurelius.titan.core.TitanGraph;
15 public class UtilsTest {
18 * private Utils createTestSubject() { return new Utils(); }
22 public void testBuildOkResponse() throws Exception {
25 Map<String, String> additionalHeaders = null;
28 // test with mock entity
29 Object mockEntity = new Object();
30 result = Utils.buildOkResponse(status, entity, additionalHeaders);
31 Assert.assertNotNull(result);
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);
41 public void testOpenGraph() throws Exception {
42 Configuration conf = null;
45 // default test with null
46 result = Utils.openGraph(conf);
50 public void testVertexLeftContainsRightProps() throws Exception {
51 Map<String, Object> leftProps = new HashMap<>();
52 Map<String, Object> rightProps = null;
57 result = Utils.vertexLeftContainsRightProps(leftProps, rightProps);
58 Assert.assertEquals(true, result);
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);
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);
78 @Test(expected=IllegalArgumentException.class)
79 public void testSetProperties() throws Exception {
80 Element element = null;
81 Map<String, Object> properties = null;
85 Utils.setProperties(element, properties);
88 properties = new HashMap<>();
89 properties.put("stam", new Object());
90 Utils.setProperties(element, properties);
93 @Test(expected=NullPointerException.class)
94 public void testGetProperties() throws Exception {
95 Element element = null;
96 Map<String, Object> result;
99 result = Utils.getProperties(element);