-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from valb3r/bugfix/FBP-233-documentation-elem…
…ent-formatting Bugfix/fbp 233 documentation element formatting
- Loading branch information
Showing
13 changed files
with
462 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
.../com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventDocumentationFormatTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.valb3r.bpmn.intellij.plugin.activiti.parser | ||
|
||
import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BpmnElementRemovedEvent | ||
import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BpmnShapeObjectAddedEvent | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.BoundsElement | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.EventPropagatableToXml | ||
import org.amshove.kluent.shouldBeEqualTo | ||
import org.amshove.kluent.shouldNotBeNull | ||
import org.junit.jupiter.api.Test | ||
|
||
class XmlUpdateEventDocumentationFormatTest { | ||
|
||
private val startEventId = "startevent1" | ||
private val parentProcess = BpmnElementId("m40191.SBWS-CallActivity-PdfGenerator-MapParameter") | ||
private val documentationProcessName = "documentation-element-formatting.bpmn20.xml" | ||
|
||
private val parser = ActivitiParser() | ||
|
||
@Test | ||
fun `Parsing respects newline formatting`() { | ||
val originalProcess = documentationProcessName.asResource()!! | ||
val updated = parser.update(documentationProcessName.asResource()!!, listOf()) | ||
updated.count { it == '\n' }.shouldBeEqualTo(originalProcess.count { it == '\n' } + 1) | ||
} | ||
|
||
@Test | ||
fun `New element is added with new line`() { | ||
val originalProcess = documentationProcessName.asResource()!! | ||
val testId = BpmnElementId("test") | ||
val updated = parser.update( | ||
documentationProcessName.asResource()!!, listOf( | ||
BpmnShapeObjectAddedEvent( | ||
WithParentId( | ||
parentProcess, | ||
BpmnServiceTask( | ||
testId, | ||
"test", | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
) | ||
), | ||
ShapeElement(DiagramElementId("id"), testId, BoundsElement(0.0f, 0.0f, 0.0f, 0.0f)), | ||
emptyMap() | ||
) | ||
) | ||
) | ||
|
||
updated.count { it == '\n' }.shouldBeEqualTo(originalProcess.count { it == '\n' } + 5) // Shape + Diagram \n | ||
} | ||
|
||
@Test | ||
fun `Removing element does not break 'documentation' element formatting`() { | ||
val originalProcess = readProcess() | ||
val updatedProcess = readAndUpdateProcess(BpmnElementRemovedEvent(BpmnElementId(startEventId))) | ||
updatedProcess.process.body!!.scriptTask!![0].documentation | ||
.shouldBeEqualTo(originalProcess.process.body!!.scriptTask!![0].documentation) | ||
} | ||
|
||
private fun readProcess(): BpmnProcessObject { | ||
val process = parser.parse(documentationProcessName.asResource()!!) | ||
process.shouldNotBeNull() | ||
return process | ||
} | ||
|
||
private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnProcessObject { | ||
val updated = parser.update( | ||
documentationProcessName.asResource()!!, | ||
listOf(event) | ||
) | ||
|
||
updated.shouldNotBeNull() | ||
|
||
return parser.parse(updated) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
activiti-xml-parser/src/test/resources/documentation-element-formatting.bpmn20.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="ELEKTRONISCHER_ANTRAG"> | ||
<process id="m40191.SBWS-CallActivity-PdfGenerator-MapParameter" name="SBWS-CallActivity-PdfGenerator-Map-Parameter" isExecutable="true"> | ||
<startEvent id="startevent1" name="Start"></startEvent> | ||
<scriptTask id="sid-0152746A-45A2-485C-B831-B05EF4B71BC8" name="Evaluate Map" scriptFormat="groovy" activiti:autoStoreVariables="false"> | ||
<documentation>Subprocess to evaluate an incoming map. | ||
|
||
In: | ||
testMap - to be passed in by caller</documentation> | ||
<script><![CDATA[log = org.slf4j.LoggerFactory.getLogger("com.example.EvaluateMap"); | ||
def map= execution.getVariable("testMap") | ||
log.info(map) | ||
log.info("${testMap}")]]></script> | ||
</scriptTask> | ||
<sequenceFlow id="sid-76A2706A-8FF4-4CF4-8EFE-15494A17A256" sourceRef="startevent1" targetRef="sid-0152746A-45A2-485C-B831-B05EF4B71BC8"></sequenceFlow> | ||
<endEvent id="sid-85B92D35-1ACD-49D3-83F0-F5C63CD1ECA9"></endEvent> | ||
<sequenceFlow id="sid-6F09B97C-576A-4157-B5C7-97F870886832" sourceRef="sid-0152746A-45A2-485C-B831-B05EF4B71BC8" targetRef="sid-85B92D35-1ACD-49D3-83F0-F5C63CD1ECA9"></sequenceFlow> | ||
</process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_m40191.SBWS-CallActivity-PdfGenerator-MapParameter"> | ||
<bpmndi:BPMNPlane bpmnElement="m40191.SBWS-CallActivity-PdfGenerator-MapParameter" id="BPMNPlane_m40191.SBWS-CallActivity-PdfGenerator-MapParameter"> | ||
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1"> | ||
<omgdc:Bounds height="30.0" width="30.0" x="142.0" y="85.0"></omgdc:Bounds> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape bpmnElement="sid-0152746A-45A2-485C-B831-B05EF4B71BC8" id="BPMNShape_sid-0152746A-45A2-485C-B831-B05EF4B71BC8"> | ||
<omgdc:Bounds height="80.0" width="100.0" x="255.0" y="60.0"></omgdc:Bounds> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape bpmnElement="sid-85B92D35-1ACD-49D3-83F0-F5C63CD1ECA9" id="BPMNShape_sid-85B92D35-1ACD-49D3-83F0-F5C63CD1ECA9"> | ||
<omgdc:Bounds height="28.0" width="28.0" x="400.0" y="86.0"></omgdc:Bounds> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNEdge bpmnElement="sid-6F09B97C-576A-4157-B5C7-97F870886832" id="BPMNEdge_sid-6F09B97C-576A-4157-B5C7-97F870886832"> | ||
<omgdi:waypoint x="355.0" y="100.0"></omgdi:waypoint> | ||
<omgdi:waypoint x="400.0" y="100.0"></omgdi:waypoint> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge bpmnElement="sid-76A2706A-8FF4-4CF4-8EFE-15494A17A256" id="BPMNEdge_sid-76A2706A-8FF4-4CF4-8EFE-15494A17A256"> | ||
<omgdi:waypoint x="172.0" y="100.0"></omgdi:waypoint> | ||
<omgdi:waypoint x="255.0" y="100.0"></omgdi:waypoint> | ||
</bpmndi:BPMNEdge> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
.../com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlUpdateEventDocumentationFormatTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.valb3r.bpmn.intellij.plugin.flowable.parser | ||
|
||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.BoundsElement | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement | ||
import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.EventPropagatableToXml | ||
import com.valb3r.bpmn.intellij.plugin.flowable.parser.testevents.BpmnElementRemovedEvent | ||
import com.valb3r.bpmn.intellij.plugin.flowable.parser.testevents.BpmnShapeObjectAddedEvent | ||
import org.amshove.kluent.shouldBeEqualTo | ||
import org.amshove.kluent.shouldNotBeNull | ||
import org.junit.jupiter.api.Test | ||
|
||
class XmlUpdateEventDocumentationFormatTest { | ||
|
||
private val startEventId = "startevent1" | ||
private val parentProcess = BpmnElementId("m40191.SBWS-CallActivity-PdfGenerator-MapParameter") | ||
private val documentationProcessName = "documentation-element-formatting.bpmn20.xml" | ||
|
||
private val parser = FlowableParser() | ||
|
||
@Test | ||
fun `Parsing respects newline formatting`() { | ||
val originalProcess = documentationProcessName.asResource()!! | ||
val updated = parser.update(documentationProcessName.asResource()!!, listOf()) | ||
updated.count { it == '\n' }.shouldBeEqualTo(originalProcess.count { it == '\n' } + 1) | ||
} | ||
|
||
@Test | ||
fun `New element is added with new line`() { | ||
val originalProcess = documentationProcessName.asResource()!! | ||
val testId = BpmnElementId("test") | ||
val updated = parser.update( | ||
documentationProcessName.asResource()!!, listOf( | ||
BpmnShapeObjectAddedEvent( | ||
WithParentId( | ||
parentProcess, | ||
BpmnServiceTask( | ||
testId, | ||
"test", | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
) | ||
), | ||
ShapeElement(DiagramElementId("id"), testId, BoundsElement(0.0f, 0.0f, 0.0f, 0.0f)), | ||
emptyMap() | ||
) | ||
) | ||
) | ||
|
||
updated.count { it == '\n' }.shouldBeEqualTo(originalProcess.count { it == '\n' } + 5) // Shape + Diagram \n | ||
} | ||
|
||
@Test | ||
fun `Removing element does not break 'documentation' element formatting`() { | ||
val originalProcess = readProcess() | ||
val updatedProcess = readAndUpdateProcess(BpmnElementRemovedEvent(BpmnElementId(startEventId))) | ||
updatedProcess.process.body!!.scriptTask!![0].documentation | ||
.shouldBeEqualTo(originalProcess.process.body!!.scriptTask!![0].documentation) | ||
} | ||
|
||
private fun readProcess(): BpmnProcessObject { | ||
val process = parser.parse(documentationProcessName.asResource()!!) | ||
process.shouldNotBeNull() | ||
return process | ||
} | ||
|
||
private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnProcessObject { | ||
val updated = parser.update( | ||
documentationProcessName.asResource()!!, | ||
listOf(event) | ||
) | ||
|
||
updated.shouldNotBeNull() | ||
|
||
return parser.parse(updated) | ||
} | ||
} |
Oops, something went wrong.