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