summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server/src/test
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2018-03-21 09:30:16 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2018-03-21 09:30:16 +0800
commit70410b3ef0fd4c2325431436365be82c2663a5ed (patch)
tree9b11b8c8f1e513daf0988fe4935bc8c568db9062 /sdc-workflow-designer-server/src/test
parent821c6300e715b354c421b3329809dfc906c67c87 (diff)
JsonUtils for JSON format.
JsonUtils for JSON format. Issue-ID: SDC-1079 Change-Id: I8879652751a0c0ae9d2597e33997fc32a9baa816 Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server/src/test')
-rw-r--r--sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java6
-rw-r--r--sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/JsonUtilsTest.java59
2 files changed, 61 insertions, 4 deletions
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java
index 8d3fd5d3..18a8597a 100644
--- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java
+++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java
@@ -20,8 +20,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.sdc.workflowdesigner.resources.entity.ExtendActivity;
import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
-
-import com.google.gson.Gson;
+import org.onap.sdc.workflowdesigner.utils.JsonUtils;
/**
*
@@ -49,8 +48,7 @@ public class ExtendActivityResourceTest {
try {
Response response = resource.getExtActivities("test");
ExtendActivity[] extActivities = (ExtendActivity[]) response.getEntity();
- Gson gson = new Gson();
- FileCommonUtils.write("test.json", gson.toJson(extActivities));
+ FileCommonUtils.write("test.json", JsonUtils.toJson(extActivities));
assertEquals(extActivities.length == 0, false);
} catch (Exception e) {
e.printStackTrace();
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/JsonUtilsTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/JsonUtilsTest.java
new file mode 100644
index 00000000..2672f6bd
--- /dev/null
+++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/JsonUtilsTest.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner.utils;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.sdc.workflowdesigner.resources.entity.I18nString;
+
+/**
+ *
+ */
+public class JsonUtilsTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
+
+ /**
+ * Test method for {@link org.onap.sdc.workflowdesigner.utils.JsonUtils#fromJson(java.lang.String, java.lang.Class)}.
+ */
+ @Test
+ public void testFromJson() {
+ String i18n = "{\"en_US\":\"Service Task\",\"zh_CN\":\"Service Task\"}";
+ I18nString i18nString = JsonUtils.fromJson(i18n, I18nString.class);
+ assertNotNull(i18nString);
+ }
+
+ /**
+ * Test method for {@link org.onap.sdc.workflowdesigner.utils.JsonUtils#toJson(java.lang.Object)}.
+ */
+ @Test
+ public void testToJson() {
+ I18nString i18nString = new I18nString("Service Task", "Service Task");
+ String i18n = JsonUtils.toJson(i18nString);
+ String expect = "{\"en_US\":\"Service Task\",\"zh_CN\":\"Service Task\"}";
+ assertEquals(expect, i18n);
+ }
+
+}