diff options
6 files changed, 662 insertions, 2 deletions
diff --git a/sdc-workflow-designer-server/src/main/assembly/ext-activities-display-info.json b/sdc-workflow-designer-server/src/main/assembly/ext-activities-display-info.json new file mode 100644 index 00000000..d6817db2 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/assembly/ext-activities-display-info.json @@ -0,0 +1,45 @@ +{ + "nodes": { + "apds_script": {}, + "apds_service": {}, + "apds_rest": {}, + "apds_scriptA": { + "category": "aaa" + }, + "apds_scriptB": { + "category": "aaa" + }, + "apds_serviceA": { + "category": "bbb" + }, + "apds_restA": { + "category": "ccc" + }, + "apds_restB": { + "category": "ccc" + } + }, + "categoryData": { + "aaa": { + "displayName": { + "zh_CN": "扩展脚本任务", + "en_US": "Extension Script Task" + }, + "collapse": true + }, + "bbb": { + "displayName": { + "zh_CN": "扩展Service任务", + "en_US": "Extension Service Task" + }, + "collapse": true + }, + "ccc": { + "displayName": { + "zh_CN": "扩展REST任务", + "en_US": "Extension REST Service Task" + }, + "collapse": true + } + } +}
\ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/assembly/ext-activities.json b/sdc-workflow-designer-server/src/main/assembly/ext-activities.json new file mode 100644 index 00000000..eae58fce --- /dev/null +++ b/sdc-workflow-designer-server/src/main/assembly/ext-activities.json @@ -0,0 +1,362 @@ +[ + { + "id": "apds_service", + "displayName": { + "zh_CN": "Service", + "en_US": "Service" + }, + "description": { + "zh_CN": "JAVA 节点", + "en_US": "JAVA Node" + }, + "type": "serviceTask", + "icon": { + "name": "apds_service", + "width": 56, + "height": 56 + }, + "content": { + "class": "", + "inputs": {} + } + }, + { + "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": "默认脚本", + "en_US": "Script" + }, + "description": { + "zh_CN": "脚本节点", + "en_US": "Script Node" + }, + "type": "scriptTask", + "icon": { + "name": "apds_script", + "width": 56, + "height": 56 + }, + "content": { + "scriptFormat": "", + "script": "" + } + }, + { + "id": "apds_scriptA", + "displayName": { + "zh_CN": "JavaScript", + "en_US": "JavaScript" + }, + "description": { + "zh_CN": "脚本节点", + "en_US": "Script Node" + }, + "type": "scriptTask", + "icon": { + "name": "apds_script", + "width": 56, + "height": 56 + }, + "content": { + "scriptFormat": "JavaScript", + "script": "abc" + } + }, + { + "id": "apds_scriptB", + "displayName": { + "zh_CN": "Groovy", + "en_US": "Groovy" + }, + "description": { + "zh_CN": "脚本节点", + "en_US": "Script Node" + }, + "type": "scriptTask", + "icon": { + "name": "apds_script", + "width": 56, + "height": 56 + }, + "content": { + "scriptFormat": "Groovy", + "script": "xyz" + } + }, + { + "id": "apds_serviceA", + "displayName": { + "zh_CN": "JAVA A", + "en_US": "JAVA A" + }, + "description": { + "zh_CN": "JAVA 节点", + "en_US": "JAVA Node" + }, + "type": "serviceTask", + "icon": { + "name": "apds_service", + "width": 56, + "height": 56 + }, + "content": { + "class": "com.zte.ums.workflow.activitiext.restservicetask.HttpUtil", + "inputs": { + "param1": { + "type": "string", + "default": "default", + "required": false, + "displayName": { + "zh_CN": "参数1", + "en_US": "Param1" + }, + "show": false, + "editable": true + }, + "param2": { + "type": "string", + "required": true, + "displayName": { + "zh_CN": "参数2", + "en_US": "Param2" + }, + "show": true, + "editable": true + }, + "param3": { + "type": "string", + "default": "value3", + "required": true, + "displayName": { + "zh_CN": "参数3", + "en_US": "Param3" + }, + "show": true, + "editable": false + } + }, + "outputs": { + "out1": { + "type": "string", + "required": false, + "displayName": { + "zh_CN": "输出1", + "en_US": "Output Param 1" + }, + "show": true, + "editable": true + } + } + } + }, + { + "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", + "displayName": { + "zh_CN": "REST复杂参数", + "en_US": "REST Complex Parameters" + }, + "description": { + "zh_CN": "REST复杂参数", + "en_US": "REST Complex Parameters" + }, + "type": "restTask", + "icon": { + "name": "apds_rest", + "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", + "inputs": { + "param1": { + "in": "query", + "type": "string", + "default": "default", + "required": false, + "show": false, + "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" + } + } + } + }, + "required": true, + "show": true, + "editable": true + }, + "param3": { + "in": "path", + "type": "string", + "default": "value3", + "required": true, + "show": true, + "editable": false + } + }, + "outputs": { + "body": { + "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" + } + } + } + }, + "editable": false + } + } + } + } +]
\ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/assembly/temp_workflow.json b/sdc-workflow-designer-server/src/main/assembly/temp_workflow.json new file mode 100644 index 00000000..1b44d91e --- /dev/null +++ b/sdc-workflow-designer-server/src/main/assembly/temp_workflow.json @@ -0,0 +1,143 @@ +{
+ "id":"id12345",
+ "name":"test",
+ "scene":"abcd",
+ "data":{
+ "nodes":[
+ {
+ "id":"node0",
+ "type":"startEvent",
+ "name":"开始",
+ "parentId":"root",
+ "position":{
+ "left":100,
+ "top":136,
+ "width":56,
+ "height":56
+ },
+ "connection":[
+ {
+ "sourceRef":"node0",
+ "targetRef":"node1"
+ }
+ ],
+ "parameters":[
+
+ ]
+ },
+ {
+ "id":"node1",
+ "type":"restTask",
+ "name":"REST",
+ "parentId":"root",
+ "position":{
+ "left":254,
+ "top":136,
+ "width":56,
+ "height":56
+ },
+ "connection":[
+ {
+ "sourceRef":"node1",
+ "targetRef":"node2"
+ }
+ ],
+ "produces":[
+ "application/json; charset=utf-8"
+ ],
+ "parameters":[
+ {
+ "name":"body",
+ "value":{
+ "value":{
+ "type":{
+ "value":"jhgjhv",
+ "valueSource":"String"
+ },
+ "provider":{
+ "value":"",
+ "valueSource":"Variable"
+ },
+ "serviceType":{
+ "value":"",
+ "valueSource":"String"
+ },
+ "start":{
+ "value":{
+ "year":{
+ "value":"",
+ "valueSource":"String"
+ },
+ "month":{
+ "value":"",
+ "valueSource":"String"
+ },
+ "day":{
+ "value":"",
+ "valueSource":"String"
+ }
+ },
+ "valueSource":"Definition"
+ },
+ "end":{
+ "value":{
+ "year":{
+ "value":"",
+ "valueSource":"String"
+ },
+ "month":{
+ "value":"",
+ "valueSource":"String"
+ },
+ "day":{
+ "value":"",
+ "valueSource":"String"
+ }
+ },
+ "valueSource":"Definition"
+ }
+ },
+ "valueSource":"Definition"
+ },
+ "valueSource":"String",
+ "type":"String",
+ "required":false,
+ "position":"body",
+ "schema":{
+ "$ref":"#/definitions/PackageQueryParams"
+ }
+ },
+ {
+ "name":"language-option",
+ "value":"",
+ "valueSource":"String",
+ "type":"String",
+ "required":false,
+ "position":"header"
+ }
+ ],
+ "responses":[
+
+ ],
+ "restConfigId":"catalog.v1",
+ "path":"/csars",
+ "method":"post"
+ },
+ {
+ "id":"node2",
+ "type":"endEvent",
+ "name":"结束",
+ "parentId":"root",
+ "position":{
+ "left":396,
+ "top":136,
+ "width":56,
+ "height":56
+ },
+ "connection":[
+
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file 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 060008b3..899e2ee9 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 @@ -24,7 +24,7 @@ import org.onap.sdc.workflowdesigner.utils.JsonUtils; *
*/
public class ExtendActivityResourceTest {
- private static final String EXT_ACTIVITIES_FILE_NAME = "..\\distribution\\src\\main\\assembly\\ext-activities.json";
+ private static final String EXT_ACTIVITIES_FILE_NAME = "src/main/assembly/ext-activities.json";
/**
* @throws java.lang.Exception
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 new file mode 100644 index 00000000..f91a42bb --- /dev/null +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java @@ -0,0 +1,110 @@ +/**
+ * 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.resources;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Paths;
+import java.util.UUID;
+
+import org.dom4j.DocumentException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo;
+import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
+import org.onap.sdc.workflowdesigner.utils.JsonUtils;
+
+/**
+ *
+ */
+public class WorkflowModelerResourceTest {
+ private static final String WORKFLOW_JSON_TEMP_FILE_NAME = "temp_workflow.json";
+
+ /**
+ * @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.resources.WorkflowModelerResource#buildBPMN(java.net.URI, java.lang.String)}.
+ */
+ @Test
+ public void testBuildBPMN() {
+ String bpmn = parseBpmnfromJsonFile();
+ assertEquals(false, bpmn.isEmpty());
+ }
+
+ /**
+ * @return
+ */
+ private String parseBpmnfromJsonFile() {
+ try {
+ URI srcUri = Paths.get("src/main/assembly", WORKFLOW_JSON_TEMP_FILE_NAME).toUri();
+ WorkflowModelerResource resource = new WorkflowModelerResource();
+ String processName = "plan_" + UUID.randomUUID().toString();
+ return resource.buildBPMN(srcUri, processName);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 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);
+
+ assertEqualsJson(json, json1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (DocumentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @param json
+ * @param json1
+ */
+ 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/utils/FileCommonUtilsTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java index a9770de0..39065056 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java @@ -56,7 +56,7 @@ public class FileCommonUtilsTest { */
@Test
public void testReadStringString() {
- String fileName = "src\\test\\resources\\workflow\\template-test.bpmn20.xml";
+ String fileName = "src/test/resources/workflow/template-test.bpmn20.xml";
File file = new File(fileName);
if (file.exists()) {
try {
|