diff options
19 files changed, 506 insertions, 368 deletions
diff --git a/distribution/src/main/assembly/ext-activities-display-info.json b/distribution/src/main/assembly/ext-activities-display-info.json index 8a5e10af..72056a5d 100644 --- a/distribution/src/main/assembly/ext-activities-display-info.json +++ b/distribution/src/main/assembly/ext-activities-display-info.json @@ -4,8 +4,6 @@ }, "apds_service": { }, - "apds_rest": { - }, "apds_scriptA": { "category": "aaa" }, @@ -15,10 +13,7 @@ "apds_serviceA": { "category": "aaa" }, - "apds_restA": { - "category": "aaa" - }, - "apds_restB": { + "apds_serviceB": { "category": "aaa" } }, @@ -31,4 +26,4 @@ "collapse": true } } -}
\ No newline at end of file +} diff --git a/distribution/src/main/assembly/ext-activities.json b/distribution/src/main/assembly/ext-activities.json index 0eb1f0e1..6defc343 100644 --- a/distribution/src/main/assembly/ext-activities.json +++ b/distribution/src/main/assembly/ext-activities.json @@ -21,32 +21,6 @@ } }, { - "id": "apds_rest", - "displayName": { - "zh_CN": "REST", - "en_US": "REST" - }, - "description": { - "zh_CN": "REST 节点", - "en_US": "REST Node" - }, - "type": "restTask", - "icon": { - "name": "apds_rest", - "width": 56, - "height": 56 - }, - "content": { - "url": "", - "name": "", - "version": "", - "path": "", - "method": "", - "accept": "", - "inputs": {} - } - }, - { "id": "apds_script", "displayName": { "zh_CN": "默认脚本", @@ -70,12 +44,12 @@ { "id": "apds_scriptA", "displayName": { - "zh_CN": "JavaScript", - "en_US": "JavaScript" + "zh_CN": "Stop traffic", + "en_US": "Stop traffic" }, "description": { - "zh_CN": "脚本节点", - "en_US": "Script Node" + "zh_CN": "Stop traffic", + "en_US": "Stop traffic" }, "type": "scriptTask", "icon": { @@ -91,12 +65,12 @@ { "id": "apds_scriptB", "displayName": { - "zh_CN": "Groovy Task", - "en_US": "Groovy Task" + "zh_CN": "Drain traffic", + "en_US": "Drain traffic" }, "description": { - "zh_CN": "Groovy Task", - "en_US": "Groovy Task" + "zh_CN": "Drain traffic", + "en_US": "Drain traffic" }, "type": "scriptTask", "icon": { @@ -112,12 +86,12 @@ { "id": "apds_serviceA", "displayName": { - "zh_CN": "Java Task", - "en_US": "Java Task" + "zh_CN": "Stop VNF", + "en_US": "Stop VNF" }, "description": { - "zh_CN": "Java Task", - "en_US": "Java Task" + "zh_CN": "Stop VNF", + "en_US": "Stop VNF" }, "type": "serviceTask", "icon": { @@ -126,7 +100,7 @@ "height": 56 }, "content": { - "class": "com.zte.ums.workflow.activitiext.restservicetask.HttpUtil", + "class": "org.onap.sdc.workflow.task.StopVNFDelegate", "inputs": { "param1": { "type": "string", @@ -176,187 +150,69 @@ } }, { - "id": "apds_restA", - "displayName": { - "zh_CN": "REST无参数", - "en_US": "REST No Parameters" - }, - "description": { - "zh_CN": "REST无参数", - "en_US": "REST No Parameters" - }, - "type": "restTask", - "icon": { - "name": "apds_rest", - "width": 56, - "height": 56 - }, - "content": { - "serviceName": "name", - "serviceVersion": "v1", - "baseUrl": "url", - "path": "/test/", - "method": "put", - "consumes": "application/json, text/plain", - "produces": "application/json, text/plain", - "inputs": {} - } - }, - { - "id": "apds_restB", + "id": "apds_serviceB", "displayName": { - "zh_CN": "REST复杂参数", - "en_US": "REST Complex Parameters" + "zh_CN": "Create VNF", + "en_US": "Create VNF" }, "description": { - "zh_CN": "REST复杂参数", - "en_US": "REST Complex Parameters" + "zh_CN": "Create VNF", + "en_US": "Create VNF" }, - "type": "restTask", + "type": "serviceTask", "icon": { - "name": "apds_rest", + "name": "apds_service", "width": 56, "height": 56 }, "content": { - "serviceName": "ServiceName", - "serviceVersion": "v1", - "baseUrl": "url", - "path": "/test/", - "method": "put", - "consumes": "application/json, text/plain", - "produces": "application/json, text/plain", + "class": "org.onap.sdc.workflow.task.CreateVNFDelegate", "inputs": { - "param1": { - "in": "query", + "id": { "type": "string", "default": "default", "required": false, - "show": false, + "displayName": { + "zh_CN": "id", + "en_US": "id" + }, + "show": true, "editable": true }, - "param2": { - "in": "body", - "schema": { - "type": "object", - "properties": { - "a": { - "type": "number", - "default": 123 - }, - "b": { - "type": "string", - "default": "xyz" - }, - "c": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "a", - "b", - "c" - ] - } - }, - "d": { - "type": "array", - "items": { - "type": "object", - "properties": { - "p1": { - "type": "number" - }, - "p2": { - "type": "boolean" - } - } - } - }, - "y": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "z": { - "type": "object", - "additionalProperties": { - "type": "integer" - } - } - } - }, + "name": { + "type": "string", "required": true, + "displayName": { + "zh_CN": "name", + "en_US": "name" + }, "show": true, "editable": true }, - "param3": { - "in": "path", + "type": { "type": "string", "default": "value3", "required": true, + "displayName": { + "zh_CN": "type", + "en_US": "type" + }, "show": true, "editable": false } }, "outputs": { - "body": { + "status": { + "type": "string", + "required": false, "displayName": { - "zh_CN": "消息体", - "en_US": "Message Body" - }, - "schema": { - "type": "object", - "properties": { - "a": { - "type": "number" - }, - "b": { - "type": "string" - }, - "c": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "a", - "b", - "c" - ] - } - }, - "d": { - "type": "array", - "items": { - "type": "object", - "properties": { - "p1": { - "type": "number" - }, - "p2": { - "type": "boolean" - } - } - } - }, - "y": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "z": { - "type": "object", - "additionalProperties": { - "type": "integer" - } - } - } + "zh_CN": "status", + "en_US": "status of vnf" }, - "editable": false + "show": true, + "editable": true } } } } -]
\ No newline at end of file +] diff --git a/distribution/src/main/assembly/temp_workflow.json b/distribution/src/main/assembly/temp_workflow.json index f12f892e..3b3fa1c1 100644 --- a/distribution/src/main/assembly/temp_workflow.json +++ b/distribution/src/main/assembly/temp_workflow.json @@ -5,109 +5,121 @@ "data": {
"nodes": [
{
- "id": "node0",
+ "id": "startEvent",
"type": "startEvent",
"name": "Start",
"parentId": "root",
"position": {
- "left": 99,
- "top": 131,
+ "left": 73,
+ "top": 160,
"width": 56,
"height": 56
},
"connection": [
{
- "sourceRef": "node0",
- "targetRef": "serviceTask"
+ "sourceRef": "startEvent",
+ "targetRef": "scriptTask"
}
],
- "parameters": [
- {
- "name": "aaa",
- "value": "a111",
- "valueSource": "string",
- "type": "string",
- "required": false,
- "show": true,
- "errorMsg": ""
- },
+ "parameters": []
+ },
+ {
+ "id": "scriptTask",
+ "type": "scriptTask",
+ "typeId": "apds_scriptA",
+ "icon": "apds_script",
+ "name": "Stop traffic",
+ "parentId": "root",
+ "position": {
+ "left": 175,
+ "top": 160,
+ "width": 56,
+ "height": 56
+ },
+ "connection": [
{
- "name": "bbb",
- "value": "b111",
- "valueSource": "string",
- "type": "string",
- "required": false,
- "show": true,
- "errorMsg": ""
+ "sourceRef": "scriptTask",
+ "targetRef": "scriptTask_2"
}
- ]
+ ],
+ "scriptFormat": "JavaScript",
+ "script": "abc"
},
{
- "id": "node2",
- "type": "endEvent",
- "name": "End",
+ "id": "scriptTask_2",
+ "type": "scriptTask",
+ "typeId": "apds_scriptB",
+ "icon": "apds_script",
+ "name": "Drain traffic",
"parentId": "root",
"position": {
- "left": 459,
- "top": 131,
+ "left": 289,
+ "top": 160,
"width": 56,
"height": 56
},
- "connection": []
+ "connection": [
+ {
+ "sourceRef": "scriptTask_2",
+ "targetRef": "serviceTask"
+ }
+ ],
+ "scriptFormat": "Groovy",
+ "script": "xyz"
},
{
"id": "serviceTask",
"type": "serviceTask",
"typeId": "apds_serviceA",
"icon": "apds_service",
- "name": "Java Task",
+ "name": "Stop VNF",
"parentId": "root",
"position": {
- "left": 232,
- "top": 131,
+ "left": 392,
+ "top": 160,
"width": 56,
"height": 56
},
"connection": [
{
"sourceRef": "serviceTask",
- "targetRef": "scriptTask"
+ "targetRef": "serviceTask_2"
}
],
- "className": "org.onap.sdc.workflowdesigner.JavaTask",
+ "className": "",
"inputs": [
{
"name": "param1",
+ "value": "default",
"valueSource": "string",
"type": "string",
"required": false,
"show": true,
- "errorMsg": "",
- "value": "a111"
+ "errorMsg": ""
},
{
"name": "param2",
+ "value": null,
"valueSource": "string",
"type": "string",
"required": true,
"show": true,
- "errorMsg": "",
- "value": "b111"
+ "errorMsg": ""
},
{
"name": "param3",
+ "value": "value3",
"valueSource": "string",
"type": "string",
"required": true,
"show": true,
- "errorMsg": "",
- "value": "c111"
+ "errorMsg": ""
}
],
"outputs": [
{
"name": "out1",
- "value": "",
+ "value": null,
"valueSource": "string",
"type": "string",
"required": false,
@@ -117,27 +129,61 @@ ]
},
{
- "id": "scriptTask",
- "type": "scriptTask",
- "typeId": "apds_scriptB",
- "icon": "apds_script",
- "name": "Groovy Task",
+ "id": "serviceTask_2",
+ "type": "serviceTask",
+ "typeId": "apds_serviceB",
+ "icon": "apds_service",
+ "name": "Create VNF",
"parentId": "root",
"position": {
- "left": 335,
- "top": 131,
+ "left": 500,
+ "top": 160,
"width": 56,
"height": 56
},
"connection": [
{
- "sourceRef": "scriptTask",
- "targetRef": "node2"
+ "sourceRef": "serviceTask_2",
+ "targetRef": "serviceTask_3"
+ }
+ ]
+ },
+ {
+ "id": "serviceTask_3",
+ "type": "serviceTask",
+ "typeId": "apds_service",
+ "icon": "apds_service",
+ "name": "Start VNF",
+ "parentId": "root",
+ "position": {
+ "left": 620,
+ "top": 160,
+ "width": 56,
+ "height": 56
+ },
+ "connection": [
+ {
+ "sourceRef": "serviceTask_3",
+ "targetRef": "endEvent"
}
],
- "scriptFormat": "Groovy",
- "script": "xyz"
+ "className": "",
+ "inputs": [],
+ "outputs": []
+ },
+ {
+ "id": "endEvent",
+ "type": "endEvent",
+ "name": "End",
+ "parentId": "root",
+ "position": {
+ "left": 744,
+ "top": 160,
+ "width": 56,
+ "height": 56
+ },
+ "connection": []
}
]
}
-}
\ No newline at end of file +}
diff --git a/sdc-workflow-designer-server/pom.xml b/sdc-workflow-designer-server/pom.xml index 6ecf11c3..4e125444 100644 --- a/sdc-workflow-designer-server/pom.xml +++ b/sdc-workflow-designer-server/pom.xml @@ -27,6 +27,7 @@ <properties> <velocity.version>1.7</velocity.version> + <commons-collections.version>3.2.2</commons-collections.version> <commons-io.version>2.4</commons-io.version> <dom4j.version>1.6.1</dom4j.version> <dropwizard.version>1.2.2</dropwizard.version> @@ -118,6 +119,12 @@ <groupId>io.swagger</groupId> <artifactId>swagger-jersey2-jaxrs</artifactId> <version>${swagger.version}</version> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + </exclusion> + </exclusions> </dependency> <!-- jersey --> @@ -155,12 +162,30 @@ <groupId>com.eclipsesource.jaxrs</groupId> <artifactId>consumer</artifactId> <version>${jaxrs.consumer.version}</version> + <exclusions> + <exclusion> + <groupId>com.eclipsesource.jaxrs</groupId> + <artifactId>jersey-all</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>${velocity.version}</version> + <exclusions> + <exclusion> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>${commons-collections.version}</version> </dependency> <dependency> 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/common/WorkflowDesignerException.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/SDCProxyException.java index 343df014..8f596b0c 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/WorkflowDesignerException.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/SDCProxyException.java @@ -15,19 +15,19 @@ */ package org.onap.sdc.workflowdesigner.common; -public class WorkflowDesignerException extends Exception { +public class SDCProxyException extends Exception { private static final long serialVersionUID = 1L; - public WorkflowDesignerException() { + public SDCProxyException() { super(); } - public WorkflowDesignerException(String msg, Exception e) { + public SDCProxyException(String msg, Exception e) { super(msg, e); } - public WorkflowDesignerException(String msg) { + public SDCProxyException(String msg) { super(msg); } } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java index fa1987ef..e014b542 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java @@ -16,7 +16,7 @@ package org.onap.sdc.workflowdesigner.externalservice.sdc; import org.glassfish.jersey.client.ClientConfig; -import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException; +import org.onap.sdc.workflowdesigner.common.SDCProxyException; import org.onap.sdc.workflowdesigner.config.AppConfig; import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.ActivitySpec; import org.slf4j.Logger; @@ -35,11 +35,11 @@ public class ActivitySpecServiceProxy { private static final String X_ECOMP_INSTANCE_ID = AppConfig.getSdcServiceProxy().getxEcompInstanceId(); /** */ - private static final String Activity_ROOT_PATH = "/activityspec-api/v1.0"; + private static final String ACTIVITY_ROOT_PATH = "/activityspec-api/v1.0"; private static String getActivityRootPath() { - return AppConfig.getSdcServiceProxy().getServiceAddr() + Activity_ROOT_PATH; + return AppConfig.getSdcServiceProxy().getServiceAddr() + ACTIVITY_ROOT_PATH; } /** @@ -54,15 +54,15 @@ public class ActivitySpecServiceProxy { /** * * @return - * @throws WorkflowDesignerException + * @throws SDCProxyException */ - public ActivitySpec[] getActivitySpecs() throws WorkflowDesignerException { + public ActivitySpec[] getActivitySpecs() throws SDCProxyException { ActivitySpecService serviceProxy = getActivityServiceProxy(); try { return serviceProxy.getActivitySpecs(X_ECOMP_INSTANCE_ID, AUTHORIZATION); } catch (Exception e) { LOGGER.error("Get Activity Specifications Failed.", e); - throw new WorkflowDesignerException("Get Activity Specifications Failed.", e); + throw new SDCProxyException("Get Activity Specifications Failed.", e); } } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java index b925c03d..374bca7a 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java @@ -16,7 +16,7 @@ package org.onap.sdc.workflowdesigner.externalservice.sdc; import org.glassfish.jersey.client.ClientConfig; -import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException; +import org.onap.sdc.workflowdesigner.common.SDCProxyException; import org.onap.sdc.workflowdesigner.config.AppConfig; import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo; import org.slf4j.Logger; @@ -56,17 +56,17 @@ public class SDCServiceProxy { * @param operationId * @param workflowId * @param workflowArtifactInfo - * @throws WorkflowDesignerException + * @throws SDCProxyException */ public void saveWorkflowArtifact(String uuid, String operationId, String workflowId, - WorkflowArtifactInfo workflowArtifactInfo) throws WorkflowDesignerException { + WorkflowArtifactInfo workflowArtifactInfo) throws SDCProxyException { SDCService serviceProxy = getSDCServiceProxy(); try { serviceProxy.saveWorkflowArtifact(uuid, operationId, workflowId, X_ECOMP_INSTANCE_ID, AUTHORIZATION, workflowArtifactInfo); } catch (Exception e) { LOGGER.error("Save WorkflowArtifact Failed.", e); - throw new WorkflowDesignerException("Save WorkflowArtifact Failed.", e); + throw new SDCProxyException("Save WorkflowArtifact Failed.", e); } } @@ -76,17 +76,17 @@ public class SDCServiceProxy { * @param operationId * @param workflowId * @return - * @throws WorkflowDesignerException + * @throws SDCProxyException */ public WorkflowArtifactInfo getWorkflowArtifact(String uuid, String operationId, - String workflowId) throws WorkflowDesignerException { + String workflowId) throws SDCProxyException { SDCService serviceProxy = getSDCServiceProxy(); try { return serviceProxy.getWorkflowArtifact(uuid, operationId, workflowId, X_ECOMP_INSTANCE_ID, AUTHORIZATION); } catch (Exception e) { LOGGER.error("Get WorkflowArtifact Failed.", e); - throw new WorkflowDesignerException("Get WorkflowArtifact Failed.", e); + throw new SDCProxyException("Get WorkflowArtifact Failed.", e); } } 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 bd8a541f..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 @@ -13,6 +13,8 @@ package org.onap.sdc.workflowdesigner.resources; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -23,8 +25,18 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.eclipse.jetty.http.HttpStatus; +import org.onap.sdc.workflowdesigner.common.SDCProxyException; +import org.onap.sdc.workflowdesigner.config.AppConfig; +import org.onap.sdc.workflowdesigner.externalservice.sdc.ActivitySpecServiceProxy; +import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.ActivitySpec; +import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.Parameter; import org.onap.sdc.workflowdesigner.resources.entity.ExtActivityDisplayInfo; -import org.onap.sdc.workflowdesigner.resources.entity.ExtendActivity; +import org.onap.sdc.workflowdesigner.resources.entity.I18nString; +import org.onap.sdc.workflowdesigner.resources.entity.InputOutput; +import org.onap.sdc.workflowdesigner.resources.entity.NodeCategory; +import org.onap.sdc.workflowdesigner.resources.entity.CategoryData; +import org.onap.sdc.workflowdesigner.resources.entity.Content; +import org.onap.sdc.workflowdesigner.resources.entity.ExtActivity; import org.onap.sdc.workflowdesigner.utils.FileCommonUtils; import org.onap.sdc.workflowdesigner.utils.JsonUtils; import org.onap.sdc.workflowdesigner.utils.RestUtils; @@ -54,6 +66,11 @@ public class ExtendActivityResource { private static final String EXT_ACTIVITIES_FILE_NAME = "ext-activities.json"; + private static final CategoryData EXTENSION_TASK_CATEGORY = + new CategoryData(new I18nString("Extension Task", "Extension Task")); + + private static final String EXTENSION_TASK_CATEGORY_CATEGORY_ID = "extension_task_category_id"; + /** * test function. * @@ -63,7 +80,7 @@ public class ExtendActivityResource { @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Get Extend Activities.", response = ExtendActivity.class, + @ApiOperation(value = "Get Extend Activities.", response = ExtActivity.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", @@ -74,25 +91,107 @@ public class ExtendActivityResource { response = String.class)}) @Timed public Response getExtActivities(@ApiParam(value = "sence") @QueryParam("sence") String sence) { + if (AppConfig.isSDCAdapter()) { + return getExtActivitiesfromSDC(); + } else { + return getExtActivitiesfromLocal(); + } + } + /** + * @return + */ + private Response getExtActivitiesfromLocal() { try { - ExtendActivity[] extActivities = retriveExtActivites(sence); + String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME); + ExtActivity[] extActivities = JsonUtils.fromJson(json, ExtActivity[].class); return Response.status(Response.Status.OK).entity(extActivities).build(); } catch (IOException e) { - LOGGER.error("Get ExtActivities failed.", e); + LOGGER.error("Get ExtActivities from local failed.", e); throw RestUtils.newInternalServerErrorException(e); } + } + /** + * @return + */ + private Response getExtActivitiesfromSDC() { + try { + ActivitySpecServiceProxy proxy = new ActivitySpecServiceProxy(); + ActivitySpec[] activitySpecs = proxy.getActivitySpecs(); + ExtActivity[] extActivities = convert2ExtActivities(activitySpecs); + return Response.status(Response.Status.OK).entity(extActivities).build(); + } catch (SDCProxyException e) { + LOGGER.error("Get ExtActivities from sdc failed.", e); + throw RestUtils.newInternalServerErrorException(e); + } } /** - * @param sence + * @param activitySpecs + * @return + */ + private ExtActivity[] convert2ExtActivities(ActivitySpec[] activitySpecs) { + ExtActivity[] extendActivities = new ExtActivity[activitySpecs.length]; + for (int i = 0; i < activitySpecs.length; i++) { + extendActivities[i] = convert2ExtActivity(activitySpecs[i]); + } + return extendActivities; + } + + /** + * @param activitySpec + * @return + */ + private ExtActivity convert2ExtActivity(ActivitySpec activitySpec) { + ExtActivity extActivity = new ExtActivity(); + extActivity.setId(activitySpec.getId()); + extActivity.setDisplayName(new I18nString(activitySpec.getName(), activitySpec.getName())); + extActivity.setDescription( + new I18nString(activitySpec.getDescription(), activitySpec.getDescription())); + extActivity.setType(activitySpec.getType()); + extActivity.setContent(buildContent(activitySpec)); + return extActivity; + } + + /** + * @param activitySpec + * @return + */ + private Content buildContent(ActivitySpec activitySpec) { + Content content = new Content(); +// 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())); + content.setOutputs(convert2InputOutputs(activitySpec.getOutputs())); + return content; + } + + /** + * @param parameters + * @return + */ + private Map<String, InputOutput> convert2InputOutputs(Parameter[] parameters) { + Map<String, InputOutput> inputOutputs = new HashMap<>(); + for (Parameter parameter : parameters) { + inputOutputs.put(parameter.getName(), convert2InputOutput(parameter)); + } + return inputOutputs; + } + + /** + * @param parameter * @return - * @throws IOException */ - protected ExtendActivity[] retriveExtActivites(String sence) throws IOException { - String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME); - return JsonUtils.fromJson(json, ExtendActivity[].class); + private InputOutput convert2InputOutput(Parameter parameter) { + InputOutput inputOutput = new InputOutput(); + inputOutput.setDisplayName(new I18nString(parameter.getName(), parameter.getName())); + inputOutput.setType(parameter.getType()); + inputOutput.setDefault(parameter.getDefault()); + inputOutput.setValue(parameter.getValue()); + return inputOutput; } @@ -111,16 +210,70 @@ public class ExtendActivityResource { response = String.class)}) @Timed public Response getDisplayInfo(@ApiParam(value = "sence") @QueryParam("sence") String sence) { + if (AppConfig.isSDCAdapter()) { + return getDisplayInfofromSDC(); + } else { + return getDisplayInfofromLocal(sence); + } + } + + /** + * @param sence + * @return + */ + private Response getDisplayInfofromLocal(String sence) { try { ExtActivityDisplayInfo displayInfo = retriveDisplayInfo(sence); return Response.status(Response.Status.OK).entity(displayInfo).build(); } catch (IOException e) { - LOGGER.error("Get Extend Activities DisplayInfo failed.", e); + LOGGER.error("Get Extend Activities DisplayInfo from failed.", e); throw RestUtils.newInternalServerErrorException(e); } } /** + * @return + */ + private Response getDisplayInfofromSDC() { + try { + ActivitySpecServiceProxy proxy = new ActivitySpecServiceProxy(); + ActivitySpec[] activitySpecs = proxy.getActivitySpecs(); + ExtActivityDisplayInfo displayInfo = convert2ExtActivityDisplayInfo(activitySpecs); + return Response.status(Response.Status.OK).entity(displayInfo).build(); + } catch (SDCProxyException e) { + LOGGER.error("Get Extend Activities DisplayInfo from sdc failed.", e); + throw RestUtils.newInternalServerErrorException(e); + } + } + + /** + * @param activitySpecs + * @return + */ + private ExtActivityDisplayInfo convert2ExtActivityDisplayInfo(ActivitySpec[] activitySpecs) { + ExtActivityDisplayInfo displayInfo = new ExtActivityDisplayInfo(); + + for (ActivitySpec activitySpec : activitySpecs) { + displayInfo.getNodes().put(activitySpec.getId(), buildNodeCategory(activitySpec)); + } + + displayInfo.getCategoryData().put(EXTENSION_TASK_CATEGORY_CATEGORY_ID, EXTENSION_TASK_CATEGORY); + + return displayInfo; + } + + /** + * @param activitySpec + * @return + */ + private NodeCategory buildNodeCategory(ActivitySpec activitySpec) { + NodeCategory nodeCategory = new NodeCategory(); + nodeCategory.setCategory(EXTENSION_TASK_CATEGORY_CATEGORY_ID); + + return nodeCategory; + } + + /** * @param sence * @return * @throws IOException diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java index 0f0e2dd8..c08fcef5 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java @@ -14,9 +14,9 @@ package org.onap.sdc.workflowdesigner.resources; import java.io.IOException; import java.net.URI; -//import java.nio.file.Paths; +import java.nio.file.Paths; import java.util.List; -//import java.util.UUID; +import java.util.UUID; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -24,6 +24,7 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -32,15 +33,17 @@ import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.eclipse.jetty.http.HttpStatus; -//import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException; -//import org.onap.sdc.workflowdesigner.externalservice.sdc.SDCServiceProxy; -//import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo; +import org.onap.sdc.workflowdesigner.common.SDCProxyException; +import org.onap.sdc.workflowdesigner.config.AppConfig; +import org.onap.sdc.workflowdesigner.externalservice.sdc.SDCServiceProxy; +import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo; import org.onap.sdc.workflowdesigner.model.Process; import org.onap.sdc.workflowdesigner.parser.Bpmn4ToscaJsonParser; -//import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo; +import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo; import org.onap.sdc.workflowdesigner.utils.FileCommonUtils; -//import org.onap.sdc.workflowdesigner.utils.JsonUtils; +import org.onap.sdc.workflowdesigner.utils.JsonUtils; import org.onap.sdc.workflowdesigner.utils.RestUtils; +import org.onap.sdc.workflowdesigner.utils.ToolUtils; import org.onap.sdc.workflowdesigner.writer.BpmnPlanArtefactWriter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +66,7 @@ public class WorkflowModelerResource { private static final Logger logger = LoggerFactory.getLogger(WorkflowModelerResource.class); private static final String WORKFLOW_JSON_TEMP_FILE_NAME = "temp_workflow.json"; -// private static final String WORKFLOW_XML_TEMP_FILE_NAME = "temp_workflow.xml"; + private static final String WORKFLOW_XML_TEMP_FILE_NAME = "temp_workflow.xml"; /** @@ -74,7 +77,7 @@ public class WorkflowModelerResource { @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Get Model", response = String.class) + @ApiOperation(value = "Get Model", response = WorkflowInfo.class) @ApiResponses(value = { @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class), @@ -83,17 +86,78 @@ public class WorkflowModelerResource { @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "server internal error", response = String.class)}) @Timed - public Response getModel(@ApiParam(value = "id") @PathParam("id") String id) { + public Response getModel(@ApiParam(value = "id") @PathParam("id") String id, + @ApiParam(value = "name") @QueryParam("name") String name, + @ApiParam(value = "uuid") @QueryParam("uuid") String uuid, + @ApiParam(value = "operationId") @QueryParam("operationId") String operationId) { + if (AppConfig.isSDCAdapter()) { + return getModelfromSDC(uuid, operationId, id, name); + } else { + return getModelfromLocal(); + } + + } + + /** + * @return + */ + private Response getModelfromLocal() { try { String json = FileCommonUtils.readString(WORKFLOW_JSON_TEMP_FILE_NAME); return Response.status(Response.Status.OK).entity(json).build(); } catch (IOException e) { - logger.error("get workflow failed.", e); + logger.error("get workflow from local failed.", e); throw RestUtils.newInternalServerErrorException(e); } } + /** + * @param uuid + * @param operationId + * @param id + * @param name + * @return + */ + private Response getModelfromSDC(String uuid, String operationId, String id, String name) { + try { + SDCServiceProxy sdcProxy = new SDCServiceProxy(); + WorkflowArtifactInfo wai = sdcProxy.getWorkflowArtifact(uuid, operationId, id); + String bpmn = wai.getPayloadData(); + String json = readJsonfromBPMN(bpmn); + if (ToolUtils.isEmpty(json)) { + WorkflowInfo wfi = newEmptyWorkflowInfo(uuid, operationId, id, name); + return Response.status(Response.Status.OK).entity(wfi).build(); + } + return Response.status(Response.Status.OK).entity(json).build(); + } catch (SDCProxyException e) { + logger.error("get workflow from sdc failed.", e); + throw RestUtils.newInternalServerErrorException(e); + } catch (DocumentException e) { + logger.error("get workflow from sdc failed.", e); + throw RestUtils.newInternalServerErrorException(e); + } + } + + /** + * @param id + * @param operationId + * @param uuid + * @param name + * @return + */ + private WorkflowInfo newEmptyWorkflowInfo(String uuid, String operationId, String id, + String name) { + WorkflowInfo wfi = new WorkflowInfo(); + wfi.setId(id); + wfi.setName(name); + wfi.setUuid(uuid); + wfi.setOperationId(operationId); + + return wfi; + } + + @Path("/{id}") @PUT @@ -112,15 +176,16 @@ public class WorkflowModelerResource { @ApiParam(value = "Model Content", required = true) String json) { try { FileCommonUtils.write(WORKFLOW_JSON_TEMP_FILE_NAME, json); - - // TODO for Nexus-IQ -// URI srcUri = Paths.get(".", WORKFLOW_JSON_TEMP_FILE_NAME).toUri(); -// String processName = "plan_" + UUID.randomUUID().toString(); -// String bpmn = buildBPMN(srcUri, processName); -// String jsonBpmn = insertJson2Bpmn(json, bpmn); -// save2SDC(json, jsonBpmn); -// FileCommonUtils.write(WORKFLOW_XML_TEMP_FILE_NAME, jsonBpmn); + URI srcUri = Paths.get(".", WORKFLOW_JSON_TEMP_FILE_NAME).toUri(); + String processName = "plan_" + UUID.randomUUID().toString(); + String bpmn = buildBPMN(srcUri, processName); + String jsonBpmn = insertJson2Bpmn(json, bpmn); + + if (AppConfig.isSDCAdapter()) { + save2SDC(json, jsonBpmn); + } + FileCommonUtils.write(WORKFLOW_XML_TEMP_FILE_NAME, jsonBpmn); return Response.status(Response.Status.OK).entity(json).build(); } catch (IOException e) { @@ -149,7 +214,11 @@ public class WorkflowModelerResource { * @return * @throws DocumentException */ - protected String readJsonfromBPMNFile(String bpmn) throws DocumentException { + protected String readJsonfromBPMN(String bpmn) throws DocumentException { + if (ToolUtils.isEmpty(bpmn)) { + return null; + } + Document doc = DocumentHelper.parseText(bpmn); List<?> elementList = doc.content(); for (Object object : elementList) { @@ -163,20 +232,20 @@ public class WorkflowModelerResource { } -// /** -// * @param json -// * @param bpmn -// * @throws WorkflowDesignerException -// */ -// private void save2SDC(String json, String bpmn) throws WorkflowDesignerException { -// WorkflowInfo workflowInfo = JsonUtils.fromJson(json, WorkflowInfo.class); -// WorkflowArtifactInfo workflowArtifactInfo = -// new WorkflowArtifactInfo(workflowInfo.getName(), workflowInfo.getDescription(), bpmn); -// -// SDCServiceProxy sdcProxy = new SDCServiceProxy(); -// sdcProxy.saveWorkflowArtifact(workflowInfo.getUuid(), workflowInfo.getOperationId(), -// workflowInfo.getId(), workflowArtifactInfo); -// } + /** + * @param json + * @param bpmn + * @throws SDCProxyException + */ + private void save2SDC(String json, String bpmn) throws SDCProxyException { + WorkflowInfo workflowInfo = JsonUtils.fromJson(json, WorkflowInfo.class); + WorkflowArtifactInfo workflowArtifactInfo = + new WorkflowArtifactInfo(workflowInfo.getName(), workflowInfo.getDescription(), bpmn); + + SDCServiceProxy sdcProxy = new SDCServiceProxy(); + sdcProxy.saveWorkflowArtifact(workflowInfo.getUuid(), workflowInfo.getOperationId(), + workflowInfo.getId(), workflowArtifactInfo); + } /** * 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..2a49ae07 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,19 @@ package org.onap.sdc.workflowdesigner.resources.entity; import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
/**
*
*/
+@JsonInclude(Include.NON_NULL)
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 +34,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/main/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivity.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivity.java index 30e35c13..5a798ee2 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivity.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivity.java @@ -11,10 +11,14 @@ */
package org.onap.sdc.workflowdesigner.resources.entity;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
/**
*
*/
-public class ExtendActivity {
+@JsonInclude(Include.NON_NULL)
+public class ExtActivity {
private String id;
private I18nString displayName;
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/ExtendActivityResourceTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java index 899e2ee9..fcb71360 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 @@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals; import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.onap.sdc.workflowdesigner.resources.entity.ExtendActivity;
+import org.onap.sdc.workflowdesigner.resources.entity.ExtActivity;
import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
import org.onap.sdc.workflowdesigner.utils.JsonUtils;
@@ -39,13 +39,13 @@ public class ExtendActivityResourceTest { public void tearDown() throws Exception {}
/**
- * Test method for {@link org.onap.sdc.workflowdesigner.resources.ExtendActivityResource#retriveExtActivites(java.lang.String)}.
+ *
*/
@Test
public void testRetriveExtActivites() {
try {
String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME);
- ExtendActivity[] extActivities = JsonUtils.fromJson(json, ExtendActivity[].class);
+ ExtActivity[] extActivities = JsonUtils.fromJson(json, ExtActivity[].class);
FileCommonUtils.write("test.json", JsonUtils.toJson(extActivities));
assertEquals(extActivities.length == 0, false);
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java index a67adbeb..ba399644 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java @@ -45,7 +45,8 @@ public class WorkflowModelerResourceTest { public void tearDown() throws Exception {}
/**
- * Test method for {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#buildBPMN(java.net.URI, java.lang.String)}.
+ * Test method for
+ * {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#buildBPMN(java.net.URI, java.lang.String)}.
*/
@Test
public void testBuildBPMN() {
@@ -65,25 +66,25 @@ public class WorkflowModelerResourceTest { } catch (IOException e) {
} catch (Exception e) {
}
-// return null;
- // TODO for Nexus-IQ
- return " ";
+
+ return null;
}
-
+
/**
- * Test method for {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#insertJson2Bpmn(java.lang.String, java.lang.String)}.
+ * Test method for
+ * {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#insertJson2Bpmn(java.lang.String, java.lang.String)}.
*/
@Test
public void testInsertJson2Bpmn() {
String bpmn = parseBpmnfromJsonFile();
-
+
try {
String json = FileCommonUtils.readString("src/main/assembly/" + WORKFLOW_JSON_TEMP_FILE_NAME);
WorkflowModelerResource resource = new WorkflowModelerResource();
String combineBpmn = resource.insertJson2Bpmn(json, bpmn);
- String json1 = resource.readJsonfromBPMNFile(combineBpmn);
-
+ String json1 = resource.readJsonfromBPMN(combineBpmn);
+
assertEqualsJson(json, json1);
} catch (IOException e) {
} catch (DocumentException e) {
@@ -97,12 +98,12 @@ public class WorkflowModelerResourceTest { private void assertEqualsJson(String json, String json1) {
WorkflowInfo wi = JsonUtils.fromJson(json, WorkflowInfo.class);
WorkflowInfo wi1 = JsonUtils.fromJson(json1, WorkflowInfo.class);
-
+
String newJson = JsonUtils.toJson(wi);
String newJson1 = JsonUtils.toJson(wi1);
assertEquals(newJson1, newJson);
-
+
}
}
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);
+ }
}
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivityTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivityTest.java index e8fa1e75..0c16807a 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivityTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivityTest.java @@ -43,7 +43,7 @@ public class ExtendActivityTest { IconData icon = new IconData();
Content content = new Content();
- ExtendActivity ea = new ExtendActivity();
+ ExtActivity ea = new ExtActivity();
ea.setContent(content);
ea.setDescription(description);
ea.setDisplayName(displayName);
|