--- /dev/null
+[
+ {
+ "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
--- /dev/null
+{\r
+ "id":"id12345",\r
+ "name":"test",\r
+ "scene":"abcd",\r
+ "data":{\r
+ "nodes":[\r
+ {\r
+ "id":"node0",\r
+ "type":"startEvent",\r
+ "name":"开始",\r
+ "parentId":"root",\r
+ "position":{\r
+ "left":100,\r
+ "top":136,\r
+ "width":56,\r
+ "height":56\r
+ },\r
+ "connection":[\r
+ {\r
+ "sourceRef":"node0",\r
+ "targetRef":"node1"\r
+ }\r
+ ],\r
+ "parameters":[\r
+\r
+ ]\r
+ },\r
+ {\r
+ "id":"node1",\r
+ "type":"restTask",\r
+ "name":"REST",\r
+ "parentId":"root",\r
+ "position":{\r
+ "left":254,\r
+ "top":136,\r
+ "width":56,\r
+ "height":56\r
+ },\r
+ "connection":[\r
+ {\r
+ "sourceRef":"node1",\r
+ "targetRef":"node2"\r
+ }\r
+ ],\r
+ "produces":[\r
+ "application/json; charset=utf-8"\r
+ ],\r
+ "parameters":[\r
+ {\r
+ "name":"body",\r
+ "value":{\r
+ "value":{\r
+ "type":{\r
+ "value":"jhgjhv",\r
+ "valueSource":"String"\r
+ },\r
+ "provider":{\r
+ "value":"",\r
+ "valueSource":"Variable"\r
+ },\r
+ "serviceType":{\r
+ "value":"",\r
+ "valueSource":"String"\r
+ },\r
+ "start":{\r
+ "value":{\r
+ "year":{\r
+ "value":"",\r
+ "valueSource":"String"\r
+ },\r
+ "month":{\r
+ "value":"",\r
+ "valueSource":"String"\r
+ },\r
+ "day":{\r
+ "value":"",\r
+ "valueSource":"String"\r
+ }\r
+ },\r
+ "valueSource":"Definition"\r
+ },\r
+ "end":{\r
+ "value":{\r
+ "year":{\r
+ "value":"",\r
+ "valueSource":"String"\r
+ },\r
+ "month":{\r
+ "value":"",\r
+ "valueSource":"String"\r
+ },\r
+ "day":{\r
+ "value":"",\r
+ "valueSource":"String"\r
+ }\r
+ },\r
+ "valueSource":"Definition"\r
+ }\r
+ },\r
+ "valueSource":"Definition"\r
+ },\r
+ "valueSource":"String",\r
+ "type":"String",\r
+ "required":false,\r
+ "position":"body",\r
+ "schema":{\r
+ "$ref":"#/definitions/PackageQueryParams"\r
+ }\r
+ },\r
+ {\r
+ "name":"language-option",\r
+ "value":"",\r
+ "valueSource":"String",\r
+ "type":"String",\r
+ "required":false,\r
+ "position":"header"\r
+ }\r
+ ],\r
+ "responses":[\r
+\r
+ ],\r
+ "restConfigId":"catalog.v1",\r
+ "path":"/csars",\r
+ "method":"post"\r
+ },\r
+ {\r
+ "id":"node2",\r
+ "type":"endEvent",\r
+ "name":"结束",\r
+ "parentId":"root",\r
+ "position":{\r
+ "left":396,\r
+ "top":136,\r
+ "width":56,\r
+ "height":56\r
+ },\r
+ "connection":[\r
+\r
+ ]\r
+ }\r
+ ]\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright (c) 2018 ZTE Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
+ * and are available at http://www.eclipse.org/legal/epl-v10.html\r
+ * and http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Contributors:\r
+ * ZTE - initial API and implementation and/or initial documentation\r
+ */\r
+package org.onap.sdc.workflowdesigner.resources;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import java.io.IOException;\r
+import java.net.URI;\r
+import java.nio.file.Paths;\r
+import java.util.UUID;\r
+\r
+import org.dom4j.DocumentException;\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo;\r
+import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;\r
+import org.onap.sdc.workflowdesigner.utils.JsonUtils;\r
+\r
+/**\r
+ *\r
+ */\r
+public class WorkflowModelerResourceTest {\r
+ private static final String WORKFLOW_JSON_TEMP_FILE_NAME = "temp_workflow.json";\r
+\r
+ /**\r
+ * @throws java.lang.Exception\r
+ */\r
+ @Before\r
+ public void setUp() throws Exception {}\r
+\r
+ /**\r
+ * @throws java.lang.Exception\r
+ */\r
+ @After\r
+ public void tearDown() throws Exception {}\r
+\r
+ /**\r
+ * Test method for {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#buildBPMN(java.net.URI, java.lang.String)}.\r
+ */\r
+ @Test\r
+ public void testBuildBPMN() {\r
+ String bpmn = parseBpmnfromJsonFile();\r
+ assertEquals(false, bpmn.isEmpty());\r
+ }\r
+\r
+ /**\r
+ * @return\r
+ */\r
+ private String parseBpmnfromJsonFile() {\r
+ try {\r
+ URI srcUri = Paths.get("src/main/assembly", WORKFLOW_JSON_TEMP_FILE_NAME).toUri();\r
+ WorkflowModelerResource resource = new WorkflowModelerResource();\r
+ String processName = "plan_" + UUID.randomUUID().toString();\r
+ return resource.buildBPMN(srcUri, processName);\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ /**\r
+ * Test method for {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#insertJson2Bpmn(java.lang.String, java.lang.String)}.\r
+ */\r
+ @Test\r
+ public void testInsertJson2Bpmn() {\r
+ String bpmn = parseBpmnfromJsonFile();\r
+ \r
+ try {\r
+ String json = FileCommonUtils.readString("src/main/assembly/" + WORKFLOW_JSON_TEMP_FILE_NAME);\r
+ WorkflowModelerResource resource = new WorkflowModelerResource();\r
+ String combineBpmn = resource.insertJson2Bpmn(json, bpmn);\r
+\r
+ String json1 = resource.readJsonfromBPMNFile(combineBpmn);\r
+ \r
+ assertEqualsJson(json, json1);\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ } catch (DocumentException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @param json\r
+ * @param json1\r
+ */\r
+ private void assertEqualsJson(String json, String json1) {\r
+ WorkflowInfo wi = JsonUtils.fromJson(json, WorkflowInfo.class);\r
+ WorkflowInfo wi1 = JsonUtils.fromJson(json1, WorkflowInfo.class);\r
+ \r
+ String newJson = JsonUtils.toJson(wi);\r
+ String newJson1 = JsonUtils.toJson(wi1);\r
+\r
+ assertEquals(newJson1, newJson);\r
+ \r
+ }\r
+\r
+}\r