Skip to content

Commit

Permalink
Added support for send and business rule external tasks (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
gclaussn committed Sep 26, 2024
1 parent 87c1f38 commit 2bc0923
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 0 deletions.
12 changes: 12 additions & 0 deletions integration-tests/simple.robot
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ mvn clean test
Should contain ${result.stdout} Running org.example.it.SimpleCollaborationTest
Should contain ${result.stdout} Running org.example.it.SimpleConditionalCatchEventTest
Should contain ${result.stdout} Running org.example.it.SimpleEventBasedGatewayTest
Should contain ${result.stdout} Running org.example.it.SimpleExternalBusinessRuleTaskTest
Should contain ${result.stdout} Running org.example.it.SimpleExternalMessageThrowEventTest
Should contain ${result.stdout} Running org.example.it.SimpleExternalSendTaskTest
Should contain ${result.stdout} Running org.example.it.SimpleExternalTaskTest
Should contain ${result.stdout} Running org.example.it.SimpleMessageCatchEventTest
Should contain ${result.stdout} Running org.example.it.SimpleMessageThrowEventTest
Expand Down Expand Up @@ -72,6 +75,9 @@ Assert Test Code Generation
Should contain ${result.stdout} Found BPMN file: simpleCallActivity.bpmn
Should contain ${result.stdout} Found BPMN file: simpleCollaboration.bpmn
Should contain ${result.stdout} Found BPMN file: simpleConditionalCatchEvent.bpmn
Should contain ${result.stdout} Found BPMN file: simpleExternalBusinessRuleTask.bpmn
Should contain ${result.stdout} Found BPMN file: simpleExternalMessageThrowEvent.bpmn
Should contain ${result.stdout} Found BPMN file: simpleExternalSendTask.bpmn
Should contain ${result.stdout} Found BPMN file: simpleExternalTask.bpmn
Should contain ${result.stdout} Found BPMN file: simpleMessageCatchEvent.bpmn
Should contain ${result.stdout} Found BPMN file: simpleMessageThrowEvent.bpmn
Expand Down Expand Up @@ -120,6 +126,9 @@ Assert Test Code Generation
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simpleeventbasedgateway/TC_Message.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simpleeventbasedgateway/TC_startEvent__eventBasedGateway.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simpleeventbasedgateway/TC_Timer.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simpleexternalbusinessruletask/TC_startEvent__endEvent.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simpleexternalmessagethrowevent/TC_startEvent__endEvent.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simpleexternalsendtask/TC_startEvent__endEvent.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simpleexternaltask/TC_startEvent__endEvent.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simplemessagecatchevent/TC_startEvent__endEvent.java
Should contain ${result.stdout} Writing file: ${buildDir}/bpmndt/generated/simplemessagethrowevent/TC_startEvent__endEvent.java
Expand All @@ -140,6 +149,9 @@ Assert Test Code Generation
File should exist ${testSources}/generated/simpleeventbasedgateway/TC_Message.java
File should exist ${testSources}/generated/simpleeventbasedgateway/TC_startEvent__eventBasedGateway.java
File should exist ${testSources}/generated/simpleeventbasedgateway/TC_Timer.java
File should exist ${testSources}/generated/simpleexternalbusinessruletask/TC_startEvent__endEvent.java
File should exist ${testSources}/generated/simpleexternalmessagethrowevent/TC_startEvent__endEvent.java
File should exist ${testSources}/generated/simpleexternalsendtask/TC_startEvent__endEvent.java
File should exist ${testSources}/generated/simpleexternaltask/TC_startEvent__endEvent.java
File should exist ${testSources}/generated/simplemessagecatchevent/TC_startEvent__endEvent.java
File should exist ${testSources}/generated/simplemessagethrowevent/TC_startEvent__endEvent.java
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bpmndt="http://camunda.org/schema/extension/bpmn-driven-testing" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0cy2jey" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.20.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.20.0">
<bpmn:process id="simpleExternalBusinessRuleTask" isExecutable="true" camunda:historyTimeToLive="180">
<bpmn:extensionElements>
<bpmndt:testCases>
<bpmndt:testCase>
<bpmndt:path>
<bpmndt:node>startEvent</bpmndt:node>
<bpmndt:node>externalBusinessRuleTask</bpmndt:node>
<bpmndt:node>endEvent</bpmndt:node>
</bpmndt:path>
</bpmndt:testCase>
</bpmndt:testCases>
</bpmn:extensionElements>
<bpmn:startEvent id="startEvent">
<bpmn:outgoing>Flow_1nsyone</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1nsyone" sourceRef="startEvent" targetRef="externalBusinessRuleTask" />
<bpmn:endEvent id="endEvent">
<bpmn:incoming>Flow_1s9au55</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1s9au55" sourceRef="externalBusinessRuleTask" targetRef="endEvent" />
<bpmn:businessRuleTask id="externalBusinessRuleTask" camunda:type="external" camunda:topic="test-topic">
<bpmn:incoming>Flow_1nsyone</bpmn:incoming>
<bpmn:outgoing>Flow_1s9au55</bpmn:outgoing>
</bpmn:businessRuleTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="simpleExternalBusinessRuleTask">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="startEvent">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0rt6m0u_di" bpmnElement="endEvent">
<dc:Bounds x="432" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1fmdhcz_di" bpmnElement="externalBusinessRuleTask">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1nsyone_di" bpmnElement="Flow_1nsyone">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1s9au55_di" bpmnElement="Flow_1s9au55">
<di:waypoint x="370" y="117" />
<di:waypoint x="432" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:bpmndt="http://camunda.org/schema/extension/bpmn-driven-testing" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0cy2jey" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.20.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.20.0">
<bpmn:process id="simpleExternalMessageThrowEvent" isExecutable="true" camunda:historyTimeToLive="180">
<bpmn:extensionElements>
<bpmndt:testCases>
<bpmndt:testCase>
<bpmndt:path>
<bpmndt:node>startEvent</bpmndt:node>
<bpmndt:node>externalMessageThrowEvent</bpmndt:node>
<bpmndt:node>endEvent</bpmndt:node>
</bpmndt:path>
</bpmndt:testCase>
</bpmndt:testCases>
</bpmn:extensionElements>
<bpmn:startEvent id="startEvent">
<bpmn:outgoing>Flow_0ll0rsa</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_0ll0rsa" sourceRef="startEvent" targetRef="externalMessageThrowEvent" />
<bpmn:endEvent id="endEvent">
<bpmn:incoming>Flow_1upmxrt</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1upmxrt" sourceRef="externalMessageThrowEvent" targetRef="endEvent" />
<bpmn:intermediateThrowEvent id="externalMessageThrowEvent">
<bpmn:incoming>Flow_0ll0rsa</bpmn:incoming>
<bpmn:outgoing>Flow_1upmxrt</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_11agqmh" camunda:type="external" camunda:topic="test-topic" />
</bpmn:intermediateThrowEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="simpleExternalMessageThrowEvent">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="startEvent">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_160d3xt_di" bpmnElement="endEvent">
<dc:Bounds x="372" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1rzedh4_di" bpmnElement="externalMessageThrowEvent">
<dc:Bounds x="272" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0ll0rsa_di" bpmnElement="Flow_0ll0rsa">
<di:waypoint x="215" y="117" />
<di:waypoint x="272" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1upmxrt_di" bpmnElement="Flow_1upmxrt">
<di:waypoint x="308" y="117" />
<di:waypoint x="372" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bpmndt="http://camunda.org/schema/extension/bpmn-driven-testing" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0cy2jey" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.20.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.20.0">
<bpmn:process id="simpleExternalSendTask" isExecutable="true" camunda:historyTimeToLive="180">
<bpmn:extensionElements>
<bpmndt:testCases>
<bpmndt:testCase>
<bpmndt:path>
<bpmndt:node>startEvent</bpmndt:node>
<bpmndt:node>externalSendTask</bpmndt:node>
<bpmndt:node>endEvent</bpmndt:node>
</bpmndt:path>
</bpmndt:testCase>
</bpmndt:testCases>
</bpmn:extensionElements>
<bpmn:startEvent id="startEvent">
<bpmn:outgoing>Flow_1nsyone</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1nsyone" sourceRef="startEvent" targetRef="externalSendTask" />
<bpmn:endEvent id="endEvent">
<bpmn:incoming>Flow_1s9au55</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1s9au55" sourceRef="externalSendTask" targetRef="endEvent" />
<bpmn:sendTask id="externalSendTask" camunda:type="external" camunda:topic="test-topic">
<bpmn:incoming>Flow_1nsyone</bpmn:incoming>
<bpmn:outgoing>Flow_1s9au55</bpmn:outgoing>
</bpmn:sendTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="simpleExternalSendTask">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="startEvent">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0rt6m0u_di" bpmnElement="endEvent">
<dc:Bounds x="432" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_05885qi_di" bpmnElement="externalSendTask">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1nsyone_di" bpmnElement="Flow_1nsyone">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1s9au55_di" bpmnElement="Flow_1s9au55">
<di:waypoint x="370" y="117" />
<di:waypoint x="432" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.example.it;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import generated.simpleexternalbusinessruletask.TC_startEvent__endEvent;

public class SimpleExternalBusinessRuleTaskTest {

@RegisterExtension
public TC_startEvent__endEvent tc = new TC_startEvent__endEvent();

@Test
public void testExecute() {
tc.createExecutor().execute();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.example.it;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import generated.simpleexternalmessagethrowevent.TC_startEvent__endEvent;

public class SimpleExternalMessageThrowEventTest {

@RegisterExtension
public TC_startEvent__endEvent tc = new TC_startEvent__endEvent();

@Test
public void testExecute() {
tc.createExecutor().execute();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.example.it;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import generated.simpleexternalsendtask.TC_startEvent__endEvent;

public class SimpleExternalSendTaskTest {

@RegisterExtension
public TC_startEvent__endEvent tc = new TC_startEvent__endEvent();

@Test
public void testExecute() {
tc.createExecutor().execute();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.camunda.community.bpmndt.model;

import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_BOUNDARY_EVENT;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_BUSINESS_RULE_TASK;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_CALL_ACTIVITY;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_END_EVENT;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_EVENT_BASED_GATEWAY;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_INTERMEDIATE_CATCH_EVENT;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_INTERMEDIATE_THROW_EVENT;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_PROCESS;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_RECEIVE_TASK;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_SEND_TASK;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_SERVICE_TASK;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_START_EVENT;
import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_USER_TASK;
Expand All @@ -21,12 +23,14 @@

import org.camunda.bpm.model.bpmn.instance.Activity;
import org.camunda.bpm.model.bpmn.instance.BaseElement;
import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask;
import org.camunda.bpm.model.bpmn.instance.FlowElement;
import org.camunda.bpm.model.bpmn.instance.FlowNode;
import org.camunda.bpm.model.bpmn.instance.IntermediateThrowEvent;
import org.camunda.bpm.model.bpmn.instance.MessageEventDefinition;
import org.camunda.bpm.model.bpmn.instance.MultiInstanceLoopCharacteristics;
import org.camunda.bpm.model.bpmn.instance.Process;
import org.camunda.bpm.model.bpmn.instance.SendTask;
import org.camunda.bpm.model.bpmn.instance.ServiceTask;
import org.camunda.bpm.model.bpmn.instance.SubProcess;
import org.camunda.bpm.model.xml.instance.ModelElementInstance;
Expand Down Expand Up @@ -135,6 +139,12 @@ public String getTopicName(String flowNodeId) {
if (is(flowNodeId, BPMN_ELEMENT_SERVICE_TASK)) {
ServiceTask serviceTask = (ServiceTask) flowNodes.get(flowNodeId);
return serviceTask.getCamundaTopic();
} else if (is(flowNodeId, BPMN_ELEMENT_SEND_TASK)) {
SendTask sendTask = (SendTask) flowNodes.get(flowNodeId);
return sendTask.getCamundaTopic();
} else if (is(flowNodeId, BPMN_ELEMENT_BUSINESS_RULE_TASK)) {
BusinessRuleTask businessRuleTask = (BusinessRuleTask) flowNodes.get(flowNodeId);
return businessRuleTask.getCamundaTopic();
} else if (is(flowNodeId, BPMN_ELEMENT_INTERMEDIATE_THROW_EVENT)) {
IntermediateThrowEvent event = (IntermediateThrowEvent) flowNodes.get(flowNodeId);

Expand Down Expand Up @@ -172,6 +182,12 @@ public boolean isExternalTask(String flowNodeId) {
if (is(flowNodeId, BPMN_ELEMENT_SERVICE_TASK)) {
ServiceTask serviceTask = (ServiceTask) flowNodes.get(flowNodeId);
return "external".equals(serviceTask.getCamundaType());
} else if (is(flowNodeId, BPMN_ELEMENT_SEND_TASK)) {
SendTask sendTask = (SendTask) flowNodes.get(flowNodeId);
return "external".equals(sendTask.getCamundaType());
} else if (is(flowNodeId, BPMN_ELEMENT_BUSINESS_RULE_TASK)) {
BusinessRuleTask businessRuleTask = (BusinessRuleTask) flowNodes.get(flowNodeId);
return "external".equals(businessRuleTask.getCamundaType());
} else if (is(flowNodeId, BPMN_ELEMENT_INTERMEDIATE_THROW_EVENT)) {
IntermediateThrowEvent event = (IntermediateThrowEvent) flowNodes.get(flowNodeId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public void testGetMultiInstance() {
assertThat(bpmnSupport.getMultiInstanceLoopCharacteristics("multiInstanceManualTask")).isNotNull();
}

@Test
public void testGetTopicName() {
bpmnSupport = of(simple.resolve("simpleExternalTask.bpmn"));
assertThat(bpmnSupport.getTopicName("externalTask")).isEqualTo("test-topic");

bpmnSupport = of(simple.resolve("simpleExternalBusinessRuleTask.bpmn"));
assertThat(bpmnSupport.getTopicName("externalBusinessRuleTask")).isEqualTo("test-topic");

bpmnSupport = of(simple.resolve("simpleExternalMessageThrowEvent.bpmn"));
assertThat(bpmnSupport.getTopicName("externalMessageThrowEvent")).isEqualTo("test-topic");

bpmnSupport = of(simple.resolve("simpleExternalSendTask.bpmn"));
assertThat(bpmnSupport.getTopicName("externalSendTask")).isEqualTo("test-topic");

bpmnSupport = of(simple.resolve("simpleUserTask.bpmn"));
assertThat(bpmnSupport.getTopicName("userTask")).isNull();
}

@Test
public void testHas() {
bpmnSupport = of(simple.resolve("simple.bpmn"));
Expand Down Expand Up @@ -62,6 +80,18 @@ public void testIsEventBasedGateway() {
public void testIsExternalTask() {
bpmnSupport = of(simple.resolve("simpleExternalTask.bpmn"));
assertThat(bpmnSupport.isExternalTask("externalTask")).isTrue();

bpmnSupport = of(simple.resolve("simpleExternalBusinessRuleTask.bpmn"));
assertThat(bpmnSupport.isExternalTask("externalBusinessRuleTask")).isTrue();

bpmnSupport = of(simple.resolve("simpleExternalMessageThrowEvent.bpmn"));
assertThat(bpmnSupport.isExternalTask("externalMessageThrowEvent")).isTrue();

bpmnSupport = of(simple.resolve("simpleExternalSendTask.bpmn"));
assertThat(bpmnSupport.isExternalTask("externalSendTask")).isTrue();

bpmnSupport = of(simple.resolve("simpleUserTask.bpmn"));
assertThat(bpmnSupport.isExternalTask("userTask")).isFalse();
}

@Test
Expand Down

0 comments on commit 2bc0923

Please sign in to comment.