|
| 1 | +/* |
| 2 | + * Copyright 2020-Present The Serverless Workflow Specification Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package io.serverlessworkflow.diagram.test; |
| 17 | + |
| 18 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 19 | + |
| 20 | +import io.serverlessworkflow.api.Workflow; |
| 21 | +import io.serverlessworkflow.api.interfaces.WorkflowDiagram; |
| 22 | +import io.serverlessworkflow.diagram.WorkflowDiagramImpl; |
| 23 | +import io.serverlessworkflow.diagram.test.utils.DiagramTestUtils; |
| 24 | +import org.junit.jupiter.api.Assertions; |
| 25 | +import org.junit.jupiter.params.ParameterizedTest; |
| 26 | +import org.junit.jupiter.params.provider.ValueSource; |
| 27 | + |
| 28 | +public class CustomTemplateWorkflowDiagramTest { |
| 29 | + |
| 30 | + @ParameterizedTest |
| 31 | + @ValueSource(strings = {"/examples/applicantrequest.json", "/examples/applicantrequest.yml"}) |
| 32 | + public void testSpecExamplesParsing(String workflowLocation) throws Exception { |
| 33 | + |
| 34 | + Workflow workflow = Workflow.fromSource(DiagramTestUtils.readWorkflowFile(workflowLocation)); |
| 35 | + |
| 36 | + assertNotNull(workflow); |
| 37 | + assertNotNull(workflow.getId()); |
| 38 | + assertNotNull(workflow.getName()); |
| 39 | + assertNotNull(workflow.getStates()); |
| 40 | + |
| 41 | + WorkflowDiagram workflowDiagram = |
| 42 | + new WorkflowDiagramImpl().setWorkflow(workflow).setTemplate("custom-template"); |
| 43 | + |
| 44 | + String diagramSVG = workflowDiagram.getSvgDiagram(); |
| 45 | + |
| 46 | + Assertions.assertNotNull(diagramSVG); |
| 47 | + // custom template uses #0000FF as start node color |
| 48 | + Assertions.assertTrue(diagramSVG.contains("#0000FF")); |
| 49 | + } |
| 50 | +} |
0 commit comments