Need guidance for a call activity

38 views
Skip to first unread message

Simon Thiel

unread,
Sep 11, 2015, 5:50:48 AM9/11/15
to camunda BPM users

Hi@all

while extending our bpmn model with a call activity for more spezialized task, I've noticed a strange behavior. I've read the docs, but couldn't find any hint regarding my problem.

 

 

We've configured our call activity as follows:

 

<bpmn2:callActivity id="CallActivity_2" name="Spezialprozess" calledElement="#{spezialprozess}" camunda:calledElementBinding="deployment">

      <bpmn2:extensionElements>

        <camunda:in variables="all"/>

        <camunda:out variables="all"/>

      </bpmn2:extensionElements>

      <bpmn2:incoming>SequenceFlow_19</bpmn2:incoming>

      <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing>

    </bpmn2:callActivity>

 

Then I designed the target, which should be invoked:

 

 












„Prozessintegration“-Source:

<?xml version="1.0" encoding="UTF-8"?>

<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:camunda="http://activiti.org/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_bM1s0FbwEeWra8pjDQckHQ" targetNamespace="http://activiti.org/bpmn">

  <bpmn2:collaboration id="_Collaboration_4">

    <bpmn2:participant id="_Participant_4" name="Prozessintegration" processRef="prozessintegration"/>

  </bpmn2:collaboration>

  <bpmn2:process id="prozessintegration" name="Prozessintegration" isExecutable="true">

    <bpmn2:startEvent id="StartEvent_Prozessintegration">

      <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>

    </bpmn2:startEvent>

    <bpmn2:endEvent id="EndEvent_Prozessintegration">

      <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>

    </bpmn2:endEvent>

    <bpmn2:userTask id="UserTaskProzessintegrationDurchfuehren" name="Prozessintegration durchführen">

      <bpmn2:extensionElements>

        <camunda:taskListener delegateExpression="#{taskDescriptionAktualisierer}" event="complete"/>

      </bpmn2:extensionElements>

      <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>

      <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>

    </bpmn2:userTask>

    <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_Prozessintegration" targetRef="UserTaskProzessintegrationDurchfuehren"/>

    <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="UserTaskProzessintegrationDurchfuehren" targetRef="EndEvent_Prozessintegration"/>

  </bpmn2:process>

  <bpmndi:BPMNDiagram id="BPMNDiagram_1">

    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_4">

      <bpmndi:BPMNShape id="_BPMNShape_Participant_4" bpmnElement="_Participant_4" isHorizontal="true">

        <dc:Bounds height="215.0" width="540.0" x="425.0" y="116.0"/>

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_6" bpmnElement="StartEvent_Prozessintegration">

        <dc:Bounds height="36.0" width="36.0" x="504.0" y="197.0"/>

        <bpmndi:BPMNLabel>

          <dc:Bounds height="0.0" width="0.0" x="522.0" y="238.0"/>

        </bpmndi:BPMNLabel>

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="_BPMNShape_EndEvent_4" bpmnElement="EndEvent_Prozessintegration">

        <dc:Bounds height="36.0" width="36.0" x="905.0" y="197.0"/>

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="_BPMNShape_UserTask_4" bpmnElement="UserTaskProzessintegrationDurchfuehren">

        <dc:Bounds height="80.0" width="100.0" x="660.0" y="175.0"/>

      </bpmndi:BPMNShape>

      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_6" targetElement="_BPMNShape_UserTask_4">

        <di:waypoint xsi:type="dc:Point" x="540.0" y="215.0"/>

        <di:waypoint xsi:type="dc:Point" x="660.0" y="215.0"/>

        <bpmndi:BPMNLabel>

          <dc:Bounds height="6.0" width="6.0" x="574.0" y="215.0"/>

        </bpmndi:BPMNLabel>

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_UserTask_4" targetElement="_BPMNShape_EndEvent_4">

        <di:waypoint xsi:type="dc:Point" x="760.0" y="215.0"/>

        <di:waypoint xsi:type="dc:Point" x="905.0" y="215.0"/>

        <bpmndi:BPMNLabel>

          <dc:Bounds height="6.0" width="6.0" x="871.0" y="215.0"/>

        </bpmndi:BPMNLabel>

      </bpmndi:BPMNEdge>

    </bpmndi:BPMNPlane>

  </bpmndi:BPMNDiagram>

</bpmn2:definitions>

 

 

Running my unit-test, I suspect the task to pass the start-gateway named „StartEvent_Prozessintegration“. The test result acutally points out, that the task passed the call activity mentioned above (CallActivity_2), but does not pass the start-gateway. The task seems to bypass the new model and continue its path at the parent model.

 

 

Test-Case:

public class SpezialprozessTest extends PluggableProcessEngineTestCase {

 

    private static final String BPMN_FILE_AUFGABENBEARBEITUNG = "Aufgabenbearbeitung.bpmn";

 

    private static final String BPMN_FILE_SPEZIALPROZESS_PROZESSINTEGRATION = "Prozessintegration.bpmn";

 

 

    public void setup() {

        Mocks.register(…);

       // Several mocks registered

    }

 

    @Deployment(resources = {BPMN_FILE_AUFGABENBEARBEITUNG, BPMN_FILE_SPEZIALPROZESS_PROZESSINTEGRATION})

    public void testSpezialprozess() {

        setup();

        Map<String, Object> variablen = new HashMap<String, Object>();

        variablen.put("spezialprozess", "prozessintegration");

 

        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("aufgabenbearbeitung", variablen);

 

        Task task = taskService.createTaskQuery().singleResult();

 

        taskService.complete(task.getId());

 

        assertThat(processInstance).hasPassed("StartEvent_Prozessintegration");

    }  

 

 

What am I missing? Any hints are truly appreciated.

Thanks in advance

Simon

Ingo Richtsmeier

unread,
Sep 11, 2015, 6:55:01 AM9/11/15
to camunda BPM users
Hi Simon,

the call activity starts a new process instance. If you query for this in your JUnit-test, you can check the passed activities afterwards.

Kind Regards, Ingo

Philipp Ossler

unread,
Sep 11, 2015, 8:29:51 AM9/11/15
to camunda BPM users
Hi Simon,

Ingo is right. Just change your unit test to

@Deployment(resources = {BPMN_FILE_AUFGABENBEARBEITUNG, BPMN_FILE_SPEZIALPROZESS_PROZESSINTEGRATION})
public void testSpezialprozess() {
      setup();

      Map<String, Object> variablen = new HashMap<String, Object>();
      variablen.put("spezialprozess", "prozessintegration");
      runtimeService.startProcessInstanceByKey("aufgabenbearbeitung", variablen);

      Task task = taskService.createTaskQuery().singleResult();
      ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();

      taskService.complete(task.getId());

      assertThat(processInstance).hasPassed("StartEvent_Prozessintegration");
    }


Greetings,
Philipp

Simon Thiel

unread,
Sep 11, 2015, 8:52:35 AM9/11/15
to camunda BPM users
Hi,

big thanks to both of you. I assumed that a taskService.complete() would be the initial trigger to enter the subprocess, instead it'll resume the task to leave the UserTask. So I started querying after performing a complete and only got null as a result. Changing my test to Phillipps suggestion did the deal.

Thank you and have a nice weekend
Simon
Reply all
Reply to author
Forward
0 new messages