Skip to content

Commit d1533cb

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

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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.only('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+
expect(taskBo.ioSpecification.dataInputs).to.have.length(1);
47+
expect(taskBo.ioSpecification.inputSets).to.have.length(1);
48+
expect(taskBo.ioSpecification.inputSets[0].dataInputRefs).to.have.length(1);
49+
expect(taskBo.ioSpecification.dataOutputs).to.have.length(1);
50+
expect(taskBo.ioSpecification.outputSets).to.have.length(1);
51+
expect(taskBo.ioSpecification.outputSets[0].dataOutputRefs).to.have.length(1);
52+
53+
expect(dataInputAssociationBo.targetRef).to.exist;
54+
expect(dataInputAssociationBo.targetRef).to.eql(getDataInput(taskBo, dataInputAssociationBo.targetRef));
55+
56+
expect(dataOutputAssociationBo.get('sourceRef')[0]).to.exist;
57+
expect(dataOutputAssociationBo.get('sourceRef')[0]).to.eql(getDataOutput(taskBo, dataOutputAssociationBo.get('sourceRef')[0]));
58+
}));
59+
60+
61+
it('should remove bpmn:DataOutput on connect -> undo', inject(function(commandStack, elementRegistry, modeling) {
62+
63+
// given
64+
var dataObject1 = elementRegistry.get('DataObjectReference_1'),
65+
dataObject2 = elementRegistry.get('DataObjectReference_2'),
66+
task = elementRegistry.get('Task_1'),
67+
taskBo = task.businessObject;
68+
69+
var dataInputAssociation = modeling.connect(dataObject1, task, {
70+
type: 'bpmn:DataInputAssociation'
71+
});
72+
73+
modeling.connect(task, dataObject2, {
74+
type: 'bpmn:DataOutputAssociation'
75+
});
76+
77+
// when
78+
commandStack.undo();
79+
80+
// then
81+
var dataInputAssociationBo = dataInputAssociation.businessObject;
82+
83+
expect(taskBo.ioSpecification).to.exist;
84+
expect(taskBo.ioSpecification.dataInputs).to.have.length(1);
85+
expect(taskBo.ioSpecification.inputSets).to.have.length(1);
86+
expect(taskBo.ioSpecification.inputSets[0].dataInputRefs).to.have.length(1);
87+
expect(taskBo.ioSpecification.dataOutputs).to.not.exist;
88+
expect(taskBo.ioSpecification.outputSets).to.not.exist;
89+
90+
expect(dataInputAssociationBo.targetRef).to.exist;
91+
expect(dataInputAssociationBo.targetRef).to.eql(getDataInput(taskBo, dataInputAssociationBo.targetRef));
92+
}));
93+
94+
95+
it('should remove bpmn:DataInput and bpmn:DataOutput on connect -> connect -> undo -> undo', inject(
96+
function(commandStack, elementRegistry, modeling) {
97+
98+
// given
99+
var dataObject1 = elementRegistry.get('DataObjectReference_1'),
100+
dataObject2 = elementRegistry.get('DataObjectReference_2'),
101+
task = elementRegistry.get('Task_1'),
102+
taskBo = task.businessObject;
103+
104+
modeling.connect(dataObject1, task, {
105+
type: 'bpmn:DataInputAssociation'
106+
});
107+
108+
modeling.connect(task, dataObject2, {
109+
type: 'bpmn:DataOutputAssociation'
110+
});
111+
112+
// when
113+
commandStack.undo();
114+
commandStack.undo();
115+
116+
// then
117+
expect(taskBo.ioSpecification).not.to.exist;
118+
}
119+
));
120+
121+
});

0 commit comments

Comments
 (0)