Skip to content

Commit

Permalink
fix(VariableResolver): correctly filter out already existing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm authored and nikku committed Mar 11, 2024
1 parent 7ea4dfc commit 6e3b711
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 78 deletions.
4 changes: 2 additions & 2 deletions lib/base/VariableResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ function merge(property, target, source) {
target[property] = [];
}

const originToAdd = source[property].filter(o => !target.origin.includes(o));
const propertiesToAdd = source[property].filter(o => !target[property].includes(o));

target[property].push(...originToAdd);
target[property].push(...propertiesToAdd);
}

export function mergeEntries(target, source, visited = []) {
Expand Down
75 changes: 0 additions & 75 deletions test/fixtures/zeebe/mappings/mappings.bpmn

This file was deleted.

38 changes: 37 additions & 1 deletion test/fixtures/zeebe/mappings/merging.bpmn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?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:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1noegy9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.10.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0">
<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:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1noegy9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.21.0-rc.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0">
<bpmn:collaboration id="Collaboration_0val525">
<bpmn:participant id="Participant_1" processRef="Process_1" />
<bpmn:participant id="Participant_2" processRef="Process_2" />
<bpmn:participant id="Participant_3" processRef="Process_3" />
</bpmn:collaboration>
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:serviceTask id="mergeContext" name="Merging Contexts">
Expand Down Expand Up @@ -36,6 +37,34 @@
</bpmn:extensionElements>
</bpmn:serviceTask>
</bpmn:process>
<bpmn:process id="Process_3" isExecutable="false">
<bpmn:serviceTask id="Activity_1d3l9mi" name="20 Mappings">
<bpmn:extensionElements>
<zeebe:ioMapping>
<zeebe:output source="=a" target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
<zeebe:output target="foo" />
</zeebe:ioMapping>
</bpmn:extensionElements>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0val525">
<bpmndi:BPMNShape id="Participant_0o063cf_di" bpmnElement="Participant_1" isHorizontal="true">
Expand All @@ -59,6 +88,13 @@
<dc:Bounds x="510" y="460" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_10nlgk8_di" bpmnElement="Participant_3" isHorizontal="true">
<dc:Bounds x="160" y="680" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1lvesqk_di" bpmnElement="Activity_1d3l9mi">
<dc:Bounds x="210" y="760" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
23 changes: 23 additions & 0 deletions test/spec/zeebe/Mappings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,29 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
]);
}));


it('should handle many merge operations', inject(async function(variableResolver, elementRegistry) {

// given
const root = elementRegistry.get('Participant_3');

createProvider({
variables: [],
variableResolver
});

// when
// this failed previously in an infinite loop, cf. https://github.com/camunda/camunda-modeler/issues/4139
const variables = await variableResolver.getVariablesForElement(root.businessObject.processRef);

// then
expect(variables).to.variableEqual([
{
name: 'foo'
}
]);
}));

});


Expand Down

0 comments on commit 6e3b711

Please sign in to comment.