342b566c2d26aca46049d1a48f0f5d32d8663ff9
[sdc/sdc-workflow-designer.git] /
1 /**\r
2  * Copyright (c) 2017 ZTE Corporation.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the Apache License, Version 2.0\r
5  * and the Eclipse Public License v1.0 which both accompany this distribution,\r
6  * and are available at http://www.eclipse.org/legal/epl-v10.html\r
7  * and http://www.apache.org/licenses/LICENSE-2.0\r
8  *\r
9  * Contributors:\r
10  *     ZTE - initial API and implementation and/or initial documentation\r
11  */\r
12 package org.onap.sdc.workflowdesigner.planwriter;\r
13 \r
14 import static org.junit.Assert.assertEquals;\r
15 \r
16 import java.io.BufferedReader;\r
17 import java.io.File;\r
18 import java.io.FileReader;\r
19 import java.io.IOException;\r
20 \r
21 import org.junit.Test;\r
22 import org.onap.sdc.workflowdesigner.model.Process;\r
23 import org.onap.sdc.workflowdesigner.writer.BpmnPlanArtefactWriter;\r
24 \r
25 public class BpmnPlanArtefactWriterTest {\r
26 \r
27     @Test\r
28     public void testWritePlan() throws Exception {\r
29         BpmnPlanArtefactWriter writer = new BpmnPlanArtefactWriter(mockProcss());\r
30         String result = writer.completePlanTemplate();\r
31         assertEquals(result, getResult());\r
32     }\r
33 \r
34     private Process mockProcss() {\r
35         Process process = new Process("templateTest");\r
36 \r
37         return process;\r
38     }\r
39 \r
40     public String getResult() throws IOException {\r
41         StringBuffer buffer = new StringBuffer();\r
42 \r
43         String path = "src/test/resources/workflow/template-test.bpmn20.xml";\r
44         BufferedReader reader = new BufferedReader(new FileReader(new File(path)));\r
45 \r
46         String line = null;\r
47         while ((line = reader.readLine()) != null) {\r
48             buffer.append(line).append("\r\n");\r
49         }\r
50 \r
51         if (reader != null) {\r
52             reader.close();\r
53         }\r
54 \r
55         return buffer.toString();\r
56     }\r
57 \r
58 }\r