Add unit test for bpmn workflow converter
Issue-ID: SDC-404
Change-Id: Ie6f897f06b0e759992d3ba6e65c719a84a40f143
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/convert/BPMN4Tosca2BpmnTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/convert/BPMN4Tosca2BpmnTest.java
new file mode 100644
index 0000000..fc423a1
--- /dev/null
+++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/convert/BPMN4Tosca2BpmnTest.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.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.convert;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URI;
+import java.nio.file.Paths;
+
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.junit.Test;
+import org.onap.sdc.workflowdesigner.converter.Bpmn4Tosca2Bpmn;
+
+public class BPMN4Tosca2BpmnTest {
+ private static String RESOURCES_DIR = "src/test/resources/workflow";
+
+ @Test
+ public void testTransform() throws ResourceNotFoundException, ParseErrorException, Exception {
+
+ URI srcUri = Paths.get(RESOURCES_DIR, "workflow.json").toUri();
+ URI targetUri = Paths.get(RESOURCES_DIR, "bpmnworkflow.bpmn20.xml").toUri();
+ BPMN4Tosca2BpmnTest.class.getResource(".");
+ Bpmn4Tosca2Bpmn transformer = new Bpmn4Tosca2Bpmn();
+ transformer.transform("transformTest", srcUri, targetUri);
+ assertTrue(new File(targetUri.getPath()).exists());
+ }
+
+}
diff --git a/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json b/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json
new file mode 100644
index 0000000..4799fc9
--- /dev/null
+++ b/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json
@@ -0,0 +1,17 @@
+{"nodes":[
+ {
+ "sequenceFlows":[
+ {"condition":"","sourceRef":"node0","targetRef":"node1"},
+ {"condition":"","sourceRef":"node0","targetRef":"node3"}
+ ],
+ "parameters":[],"id":"node0","name":"startEvent","type":"startEvent","parentId":"root",
+ "position":{"width":30,"height":30,"left":468,"top":55}
+ },
+ {
+ "sequenceFlows":[{"condition":"","sourceRef":"node1","targetRef":"node2"}],
+ "input":[],"output":[],"template":{},"id":"node1","name":"endEvent",
+ "type":"endEvent","parentId":"root",
+ "position":{"width":252.08334350585938,"height":46.66666793823242,"left":432,"top":167}
+ }],
+"configs":{"restConfigs":[]}
+}
\ No newline at end of file