How do I junit test a boundary event escalation?

Hello,

I try to test the path that starts from the receiving end of an escalation.

But I can’t find a way to trigger that event.

receiving messages or signals is not working, since the boundary events are not considered to be either of it.
Could somebody please point out how I can do that?
I’m using camunda-bpm-assert which doesn’t offer any (obvious) helper method.

thanks hlux.

The process model looks like this.

<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0">
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:startEvent id="StartEvent_1" name="Be a good pet lover">
      <bpmn:outgoing>SequenceFlow_13a1h0c</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_13a1h0c" sourceRef="StartEvent_1" targetRef="FeedTheFish" />
    <bpmn:subProcess id="FeedTheFish" name="Feed the fish">
      <bpmn:incoming>SequenceFlow_13a1h0c</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_0gbi469</bpmn:outgoing>
    </bpmn:subProcess>
    <bpmn:endEvent id="EndEvent_151hod1" name="Be Happy">
      <bpmn:incoming>SequenceFlow_0gbi469</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_0gbi469" sourceRef="FeedTheFish" targetRef="EndEvent_151hod1" />
    <bpmn:boundaryEvent id="BoundaryEvent_034chen" name="pet food is empty" attachedToRef="FeedTheFish">
      <bpmn:outgoing>SequenceFlow_1ud74nz</bpmn:outgoing>
      <bpmn:escalationEventDefinition escalationRef="Escalation_1frqj7r" />
    </bpmn:boundaryEvent>
    <bpmn:endEvent id="EndEvent_0ba0xul" name="Go Shopping">
      <bpmn:incoming>SequenceFlow_1ud74nz</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1ud74nz" sourceRef="BoundaryEvent_034chen" targetRef="EndEvent_0ba0xul" />
  </bpmn:process>
  <bpmn:escalation id="Escalation_1frqj7r" name="BuyPetFood" escalationCode="BuyPetFood" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="173" y="102" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="155" y="138" width="72" height="24" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_13a1h0c_di" bpmnElement="SequenceFlow_13a1h0c">
        <di:waypoint xsi:type="dc:Point" x="209" y="120" />
        <di:waypoint xsi:type="dc:Point" x="337" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="273" y="105" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="SubProcess_0nxm6ky_di" bpmnElement="FeedTheFish">
        <dc:Bounds x="337" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_151hod1_di" bpmnElement="EndEvent_151hod1">
        <dc:Bounds x="565" y="102" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="558" y="138" width="49" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0gbi469_di" bpmnElement="SequenceFlow_0gbi469">
        <di:waypoint xsi:type="dc:Point" x="437" y="120" />
        <di:waypoint xsi:type="dc:Point" x="565" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="501" y="95" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="BoundaryEvent_1ukgs31_di" bpmnElement="BoundaryEvent_034chen">
        <dc:Bounds x="402" y="142" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="378" y="178" width="84" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_0ba0xul_di" bpmnElement="EndEvent_0ba0xul">
        <dc:Bounds x="565" y="254" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="550" y="290" width="65" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1ud74nz_di" bpmnElement="SequenceFlow_1ud74nz">
        <di:waypoint xsi:type="dc:Point" x="420" y="178" />
        <di:waypoint xsi:type="dc:Point" x="420" y="272" />
        <di:waypoint xsi:type="dc:Point" x="565" y="272" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="435" y="215" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Hi @hlux,

an escalation catch event can only be triggered by an escalation throw event. There is no Api to trigger the event by code. You can use a process to throw the escalation event.

Does this help you?

Best regards,
Philipp

Hi Phillip,

thanks for yout reply.
Not exactly the answer I wished to hear, but at least I can stop my research at this point now :slight_smile:

To solve the problem I’m “mocking” a subprocess in the test that throws an escalation event.

.endEvent().escalation(escalationCode).done();

cheers,
hlux