test(modeling): verify DataStore addition, update and removal
Related to #345
This commit is contained in:
parent
6b27ee4301
commit
28e845984d
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="Definitions_1" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||
<bpmn:collaboration id="Collaboration">
|
||||
<bpmn:participant id="Participant" processRef="Process"/>
|
||||
</bpmn:collaboration>
|
||||
<bpmn:process id="Process" isExecutable="false">
|
||||
<bpmn:subProcess id="SubProcess">
|
||||
<bpmn:dataStoreReference id="DataStoreReference"/>
|
||||
</bpmn:subProcess>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
|
||||
<bpmndi:BPMNShape id="Participant_di" bpmnElement="Participant" isHorizontal="false">
|
||||
<dc:Bounds height="250.0" width="600.0" x="42.0" y="46.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="SubProcess_di" bpmnElement="SubProcess" isExpanded="true">
|
||||
<dc:Bounds height="200.0" width="350.0" x="260.0" y="73.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="DataStoreReference_di" bpmnElement="DataStoreReference">
|
||||
<dc:Bounds height="50.0" width="50.0" x="395.0" y="195.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="20.0" width="90.0" x="375.0" y="245.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="Definitions_1" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||
<bpmn:collaboration id="Collaboration">
|
||||
<bpmn:participant id="Participant" processRef="Process"/>
|
||||
</bpmn:collaboration>
|
||||
<bpmn:process id="Process" isExecutable="false">
|
||||
<bpmn:task id="Task">
|
||||
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
|
||||
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
|
||||
</bpmn:task>
|
||||
<bpmn:startEvent id="StartEvent">
|
||||
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:endEvent id="EndEvent">
|
||||
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:dataStoreReference id="DataStoreReference" name="Data Store" dataStoreRef="DataStore_1"/>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent" targetRef="Task"/>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_2" name="" sourceRef="Task" targetRef="EndEvent"/>
|
||||
</bpmn:process>
|
||||
<bpmn:dataStore id="DataStore_1" name="Data Store 1"/>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
|
||||
<bpmndi:BPMNShape id="Participant_di" bpmnElement="Participant" isHorizontal="false">
|
||||
<dc:Bounds height="250.0" width="600.0" x="84.0" y="48.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_8" bpmnElement="Task">
|
||||
<dc:Bounds height="76.0" width="97.0" x="264.0" y="98.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_3" bpmnElement="StartEvent">
|
||||
<dc:Bounds height="36.0" width="36.0" x="144.0" y="118.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="0.0" width="0.0" x="162.0" y="159.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent">
|
||||
<dc:Bounds height="36.0" width="36.0" x="468.0" y="118.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="0.0" width="0.0" x="486.0" y="159.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_DataStoreReference_3" bpmnElement="DataStoreReference">
|
||||
<dc:Bounds height="50.0" width="50.0" x="311.0" y="204.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="21.0" width="79.0" x="297.0" y="259.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_3" targetElement="_BPMNShape_Task_8">
|
||||
<di:waypoint xsi:type="dc:Point" x="180.0" y="136.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="264.0" y="136.0"/>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_Task_8" targetElement="_BPMNShape_EndEvent_2">
|
||||
<di:waypoint xsi:type="dc:Point" x="360.0" y="136.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="468.0" y="136.0"/>
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -0,0 +1,232 @@
|
|||
'use strict';
|
||||
|
||||
var TestHelper = require('../../../../TestHelper');
|
||||
|
||||
/* global bootstrapModeler, inject */
|
||||
|
||||
var is = require('../../../../../lib/util/ModelUtil').is;
|
||||
|
||||
var modelingModule = require('../../../../../lib/features/modeling'),
|
||||
coreModule = require('../../../../../lib/core');
|
||||
|
||||
|
||||
describe('features/modeling/behavior - data store', function() {
|
||||
|
||||
var testModules = [ coreModule, modelingModule ];
|
||||
|
||||
|
||||
describe('create', function() {
|
||||
|
||||
var processDiagramXML = require('./DataStoreBehavior.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
it('should create DataStoreReference on participant', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// give
|
||||
var participantElement = elementRegistry.get('Participant'),
|
||||
participantBo = participantElement.businessObject,
|
||||
processBo = participantBo.processRef;
|
||||
|
||||
// when
|
||||
var dataStoreShape = modeling.createShape(
|
||||
{ type: 'bpmn:DataStoreReference' },
|
||||
{ x: 220, y: 220 },
|
||||
participantElement);
|
||||
|
||||
var dataStoreReference = dataStoreShape.businessObject;
|
||||
|
||||
// then
|
||||
// reference correctly wired
|
||||
expect(dataStoreReference.$parent).to.eql(processBo);
|
||||
expect(processBo.flowElements).to.contain(dataStoreReference);
|
||||
|
||||
// no actual data store created
|
||||
expect(dataStoreReference.dataStoreRef).not.to.exist;
|
||||
}));
|
||||
|
||||
|
||||
it('should create DataStoreReference on sub process', inject(function(elementRegistry, modeling, bpmnjs) {
|
||||
|
||||
// give
|
||||
var subProcessElement = elementRegistry.get('SubProcess'),
|
||||
subProcessBo = subProcessElement.businessObject;
|
||||
|
||||
// when
|
||||
var dataStoreShape = modeling.createShape(
|
||||
{ type: 'bpmn:DataStoreReference' },
|
||||
{ x: 420, y: 220 },
|
||||
subProcessElement);
|
||||
|
||||
var dataStoreReference = dataStoreShape.businessObject;
|
||||
|
||||
// then
|
||||
// reference correctly wired
|
||||
expect(dataStoreReference.$parent).to.eql(subProcessBo);
|
||||
expect(subProcessBo.flowElements).to.contain(dataStoreReference);
|
||||
|
||||
// no actual data store created
|
||||
expect(dataStoreReference.dataStoreRef).not.to.exist;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('move', function() {
|
||||
|
||||
var processDiagramXML = require('./DataStoreBehavior.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
it('should move DataStoreReference', inject(function(elementRegistry, modeling, bpmnjs) {
|
||||
|
||||
// give
|
||||
var subProcessElement = elementRegistry.get('SubProcess'),
|
||||
subProcessBo = subProcessElement.businessObject,
|
||||
participantElement = elementRegistry.get('Participant'),
|
||||
participantBo = participantElement.businessObject,
|
||||
dataStoreReference = elementRegistry.get('DataStoreReference'),
|
||||
dataStoreReferenceBo = dataStoreReference.businessObject;
|
||||
|
||||
// when
|
||||
modeling.moveElements([ dataStoreReference ], { x: -200, y: 0 }, participantElement);
|
||||
|
||||
// then
|
||||
// reference correctly wired
|
||||
expect(dataStoreReference.parent).to.eql(participantElement);
|
||||
expect(dataStoreReferenceBo.$parent).to.eql(participantBo.processRef);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('connect', function() {
|
||||
|
||||
var processDiagramXML = require('./DataStoreBehavior.connect.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
describe('dataOutputAssociation', function() {
|
||||
|
||||
it('should execute', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var taskShape = elementRegistry.get('Task'),
|
||||
dataStoreRefShape = elementRegistry.get('DataStoreReference');
|
||||
|
||||
// when
|
||||
var outputAssociation = modeling.connect(taskShape, dataStoreRefShape);
|
||||
|
||||
var dataOutputAssociations = taskShape.businessObject.get('dataOutputAssociations');
|
||||
|
||||
// then
|
||||
expect(dataOutputAssociations).to.eql([ outputAssociation.businessObject ]);
|
||||
expect(outputAssociation.businessObject.$parent).to.eql(taskShape.businessObject);
|
||||
|
||||
expect(taskShape.businessObject.get('dataInputAssociations')).to.be.empty;
|
||||
}));
|
||||
|
||||
|
||||
it('should undo', inject(function(elementRegistry, modeling, commandStack) {
|
||||
|
||||
// given
|
||||
var taskShape = elementRegistry.get('Task'),
|
||||
dataStoreRefShape = elementRegistry.get('DataStoreReference');
|
||||
|
||||
// when
|
||||
modeling.connect(taskShape, dataStoreRefShape);
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
expect(taskShape.businessObject.get('dataOutputAssociations')).to.be.empty;
|
||||
expect(taskShape.businessObject.get('dataInputAssociations')).to.be.empty;
|
||||
}));
|
||||
|
||||
|
||||
it('should redo', inject(function(elementRegistry, modeling, commandStack) {
|
||||
|
||||
// given
|
||||
var taskShape = elementRegistry.get('Task'),
|
||||
dataStoreRefShape = elementRegistry.get('DataStoreReference');
|
||||
|
||||
// when
|
||||
var outputAssociation = modeling.connect(taskShape, dataStoreRefShape);
|
||||
commandStack.undo();
|
||||
commandStack.redo();
|
||||
|
||||
var dataOutputAssociations = taskShape.businessObject.get('dataOutputAssociations');
|
||||
|
||||
// then
|
||||
expect(dataOutputAssociations).to.eql([ outputAssociation.businessObject ]);
|
||||
expect(outputAssociation.businessObject.$parent).to.eql(taskShape.businessObject);
|
||||
|
||||
expect(taskShape.businessObject.get('dataInputAssociations')).to.be.empty;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('dataInputAssociation', function() {
|
||||
|
||||
it('should execute', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var taskShape = elementRegistry.get('Task'),
|
||||
dataStoreRefShape = elementRegistry.get('DataStoreReference');
|
||||
|
||||
// when
|
||||
var inputAssociation = modeling.connect(dataStoreRefShape, taskShape);
|
||||
|
||||
var dataInputAssociations = taskShape.businessObject.get('dataInputAssociations');
|
||||
|
||||
// then
|
||||
expect(dataInputAssociations).to.eql([ inputAssociation.businessObject ]);
|
||||
expect(inputAssociation.businessObject.$parent).to.eql(taskShape.businessObject);
|
||||
|
||||
expect(taskShape.businessObject.get('dataOutputAssociations')).to.be.empty;
|
||||
}));
|
||||
|
||||
|
||||
it('should undo', inject(function(elementRegistry, modeling, commandStack) {
|
||||
|
||||
// given
|
||||
var taskShape = elementRegistry.get('Task'),
|
||||
dataStoreRefShape = elementRegistry.get('DataStoreReference');
|
||||
|
||||
// when
|
||||
modeling.connect(dataStoreRefShape, taskShape);
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
expect(taskShape.businessObject.get('dataOutputAssociations')).to.be.empty;
|
||||
expect(taskShape.businessObject.get('dataInputAssociations')).to.be.empty;
|
||||
}));
|
||||
|
||||
|
||||
it('should redo', inject(function(elementRegistry, modeling, commandStack) {
|
||||
|
||||
// given
|
||||
var taskShape = elementRegistry.get('Task'),
|
||||
dataStoreRefShape = elementRegistry.get('DataStoreReference');
|
||||
|
||||
// when
|
||||
var inputAssociation = modeling.connect(dataStoreRefShape, taskShape);
|
||||
commandStack.undo();
|
||||
commandStack.redo();
|
||||
|
||||
var dataInputAssociations = taskShape.businessObject.get('dataInputAssociations');
|
||||
|
||||
// then
|
||||
expect(dataInputAssociations[0].$parent).to.equal(taskShape.businessObject);
|
||||
expect(dataInputAssociations).to.include(inputAssociation.businessObject);
|
||||
expect(taskShape.businessObject.get('dataOutputAssociations')).to.be.empty;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue