-/**\r
- * Copyright 2016 ZTE Corporation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-\r
-package org.onap.holmes.common.utils;\r
-\r
-import static org.hamcrest.core.IsEqual.equalTo;\r
-import static org.junit.Assert.assertThat;\r
-\r
-import com.google.gson.Gson;\r
-import com.google.gson.GsonBuilder;\r
-import com.google.gson.JsonDeserializationContext;\r
-import com.google.gson.JsonDeserializer;\r
-import com.google.gson.JsonElement;\r
-import com.google.gson.JsonParseException;\r
-import com.google.gson.JsonSerializationContext;\r
-import com.google.gson.JsonSerializer;\r
-import java.lang.reflect.Type;\r
-import org.junit.Test;\r
-import org.onap.holmes.common.utils.bean.TestBean;\r
-\r
-public class JacksonUtilTest {\r
-\r
- @Test\r
- public void testBeanToJson() throws Exception {\r
- TestBean o = new TestBean();\r
- o.setId("id");\r
- String result = GsonUtil.beanToJson(o);\r
- assertThat("{\"id\":\"id\"}", equalTo(result));\r
- }\r
-\r
- @Test\r
- public void jsonToBean_json_null() throws Exception {\r
- String jsonNull = null;\r
- TestBean testBean = GsonUtil.jsonToBean(jsonNull, TestBean.class);\r
- assertThat(testBean, equalTo(null));\r
- }\r
-\r
- @Test\r
- public void jsonToBean_json_normal() throws Exception {\r
- String json = "{\"id\":\"id\"}";\r
- TestBean testBean = GsonUtil.jsonToBean(json, TestBean.class);\r
- assertThat(testBean.getId(), equalTo("id"));\r
- }\r
-\r
-}
\ No newline at end of file