From 84372056e279fbc8a5df3d8e0e60b3b0919e4362 Mon Sep 17 00:00:00 2001 From: YuanHu Date: Fri, 13 Apr 2018 08:56:42 +0800 Subject: Json Serialize 'clazz' to 'class' Add @JsonProperty(value="class") to field 'clazz' to indicate the Json Serialize name. Issue-ID: SDC-1235 Change-Id: I21de7514a9d6c8f7227b25d8c8c9ecf4e9c35171 Signed-off-by: YuanHu --- .../sdc/workflowdesigner/WorkflowDesignerApp.java | 3 --- .../externalservice/sdc/entity/ActivityContent.java | 19 ++++--------------- .../externalservice/sdc/entity/ActivitySpec.java | 2 +- .../resources/ExtendActivityResource.java | 3 ++- .../workflowdesigner/resources/entity/Content.java | 21 +++++---------------- .../sdc/entity/ActivityContentTest.java | 6 +++--- .../resources/entity/ContentTest.java | 17 ++++++++++++++--- 7 files changed, 29 insertions(+), 42 deletions(-) diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java index e5b065ec..34a17e70 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java @@ -12,7 +12,6 @@ package org.onap.sdc.workflowdesigner; -//import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.onap.sdc.workflowdesigner.config.AdapterType; import org.onap.sdc.workflowdesigner.config.AppConfig; import org.onap.sdc.workflowdesigner.resources.ExtendActivityResource; @@ -61,8 +60,6 @@ public class WorkflowDesignerApp extends Application inputs; private Map outputs; - - /** - * @return the clazz - */ - public String getClazz() { - return clazz; - } - - /** - * @param clazz the clazz to set - */ - public void setClass(String clazz) { - this.clazz = clazz; - } + /** * @return the script diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContentTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContentTest.java index 2ede2611..4aa2dd0f 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContentTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContentTest.java @@ -39,16 +39,16 @@ public class ActivityContentTest { */ @Test public void testToString() { - String clazz = "clazz"; +// String clazz = "clazz"; String script = "script"; String scriptFormat = "scriptFormat"; ActivityContent ac = new ActivityContent(); - ac.setClazz(clazz); +// ac.setClass(clazz); ac.setScript(script); ac.setScriptFormat(scriptFormat ); - assertEquals(clazz, ac.getClazz()); +// assertEquals(clazz, ac.getClazz()); assertEquals(script, ac.getScript()); assertEquals(scriptFormat, ac.getScriptFormat()); } diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ContentTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ContentTest.java index 58738bc0..1c6612ea 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ContentTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ContentTest.java @@ -19,6 +19,7 @@ import java.util.Map; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.onap.sdc.workflowdesigner.utils.JsonUtils; /** * @@ -39,24 +40,34 @@ public class ContentTest { @Test public void test() { - String clazz = "clazz"; +// String clazz = "clazz"; String script = "script"; String scriptFormat = "scriptFormat"; Map inputs = new HashMap(); Map outputs = new HashMap(); Content c = new Content(); - c.setClass(clazz); +// c.setClass(clazz); c.setInputs(inputs); c.setOutputs(outputs); c.setScript(script); c.setScriptFormat(scriptFormat); - assertEquals(clazz, c.getClazz()); +// assertEquals(clazz, c.getClazz()); assertEquals(inputs, c.getInputs()); assertEquals(outputs, c.getOutputs()); assertEquals(script, c.getScript()); assertEquals(scriptFormat, c.getScriptFormat()); } + + @Test + public void testGson() { + String json = "{\r\n" + + " \"class\": \"aaaa\",\r\n" + + " \"inputs\": {}\r\n" + + " }"; + Content content = JsonUtils.fromJson(json, Content.class); + assertNotNull(content); + } } -- cgit 1.2.3-korg