Skip to content

Commit cd2904c

Browse files
committed
feat(data-association-behavior): test integration of both behaviors
1 parent bc7b9a3 commit cd2904c

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import {
2+
bootstrapModeler,
3+
inject
4+
} from 'test/TestHelper';
5+
6+
import modelingModule from 'lib/features/modeling';
7+
8+
import {
9+
getDataInput
10+
} from 'lib/features/modeling/behavior/DataInputAssociationBehavior';
11+
12+
import {
13+
getDataOutput
14+
} from 'lib/features/modeling/behavior/DataOutputAssociationBehavior';
15+
16+
17+
describe('modeling/behavior - DataInputAssociationBehavior and DataOutputAssociationBehavior integration', function() {
18+
19+
var diagramXML = require('./DataAssociationBehavior.bpmn');
20+
21+
beforeEach(bootstrapModeler(diagramXML, { modules: modelingModule }));
22+
23+
24+
it('should add bpmn:DataInput and bpmn:DataOutput on connect -> connect', inject(function(elementRegistry, modeling) {
25+
26+
// given
27+
var dataObject1 = elementRegistry.get('DataObjectReference_1'),
28+
dataObject2 = elementRegistry.get('DataObjectReference_2'),
29+
task = elementRegistry.get('Task_1'),
30+
taskBo = task.businessObject;
31+
32+
var dataInputAssociation = modeling.connect(dataObject1, task, {
33+
type: 'bpmn:DataInputAssociation'
34+
});
35+
36+
// when
37+
var dataOutputAssociation = modeling.connect(task, dataObject2, {
38+
type: 'bpmn:DataOutputAssociation'
39+
});
40+
41+
// then
42+
var dataInputAssociationBo = dataInputAssociation.businessObject,
43+
dataOutputAssociationBo = dataOutputAssociation.businessObject;
44+
45+
expect(taskBo.ioSpecification).to.exist;
46+
47+
expect(taskBo.ioSpecification.dataInputs).to.have.length(1);
48+
expect(taskBo.ioSpecification.inputSets).to.have.length(1);
49+
expect(taskBo.ioSpecification.inputSets[0].dataInputRefs).to.have.length(1);
50+
51+
expect(taskBo.ioSpecification.dataOutputs).to.have.length(1);
52+
expect(taskBo.ioSpecification.outputSets).to.have.length(1);
53+
expect(taskBo.ioSpecification.outputSets[0].dataOutputRefs).to.have.length(1);
54+
55+
expect(dataInputAssociationBo.targetRef).to.exist;
56+
expect(dataInputAssociationBo.targetRef).to.eql(getDataInput(taskBo, dataInputAssociationBo.targetRef));
57+
58+
expect(dataOutputAssociationBo.get('sourceRef')[0]).to.exist;
59+
expect(dataOutputAssociationBo.get('sourceRef')[0]).to.eql(getDataOutput(taskBo, dataOutputAssociationBo.get('sourceRef')[0]));
60+
}));
61+
62+
63+
it('should remove bpmn:DataOutput on connect -> undo', inject(function(commandStack, elementRegistry, modeling) {
64+
65+
// given
66+
var dataObject1 = elementRegistry.get('DataObjectReference_1'),
67+
dataObject2 = elementRegistry.get('DataObjectReference_2'),
68+
task = elementRegistry.get('Task_1'),
69+
taskBo = task.businessObject;
70+
71+
var dataInputAssociation = modeling.connect(dataObject1, task, {
72+
type: 'bpmn:DataInputAssociation'
73+
});
74+
75+
modeling.connect(task, dataObject2, {
76+
type: 'bpmn:DataOutputAssociation'
77+
});
78+
79+
// when
80+
commandStack.undo();
81+
82+
// then
83+
var dataInputAssociationBo = dataInputAssociation.businessObject;
84+
85+
expect(taskBo.ioSpecification).to.exist;
86+
87+
expect(taskBo.ioSpecification.dataInputs).to.have.length(1);
88+
expect(taskBo.ioSpecification.dataOutputs).to.not.exist;
89+
90+
expect(taskBo.ioSpecification.inputSets).to.exist;
91+
expect(taskBo.ioSpecification.inputSets).to.have.length(1);
92+
expect(taskBo.ioSpecification.inputSets[0].dataInputRefs).to.have.length(1);
93+
94+
expect(taskBo.ioSpecification.outputSets).to.exist;
95+
expect(taskBo.ioSpecification.outputSets).to.have.length(1);
96+
expect(taskBo.ioSpecification.outputSets[0].dataOutputRefs).to.have.length(0);
97+
98+
expect(dataInputAssociationBo.targetRef).to.exist;
99+
expect(dataInputAssociationBo.targetRef).to.eql(getDataInput(taskBo, dataInputAssociationBo.targetRef));
100+
}));
101+
102+
103+
it('should remove bpmn:DataInput and bpmn:DataOutput on connect -> connect -> undo -> undo', inject(
104+
function(commandStack, elementRegistry, modeling) {
105+
106+
// given
107+
var dataObject1 = elementRegistry.get('DataObjectReference_1'),
108+
dataObject2 = elementRegistry.get('DataObjectReference_2'),
109+
task = elementRegistry.get('Task_1'),
110+
taskBo = task.businessObject;
111+
112+
modeling.connect(dataObject1, task, {
113+
type: 'bpmn:DataInputAssociation'
114+
});
115+
116+
modeling.connect(task, dataObject2, {
117+
type: 'bpmn:DataOutputAssociation'
118+
});
119+
120+
// when
121+
commandStack.undo();
122+
commandStack.undo();
123+
124+
// then
125+
expect(taskBo.ioSpecification).not.to.exist;
126+
}
127+
));
128+
129+
});

0 commit comments

Comments
 (0)