re base code
[sdc.git] / catalog-dao / src / test / java / org / openecomp / sdc / be / dao / utils / DaoUtilsTest.java
1 package org.openecomp.sdc.be.dao.utils;
2
3 import org.junit.Assert;
4 import org.junit.Test;
5
6 import static org.assertj.core.api.Assertions.assertThatThrownBy;
7
8 public class DaoUtilsTest {
9
10         @Test
11         public void testConvertToJson() throws Exception {
12                 Object object = new Object();
13                 String result;
14
15                 // test 1
16                 result = DaoUtils.convertToJson(object);
17                 Assert.assertEquals("{}", result);
18                 
19                 assertThatThrownBy(()->DaoUtils.convertToJson(null)).isInstanceOf(RuntimeException.class);
20         }
21
22         @Test
23         public void testConvertFromJson() throws Exception {
24                 Class clazz = Object.class;
25                 String json = null;
26                 Object result;
27
28                 // default test
29                 result = DaoUtils.convertFromJson(clazz, json);
30                 Assert.assertEquals(null, result);
31                 
32                 try {
33                         result = DaoUtils.convertFromJson(null, json);
34                 } catch (Exception e) {
35                         // TODO Auto-generated catch block
36                         e.printStackTrace();
37                 }
38         }
39 }