|
| 1 | +/* Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | + * you may not use this file except in compliance with the License. |
| 3 | + * You may obtain a copy of the License at |
| 4 | + * |
| 5 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | + * |
| 7 | + * Unless required by applicable law or agreed to in writing, software |
| 8 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | + * See the License for the specific language governing permissions and |
| 11 | + * limitations under the License. |
| 12 | + */ |
| 13 | +package org.flowable.editor.language.xml; |
| 14 | + |
| 15 | +import static org.assertj.core.api.Assertions.assertThat; |
| 16 | +import static org.flowable.bpmn.constants.BpmnXMLConstants.ATTRIBUTE_ELEMENT_NAME; |
| 17 | + |
| 18 | +import org.flowable.bpmn.model.BpmnModel; |
| 19 | +import org.flowable.bpmn.model.ExtensionElement; |
| 20 | +import org.flowable.bpmn.model.FlowElement; |
| 21 | +import org.flowable.bpmn.model.SubProcess; |
| 22 | +import org.flowable.editor.language.xml.util.BpmnXmlConverterTest; |
| 23 | + |
| 24 | +class NameWithNewLineTest { |
| 25 | + |
| 26 | + @BpmnXmlConverterTest("nameWithNewLineTestProcess.bpmn") |
| 27 | + void validateModel(BpmnModel model) { |
| 28 | + FlowElement flowElement = model.getMainProcess().getFlowElement("startnoneevent1"); |
| 29 | + assertThat(flowElement.getName()).isEqualTo("start\nevent"); |
| 30 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 31 | + |
| 32 | + flowElement = model.getMainProcess().getFlowElement("bpmnCatchEvent_12"); |
| 33 | + assertThat(flowElement.getName()).isEqualTo("intermediate\nevent"); |
| 34 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 35 | + |
| 36 | + flowElement = model.getMainProcess().getFlowElement("bpmnGateway_14"); |
| 37 | + assertThat(flowElement.getName()).isEqualTo("gate\nway"); |
| 38 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 39 | + |
| 40 | + flowElement = model.getMainProcess().getFlowElement("bpmnEndEvent_3"); |
| 41 | + assertThat(flowElement.getName()).isEqualTo("end\nevent"); |
| 42 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 43 | + |
| 44 | + SubProcess subProcess = (SubProcess) model.getMainProcess().getFlowElement("bpmnStructure_1"); |
| 45 | + assertThat(subProcess.getName()).isEqualTo("sub\nprocess"); |
| 46 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 47 | + |
| 48 | + flowElement = subProcess.getFlowElement("bpmnTask_5"); |
| 49 | + assertThat(flowElement.getName()).isEqualTo("user\ntask"); |
| 50 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 51 | + |
| 52 | + flowElement = subProcess.getFlowElement("bpmnBoundaryEvent_10"); |
| 53 | + assertThat(flowElement.getName()).isEqualTo("boundary\nevent"); |
| 54 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 55 | + } |
| 56 | + |
| 57 | + @BpmnXmlConverterTest("nameWithoutNewLineTestProcess.bpmn") |
| 58 | + void validateModelWithoutNewLines(BpmnModel model) { |
| 59 | + FlowElement flowElement = model.getMainProcess().getFlowElement("startnoneevent1"); |
| 60 | + assertThat(flowElement.getName()).isEqualTo("startevent"); |
| 61 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 62 | + |
| 63 | + flowElement = model.getMainProcess().getFlowElement("bpmnCatchEvent_12"); |
| 64 | + assertThat(flowElement.getName()).isEqualTo("intermediateevent"); |
| 65 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 66 | + |
| 67 | + flowElement = model.getMainProcess().getFlowElement("bpmnGateway_14"); |
| 68 | + assertThat(flowElement.getName()).isEqualTo("gateway"); |
| 69 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 70 | + |
| 71 | + flowElement = model.getMainProcess().getFlowElement("bpmnEndEvent_3"); |
| 72 | + assertThat(flowElement.getName()).isEqualTo("endevent"); |
| 73 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 74 | + |
| 75 | + SubProcess subProcess = (SubProcess) model.getMainProcess().getFlowElement("bpmnStructure_1"); |
| 76 | + assertThat(subProcess.getName()).isEqualTo("subprocess"); |
| 77 | + assertThat(subProcess.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 78 | + |
| 79 | + flowElement = subProcess.getFlowElement("bpmnTask_5"); |
| 80 | + assertThat(flowElement.getName()).isEqualTo("usertask"); |
| 81 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 82 | + |
| 83 | + flowElement = subProcess.getFlowElement("bpmnBoundaryEvent_10"); |
| 84 | + assertThat(flowElement.getName()).isEqualTo("boundaryevent"); |
| 85 | + assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); |
| 86 | + } |
| 87 | +} |
0 commit comments