Skip to content

Commit

Permalink
chore(usage-statistics): add tracking for subprocess planes
Browse files Browse the repository at this point in the history
closes #2756
  • Loading branch information
marstamm authored and MaxTru committed Feb 16, 2022
1 parent ca0d1d8 commit 8a3bb20
Show file tree
Hide file tree
Showing 8 changed files with 501 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ import serviceTasksWithParticipantsXML from './fixtures/service-tasks-with-parti

import serviceTasksWithSubprocessXML from './fixtures/service-tasks-with-subprocess.bpmn';

import subprocessEmptyXML from './fixtures/subprocess-empty.bpmn';

import subprocessesNestedXML from './fixtures/subprocess-nested.bpmn';

import subprocessesInPoolXML from './fixtures/subprocess-pool.bpmn';

import subprocessesWithContentXML from './fixtures/subprocess-content.bpmn';

import userTasksXML from './fixtures/user-tasks.bpmn';

import userTasksWithParticipantsXML from './fixtures/user-tasks-with-participants.bpmn';
Expand Down Expand Up @@ -814,6 +822,118 @@ describe('<DeploymentEventHandler>', () => {
});


describe('subprocess planes', () => {

describe('bpmn', () => {

it('should send metrics with subprocess plane', async () => {

// given
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessesWithContentXML
}
});

const handleDeploymentDone = subscribe.getCall(0).args[1];

// when
await handleDeploymentDone({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 1,
nesting: 1
});

});


it('should send empty metrics with empty subprocess plane', async () => {

// given
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessEmptyXML
}
});

const handleDeploymentDone = subscribe.getCall(0).args[1];

// when
await handleDeploymentDone({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 0,
nesting: 0
});

});


it('should send metrics with nested subprocess planes', async () => {

// given
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessesNestedXML
}
});

const handleDeploymentDone = subscribe.getCall(0).args[1];

// when
await handleDeploymentDone({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 4,
nesting: 3
});

});


it('should send metrics with subprocess planes in pools', async () => {

// given
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessesInPoolXML
}
});

const handleDeploymentDone = subscribe.getCall(0).args[1];

// when
await handleDeploymentDone({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 4,
nesting: 3
});

});

});

});


it('should NOT send metrics for DMN', async () => {

// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ import serviceTasksWithParticipantsXML from './fixtures/service-tasks-with-parti

import serviceTasksWithSubprocessXML from './fixtures/service-tasks-with-subprocess.bpmn';

import subprocessEmptyXML from './fixtures/subprocess-empty.bpmn';

import subprocessesNestedXML from './fixtures/subprocess-nested.bpmn';

import subprocessesInPoolXML from './fixtures/subprocess-pool.bpmn';

import subprocessesWithContentXML from './fixtures/subprocess-content.bpmn';

import userTasksXML from './fixtures/user-tasks.bpmn';

import userTasksWithParticipantsXML from './fixtures/user-tasks-with-participants.bpmn';
Expand Down Expand Up @@ -1076,6 +1084,150 @@ describe('<DiagramOpenEventHandler>', () => {
});


describe('subprocess planes', () => {

describe('bpmn', () => {

it('should send metrics with subprocess plane', async () => {

// given
const subscribe = sinon.spy();
const onSend = sinon.spy();
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessesWithContentXML
}
});

const config = { get: () => null };

// when
const diagramOpenEventHandler = new DiagramOpenEventHandler({ onSend, subscribe, config });

diagramOpenEventHandler.enable();

const bpmnCallback = subscribe.getCall(0).args[1];

await bpmnCallback({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 1,
nesting: 1
});

});


it('should send empty metrics with empty subprocess plane', async () => {

// given
const subscribe = sinon.spy();
const onSend = sinon.spy();
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessEmptyXML
}
});

const config = { get: () => null };

// when
const diagramOpenEventHandler = new DiagramOpenEventHandler({ onSend, subscribe, config });

diagramOpenEventHandler.enable();

const bpmnCallback = subscribe.getCall(0).args[1];

await bpmnCallback({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 0,
nesting: 0
});

});


it('should send metrics with nested subprocess planes', async () => {

// given
const subscribe = sinon.spy();
const onSend = sinon.spy();
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessesNestedXML
}
});

const config = { get: () => null };

// when
const diagramOpenEventHandler = new DiagramOpenEventHandler({ onSend, subscribe, config });

diagramOpenEventHandler.enable();

const bpmnCallback = subscribe.getCall(0).args[1];

await bpmnCallback({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 4,
nesting: 3
});

});


it('should send metrics with subprocess planes in pools', async () => {

// given
const subscribe = sinon.spy();
const onSend = sinon.spy();
const tab = createTab({
type: 'bpmn',
file: {
contents: subprocessesInPoolXML
}
});

const config = { get: () => null };

// when
const diagramOpenEventHandler = new DiagramOpenEventHandler({ onSend, subscribe, config });

diagramOpenEventHandler.enable();

const bpmnCallback = subscribe.getCall(0).args[1];

await bpmnCallback({ tab });

const { diagramMetrics } = onSend.getCall(0).args[0];

// then
expect(diagramMetrics.subprocessPlanes).to.eql({
count: 4,
nesting: 3
});

});

});

});


it('should not send metrics for DMN', async () => {

// given
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1p8295l" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0-alpha.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.16.0">
<bpmn:process id="Process_03uyn38" isExecutable="true">
<bpmn:subProcess id="Activity_087ie34">
<bpmn:startEvent id="Event_1a4j25v" />
</bpmn:subProcess>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03uyn38">
<bpmndi:BPMNShape id="Activity_0iikhtk_di" bpmnElement="Activity_087ie34">
<dc:Bounds x="160" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_17e1x2s">
<bpmndi:BPMNPlane id="BPMNPlane_1jlvxoq" bpmnElement="Activity_087ie34">
<bpmndi:BPMNShape id="Event_1a4j25v_di" bpmnElement="Event_1a4j25v">
<dc:Bounds x="152" y="82" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1p8295l" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0-alpha.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.16.0">
<bpmn:process id="Process_03uyn38" isExecutable="true">
<bpmn:subProcess id="Activity_087ie34" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03uyn38">
<bpmndi:BPMNShape id="Activity_0iikhtk_di" bpmnElement="Activity_087ie34">
<dc:Bounds x="160" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_17e1x2s">
<bpmndi:BPMNPlane id="BPMNPlane_1jlvxoq" bpmnElement="Activity_087ie34" />
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1p8295l" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0-alpha.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.16.0">
<bpmn:process id="Process_03uyn38" isExecutable="true">
<bpmn:subProcess id="Activity_087ie34">
<bpmn:subProcess id="Activity_1vdoipi">
<bpmn:subProcess id="Activity_03fgf64">
<bpmn:startEvent id="Event_1s041h7" />
</bpmn:subProcess>
</bpmn:subProcess>
</bpmn:subProcess>
<bpmn:subProcess id="Activity_1stc8a1">
<bpmn:startEvent id="Event_1m9tk5x" />
</bpmn:subProcess>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03uyn38">
<bpmndi:BPMNShape id="Activity_0iikhtk_di" bpmnElement="Activity_087ie34">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_17zsmnc_di" bpmnElement="Activity_1stc8a1">
<dc:Bounds x="160" y="280" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_17e1x2s">
<bpmndi:BPMNPlane id="BPMNPlane_1jlvxoq" bpmnElement="Activity_087ie34">
<bpmndi:BPMNShape id="Activity_0p58qlh_di" bpmnElement="Activity_1vdoipi">
<dc:Bounds x="120" y="-40" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_1a3b1ap">
<bpmndi:BPMNPlane id="BPMNPlane_0utj70o" bpmnElement="Activity_1vdoipi">
<bpmndi:BPMNShape id="Activity_0g2ha5d_di" bpmnElement="Activity_03fgf64">
<dc:Bounds x="190" y="120" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_0aguriy">
<bpmndi:BPMNPlane id="BPMNPlane_15p0iiy" bpmnElement="Activity_03fgf64">
<bpmndi:BPMNShape id="Event_1s041h7_di" bpmnElement="Event_1s041h7">
<dc:Bounds x="192" y="242" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_00hbxtg">
<bpmndi:BPMNPlane id="BPMNPlane_0afj7w8" bpmnElement="Activity_1stc8a1">
<bpmndi:BPMNShape id="Event_1m9tk5x_di" bpmnElement="Event_1m9tk5x">
<dc:Bounds x="152" y="222" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Loading

0 comments on commit 8a3bb20

Please sign in to comment.