diff options
author | YuanHu <yuan.hu1@zte.com.cn> | 2018-04-13 08:56:42 +0800 |
---|---|---|
committer | YuanHu <yuan.hu1@zte.com.cn> | 2018-04-17 14:24:17 +0800 |
commit | 84372056e279fbc8a5df3d8e0e60b3b0919e4362 (patch) | |
tree | 99f804308dd003fb62a5fc3558bf653305582460 /sdc-workflow-designer-server | |
parent | e789e3060b7860075820af76a71e6dfc050cc286 (diff) |
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 <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server')
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<WorkflowDesignerConfigurati // register rest interface environment.jersey().packages("org.onap.sdc.workflowdesigner.resources"); -// // upload file by inputstream need to register MultiPartFeature -// environment.jersey().register(MultiPartFeature.class); initSwaggerConfig(environment, configuration); diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContent.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContent.java index e97fd8e2..66208a2c 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContent.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContent.java @@ -11,32 +11,21 @@ */
package org.onap.sdc.workflowdesigner.externalservice.sdc.entity;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
/**
*
*/
public class ActivityContent {
- @SerializedName("class")
- private String clazz;
+ @JsonProperty(value="class") // for dropwizard's Jackson
+ @SerializedName("class") // for Gson
+ public String clazz;
private String scriptFormat;
private String script;
- /**
- * @return the clazz
- */
- public String getClazz() {
- return clazz;
- }
-
- /**
- * @param clazz the clazz to set
- */
- public void setClazz(String clazz) {
- this.clazz = clazz;
- }
/**
* @return the scriptFormat
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java index 2ce45fa0..35a1a36e 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java @@ -25,7 +25,7 @@ public class ActivitySpec { private String type;
- private ActivityContent content;
+ private ActivityContent content = new ActivityContent();
private String[] categoryList;
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java index 46fef111..99e2f28a 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java @@ -160,7 +160,8 @@ public class ExtendActivityResource { */ private Content buildContent(ActivitySpec activitySpec) { Content content = new Content(); - content.setClass(activitySpec.getContent().getClazz()); +// content.setClass(activitySpec.getContent().getClazz()); + content.clazz = activitySpec.getContent().clazz; content.setScript(activitySpec.getContent().getScript()); content.setScriptFormat(activitySpec.getContent().getScriptFormat()); content.setInputs(convert2InputOutputs(activitySpec.getInputs())); diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/Content.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/Content.java index 5a246624..70d59928 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/Content.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/Content.java @@ -13,14 +13,16 @@ package org.onap.sdc.workflowdesigner.resources.entity; import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
/**
*
*/
public class Content {
- @SerializedName("class")
- private String clazz;
+ @JsonProperty(value="class") // for dropwizard's Jackson
+ @SerializedName("class") // for Gson
+ public String clazz;
private String script;
@@ -29,20 +31,7 @@ public class Content { private Map<String, InputOutput> inputs;
private Map<String, InputOutput> 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<String, InputOutput> inputs = new HashMap<String, InputOutput>();
Map<String, InputOutput> outputs = new HashMap<String, InputOutput>();
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);
+ }
}
|