new unit tests for sdc-dao
[sdc.git] / catalog-dao / src / test / java / org / openecomp / sdc / be / dao / utils / DaoUtilsTest.java
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/DaoUtilsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/DaoUtilsTest.java
new file mode 100644 (file)
index 0000000..06437ad
--- /dev/null
@@ -0,0 +1,43 @@
+package org.openecomp.sdc.be.dao.utils;
+
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DaoUtilsTest {
+
+       @Test
+       public void testConvertToJson() throws Exception {
+               Object object = new Object();
+               String result;
+
+               // test 1
+               result = DaoUtils.convertToJson(object);
+               Assert.assertEquals("{}", result);
+               
+               try {
+                       result = DaoUtils.convertToJson(null);
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+       }
+
+       @Test
+       public void testConvertFromJson() throws Exception {
+               Class clazz = Object.class;
+               String json = null;
+               Object result;
+
+               // default test
+               result = DaoUtils.convertFromJson(clazz, json);
+               Assert.assertEquals(null, result);
+               
+               try {
+                       result = DaoUtils.convertFromJson(null, json);
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+       }
+}
\ No newline at end of file