Skip to content

Commit

Permalink
extended test
Browse files Browse the repository at this point in the history
Issue imixs#238
  • Loading branch information
rsoika committed Apr 26, 2023
1 parent b799091 commit 62c2eae
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,11 @@ public BPMNElementNode findElementNodeById(String id) {
}

/**
* Returns a filtered list of elements
* Returns a filtered list of BPMNElementNodes.
* <p>
* The filter is defined by a Predicate which can contain any kind of complex
* boolean expression. If the expression evaluates to true, the BPMNElementNode
* will be included in the result set.
*
* @param <T>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.BPMNTypes;
import org.openbpmn.bpmn.elements.BPMNProcess;
import org.openbpmn.bpmn.elements.Event;
import org.openbpmn.bpmn.elements.core.BPMNElementNode;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.openbpmn.bpmn.util.BPMNModelFactory;
Expand Down Expand Up @@ -49,4 +50,44 @@ public void testFilterMethod() throws BPMNModelException {

}

/**
* In this test we use a more complex filter.
* We expect a throw event with at least one Link Definition and the name LINK
*
* @throws BPMNModelException
*/
@Test
public void testComplexFilterMethod() throws BPMNModelException {

logger.info("...read model");
BPMNModel model = BPMNModelFactory.read("/refmodel-15.bpmn");

assertEquals(1, model.getProcesses().size());
BPMNProcess process = model.openDefaultProces();

Set<? extends BPMNElementNode> filterResult = process
.findElementNodes(
n -> (BPMNTypes.CATCH_EVENT.equals(n.getType()) //
&& ((Event) n).getEventDefinitionsByType(BPMNTypes.EVENT_DEFINITION_LINK)
.size() == 1 //
&& "LINK".equals(n.getName())));

assertNotNull(filterResult);
// We expect exactly one result.
assertEquals(1, filterResult.size());

// now we change the filter and we expect no match !
filterResult = process
.findElementNodes(
n -> (BPMNTypes.CATCH_EVENT.equals(n.getType()) //
&& ((Event) n).getEventDefinitionsByType(BPMNTypes.EVENT_DEFINITION_CANCEL)
.size() == 1 //
&& "LINK".equals(n.getName())));

assertNotNull(filterResult);
// We expect exactly one result.
assertEquals(0, filterResult.size());

}

}
264 changes: 264 additions & 0 deletions open-bpmn.metamodel/src/test/resources/refmodel-15.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bpmn2:definitions 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:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://org.openbpmn">
<bpmn2:process id="process_1" name="Default Process" processType="Public">
<bpmn2:documentation id="documentation_cSzSmg"/>
<bpmn2:startEvent id="event_3l2H6A" name="Event-1">
<bpmn2:documentation id="documentation_LFBrTA"/>
<bpmn2:outgoing>sequenceFlow_GxGAgQ</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="task_SBK01w" name="Task-1">
<bpmn2:documentation id="documentation_s0UvSQ"/>
<bpmn2:incoming>sequenceFlow_GxGAgQ</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_GMnxSA</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:task id="task_1gbByA" name="Task-2">
<bpmn2:documentation id="documentation_ceiluQ"/>
<bpmn2:incoming>sequenceFlow_DG1nvg</bpmn2:incoming>
<bpmn2:incoming>sequenceFlow_NVfK3w</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_BVv7gA</bpmn2:outgoing>
<bpmn2:outgoing>sequenceFlow_MNZU9g</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:task id="task_awZF0w" name="Task-3">
<bpmn2:documentation id="documentation_63MfVQ"/>
<bpmn2:outgoing>sequenceFlow_0FUkVg</bpmn2:outgoing>
<bpmn2:incoming>sequenceFlow_pymNnA</bpmn2:incoming>
</bpmn2:task>
<bpmn2:task id="task_pVIAfA" name="Task-4">
<bpmn2:documentation id="documentation_P1tLrw"/>
<bpmn2:incoming>sequenceFlow_0z0yFA</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_QNdKEw</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:exclusiveGateway default="sequenceFlow_F4q8KA" gatewayDirection="Diverging" id="gateway_ee0LQw" name="Gateway-1">
<bpmn2:documentation id="documentation_wT03Zg"/>
<bpmn2:incoming>sequenceFlow_gZSk0Q</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_zO8yVQ</bpmn2:outgoing>
<bpmn2:outgoing>sequenceFlow_F4q8KA</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:intermediateCatchEvent id="event_IyD2LA" name="Event-2">
<bpmn2:documentation id="documentation_33D0jg"/>
<bpmn2:incoming>sequenceFlow_GMnxSA</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_gZSk0Q</bpmn2:outgoing>
<bpmn2:incoming>sequenceFlow_BVv7gA</bpmn2:incoming>
</bpmn2:intermediateCatchEvent>
<bpmn2:intermediateCatchEvent id="event_MczLNQ" name="Event-3">
<bpmn2:documentation id="documentation_g0lkLQ"/>
<bpmn2:incoming>sequenceFlow_F4q8KA</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_pymNnA</bpmn2:outgoing>
</bpmn2:intermediateCatchEvent>
<bpmn2:intermediateCatchEvent id="event_CxJz9w" name="Event-4">
<bpmn2:documentation id="documentation_PJdWMQ"/>
<bpmn2:incoming>sequenceFlow_zO8yVQ</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_0z0yFA</bpmn2:outgoing>
</bpmn2:intermediateCatchEvent>
<bpmn2:intermediateCatchEvent id="event_cFt0jw" name="Event-5">
<bpmn2:documentation id="documentation_IYAQ3A"/>
<bpmn2:outgoing>sequenceFlow_NVfK3w</bpmn2:outgoing>
</bpmn2:intermediateCatchEvent>
<bpmn2:intermediateCatchEvent id="event_wGYH5A" name="LINK">
<bpmn2:documentation id="documentation_jgXYAA"/>
<bpmn2:outgoing>sequenceFlow_DG1nvg</bpmn2:outgoing>
<bpmn2:linkEventDefinition id="linkEventDefinition_6gpgTw"/>
</bpmn2:intermediateCatchEvent>
<bpmn2:intermediateCatchEvent id="event_H4GvRQ" name="Event-7">
<bpmn2:documentation id="documentation_pzq0Fw"/>
<bpmn2:incoming>sequenceFlow_0FUkVg</bpmn2:incoming>
<bpmn2:outgoing>sequenceFlow_5whkuA</bpmn2:outgoing>
</bpmn2:intermediateCatchEvent>
<bpmn2:sequenceFlow id="sequenceFlow_GxGAgQ" sourceRef="event_3l2H6A" targetRef="task_SBK01w">
<bpmn2:documentation id="documentation_20Np5A"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_GMnxSA" sourceRef="task_SBK01w" targetRef="event_IyD2LA">
<bpmn2:documentation id="documentation_h8VJzg"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_gZSk0Q" sourceRef="event_IyD2LA" targetRef="gateway_ee0LQw">
<bpmn2:documentation id="documentation_062kWA"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_zO8yVQ" sourceRef="gateway_ee0LQw" targetRef="event_CxJz9w">
<bpmn2:documentation id="documentation_jSJr9g"/>
<bpmn2:conditionExpression id="formalExpression_WpF0xg" xsi:type="bpmn2:tFormalExpression"><![CDATA[a==b]]></bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_F4q8KA" sourceRef="gateway_ee0LQw" targetRef="event_MczLNQ">
<bpmn2:documentation id="documentation_0CLqyg"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_DG1nvg" sourceRef="event_wGYH5A" targetRef="task_1gbByA">
<bpmn2:documentation id="documentation_hO1vKg"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_NVfK3w" sourceRef="event_cFt0jw" targetRef="task_1gbByA">
<bpmn2:documentation id="documentation_Musc0Q"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_0FUkVg" sourceRef="task_awZF0w" targetRef="event_H4GvRQ">
<bpmn2:documentation id="documentation_tVZ02g"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_pymNnA" sourceRef="event_MczLNQ" targetRef="task_awZF0w">
<bpmn2:documentation id="documentation_opPbTQ"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_0z0yFA" sourceRef="event_CxJz9w" targetRef="task_pVIAfA">
<bpmn2:documentation id="documentation_5Cd5bw"/>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="sequenceFlow_BVv7gA" sourceRef="task_1gbByA" targetRef="event_IyD2LA">
<bpmn2:documentation id="documentation_ZTvTSg"/>
</bpmn2:sequenceFlow>
<bpmn2:endEvent id="event_1hnRCg" name="Event-9">
<bpmn2:documentation id="documentation_oWFPtg"/>
<bpmn2:incoming>sequenceFlow_MNZU9g</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="sequenceFlow_MNZU9g" sourceRef="task_1gbByA" targetRef="event_1hnRCg">
<bpmn2:documentation id="documentation_oCoP2g"/>
</bpmn2:sequenceFlow>
<bpmn2:endEvent id="event_KCPnvg" name="Event-10">
<bpmn2:documentation id="documentation_ZdhRfw"/>
<bpmn2:incoming>sequenceFlow_QNdKEw</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="sequenceFlow_QNdKEw" sourceRef="task_pVIAfA" targetRef="event_KCPnvg">
<bpmn2:documentation id="documentation_i4uNGg"/>
</bpmn2:sequenceFlow>
<bpmn2:intermediateThrowEvent id="event_NiKeWA" name="LINK">
<bpmn2:documentation id="documentation_tjcmfA"/>
<bpmn2:linkEventDefinition id="linkEventDefinition_gJlzFQ"/>
<bpmn2:incoming>sequenceFlow_5whkuA</bpmn2:incoming>
</bpmn2:intermediateThrowEvent>
<bpmn2:sequenceFlow id="sequenceFlow_5whkuA" sourceRef="event_H4GvRQ" targetRef="event_NiKeWA">
<bpmn2:documentation id="documentation_Jtdxmw"/>
</bpmn2:sequenceFlow>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="OpenBPMN Diagram">
<bpmndi:BPMNPlane bpmnElement="process_1" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="event_3l2H6A" id="BPMNShape_0aH0xQ">
<dc:Bounds height="36.0" width="36.0" x="135.0" y="107.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_qMH7eA">
<dc:Bounds height="16.0" width="100.0" x="103.0" y="146.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task_SBK01w" id="BPMNShape_Q2EOdA">
<dc:Bounds height="50.0" width="110.0" x="221.0" y="100.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task_1gbByA" id="BPMNShape_GMm6WQ">
<dc:Bounds height="50.0" width="110.0" x="630.0" y="100.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task_awZF0w" id="BPMNShape_X0WiyQ">
<dc:Bounds height="50.0" width="110.0" x="630.0" y="294.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task_pVIAfA" id="BPMNShape_wb2P5Q">
<dc:Bounds height="50.0" width="110.0" x="347.0" y="524.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="gateway_ee0LQw" id="BPMNShape_eKI0JA">
<dc:Bounds height="50.0" width="50.0" x="377.0" y="294.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_04HV9w">
<dc:Bounds height="16.0" width="100.0" x="352.0" y="347.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_IyD2LA" id="BPMNShape_3v50hg">
<dc:Bounds height="36.0" width="36.0" x="384.0" y="107.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_tGbTCQ">
<dc:Bounds height="16.0" width="100.0" x="352.0" y="146.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_MczLNQ" id="BPMNShape_2xyv9g">
<dc:Bounds height="36.0" width="36.0" x="497.0" y="301.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_wCvcBA">
<dc:Bounds height="16.0" width="100.0" x="465.0" y="340.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_CxJz9w" id="BPMNShape_poX0rg">
<dc:Bounds height="36.0" width="36.0" x="384.0" y="430.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_zIZ2Tw">
<dc:Bounds height="16.0" width="100.0" x="352.0" y="469.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_cFt0jw" id="BPMNShape_svU3dA">
<dc:Bounds height="36.0" width="36.0" x="667.0" y="182.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_rQDOmA">
<dc:Bounds height="16.0" width="100.0" x="635.0" y="221.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_wGYH5A" id="BPMNShape_wZAdxg">
<dc:Bounds height="36.0" width="36.0" x="542.0" y="107.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_AtoQPw">
<dc:Bounds height="16.0" width="100.0" x="510.0" y="146.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_H4GvRQ" id="BPMNShape_CjchXQ">
<dc:Bounds height="36.0" width="36.0" x="783.0" y="301.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_JINNXA">
<dc:Bounds height="16.0" width="100.0" x="751.0" y="340.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_GxGAgQ" id="BPMNEdge_N7M68g" sourceElement="BPMNShape_0aH0xQ" targetElement="BPMNShape_Q2EOdA">
<di:waypoint x="171.0" y="125.0"/>
<di:waypoint x="221.0" y="125.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_GMnxSA" id="BPMNEdge_YrvARw" sourceElement="BPMNShape_Q2EOdA" targetElement="BPMNShape_3v50hg">
<di:waypoint x="331.0" y="125.0"/>
<di:waypoint x="384.0" y="125.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_gZSk0Q" id="BPMNEdge_qtWF7Q" sourceElement="BPMNShape_3v50hg" targetElement="BPMNShape_eKI0JA">
<di:waypoint x="402.0" y="143.0"/>
<di:waypoint x="402.0" y="294.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_zO8yVQ" id="BPMNEdge_hygPuQ" sourceElement="BPMNShape_eKI0JA" targetElement="BPMNShape_poX0rg">
<di:waypoint x="402.0" y="344.0"/>
<di:waypoint x="402.0" y="430.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_F4q8KA" id="BPMNEdge_tl5Bkg" sourceElement="BPMNShape_eKI0JA" targetElement="BPMNShape_2xyv9g">
<di:waypoint x="427.0" y="319.0"/>
<di:waypoint x="497.0" y="319.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_DG1nvg" id="BPMNEdge_l2vcCw" sourceElement="BPMNShape_wZAdxg" targetElement="BPMNShape_GMm6WQ">
<di:waypoint x="578.0" y="125.0"/>
<di:waypoint x="630.0" y="125.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_NVfK3w" id="BPMNEdge_bEih0A" sourceElement="BPMNShape_svU3dA" targetElement="BPMNShape_GMm6WQ">
<di:waypoint x="685.0" y="182.0"/>
<di:waypoint x="685.0" y="150.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_0FUkVg" id="BPMNEdge_uUCwTw" sourceElement="BPMNShape_X0WiyQ" targetElement="BPMNShape_CjchXQ">
<di:waypoint x="740.0" y="319.0"/>
<di:waypoint x="783.0" y="319.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_pymNnA" id="BPMNEdge_nn4obg" sourceElement="BPMNShape_2xyv9g" targetElement="BPMNShape_X0WiyQ">
<di:waypoint x="533.0" y="319.0"/>
<di:waypoint x="630.0" y="319.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_0z0yFA" id="BPMNEdge_I7J0Cw" sourceElement="BPMNShape_poX0rg" targetElement="BPMNShape_wb2P5Q">
<di:waypoint x="402.0" y="466.0"/>
<di:waypoint x="402.0" y="524.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_BVv7gA" id="BPMNEdge_9vGiFA" sourceElement="BPMNShape_GMm6WQ" targetElement="BPMNShape_3v50hg">
<di:waypoint x="689.0" y="100.0"/>
<di:waypoint x="689.0" y="56.0"/>
<di:waypoint x="402.0" y="56.0"/>
<di:waypoint x="402.0" y="107.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="event_1hnRCg" id="BPMNShape_J37zoA">
<dc:Bounds height="36.0" width="36.0" x="783.0" y="107.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_eLca0w">
<dc:Bounds height="16.0" width="100.0" x="751.0" y="146.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_MNZU9g" id="BPMNEdge_E2gROQ" sourceElement="BPMNShape_GMm6WQ" targetElement="BPMNShape_J37zoA">
<di:waypoint x="740.0" y="125.0"/>
<di:waypoint x="783.0" y="125.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="event_KCPnvg" id="BPMNShape_kblozg">
<dc:Bounds height="36.0" width="36.0" x="497.0" y="531.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_c7f0Vw">
<dc:Bounds height="16.0" width="100.0" x="465.0" y="570.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_QNdKEw" id="BPMNEdge_EEWQqw" sourceElement="BPMNShape_wb2P5Q" targetElement="BPMNShape_kblozg">
<di:waypoint x="457.0" y="549.0"/>
<di:waypoint x="497.0" y="549.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="event_NiKeWA" id="BPMNShape_4QJ6KQ">
<dc:Bounds height="36.0" width="36.0" x="883.0" y="301.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_lJ03fg">
<dc:Bounds height="16.0" width="100.0" x="851.0" y="340.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_5whkuA" id="BPMNEdge_diw30w" sourceElement="BPMNShape_CjchXQ" targetElement="BPMNShape_4QJ6KQ">
<di:waypoint x="819.0" y="319.0"/>
<di:waypoint x="883.0" y="319.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>

0 comments on commit 62c2eae

Please sign in to comment.