Skip to content

Commit

Permalink
improved handling of ISO repeatable date and time expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
mswiderski committed Nov 29, 2021
1 parent a50b950 commit a458ebf
Show file tree
Hide file tree
Showing 5 changed files with 421 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,32 @@ public void testEventSignalSubProcessWithVersionedData() throws Exception {
processInstance.abort();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}

@Test
public void testEventTimerCycleISOSubProcess() throws Exception {

Application app = generateCodeProcessesOnly("event-subprocess/EventSubprocessTimerCycle.bpmn2");
assertThat(app).isNotNull();

NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("start-sub", 2);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);

Process<? extends Model> p = app.processes().processById("EventSubprocessTimer_1");

Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);

ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();

assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);

boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();

processInstance.abort();

assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:java="http://www.java.com/javaTypes" xmlns:tns="https://automatiko.io" xmlns="https://automatiko.io" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd https://automatiko.io automatiko.xsd" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="2.0.0" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="https://automatiko.io" typeLanguage="http://www.java.com/javaTypes">
<bpmn2:process id="EventSubprocessTimer" tns:version="1" tns:packageName="defaultPackage" name="Default Process" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1" name="start">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[start]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:sequenceFlow id="SequenceFlow_1" tns:priority="1" sourceRef="UserTask_1" targetRef="EndEvent_1"/>
<bpmn2:endEvent id="EndEvent_1" name="end">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[end]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:userTask id="UserTask_1" name="User Task 1">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[User Task 1]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_2" tns:priority="1" name="" sourceRef="StartEvent_1" targetRef="UserTask_1"/>
<bpmn2:subProcess id="SubProcess_1" name="Sub Process 1" triggeredByEvent="true">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[Sub Process 1]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:startEvent id="StartEvent_2" name="start-sub" isInterrupting="false">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[start-sub]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
<bpmn2:timerEventDefinition id="TimerEventDefinition_2">
<bpmn2:timeCycle xsi:type="bpmn2:tFormalExpression" id="FormalExpression_1">#{timer:R/PT2S}</bpmn2:timeCycle>
</bpmn2:timerEventDefinition>
</bpmn2:startEvent>
<bpmn2:scriptTask id="ScriptTask_1" name="Script Task 1">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[Script Task 1]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
<bpmn2:script>System.out.println(&quot;Event sub process triggered &quot; + new java.util.Date());</bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_3" tns:priority="1" sourceRef="StartEvent_2" targetRef="ScriptTask_1"/>
<bpmn2:endEvent id="EndEvent_2" name="end-sub">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[end-sub]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_4" tns:priority="1" sourceRef="ScriptTask_1" targetRef="EndEvent_2"/>
</bpmn2:subProcess>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="Default Process Diagram">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="EventSubprocessTimer">
<bpmndi:BPMNShape id="BPMNShape_SubProcess_1" bpmnElement="SubProcess_1" isExpanded="true">
<dc:Bounds height="131.0" width="381.0" x="171.0" y="210.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_1">
<dc:Bounds height="11.0" width="59.0" x="177.0" y="213.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_1" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="91.0" y="70.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_2" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="11.0" width="18.0" x="100.0" y="106.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_2" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="491.0" y="70.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_3" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="11.0" width="16.0" x="501.0" y="106.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_UserTask_1" bpmnElement="UserTask_1">
<dc:Bounds height="50.0" width="110.0" x="261.0" y="63.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_4">
<dc:Bounds height="11.0" width="48.0" x="292.0" y="82.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="StartEvent_2">
<dc:Bounds height="36.0" width="36.0" x="223.0" y="257.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_5" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="11.0" width="36.0" x="223.0" y="293.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_ScriptTask_1" bpmnElement="ScriptTask_1">
<dc:Bounds height="50.0" width="110.0" x="309.0" y="250.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_6">
<dc:Bounds height="11.0" width="52.0" x="338.0" y="269.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_2">
<dc:Bounds height="36.0" width="36.0" x="469.0" y="257.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_7" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="11.0" width="33.0" x="470.0" y="293.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="BPMNShape_UserTask_1" targetElement="BPMNShape_2">
<di:waypoint xsi:type="dc:Point" x="371.0" y="88.0"/>
<di:waypoint xsi:type="dc:Point" x="431.0" y="88.0"/>
<di:waypoint xsi:type="dc:Point" x="491.0" y="88.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_8"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="BPMNShape_1" targetElement="BPMNShape_UserTask_1">
<di:waypoint xsi:type="dc:Point" x="127.0" y="88.0"/>
<di:waypoint xsi:type="dc:Point" x="194.0" y="88.0"/>
<di:waypoint xsi:type="dc:Point" x="261.0" y="88.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_9"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_ScriptTask_1">
<di:waypoint xsi:type="dc:Point" x="259.0" y="275.0"/>
<di:waypoint xsi:type="dc:Point" x="309.0" y="275.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_10"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="BPMNShape_ScriptTask_1" targetElement="BPMNShape_EndEvent_1">
<di:waypoint xsi:type="dc:Point" x="419.0" y="275.0"/>
<di:waypoint xsi:type="dc:Point" x="469.0" y="275.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_11"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
<dc:Font name="arial" size="9.0"/>
</bpmndi:BPMNLabelStyle>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
Loading

0 comments on commit a458ebf

Please sign in to comment.