-
Notifications
You must be signed in to change notification settings - Fork 85
/
SequenceTest.java
204 lines (191 loc) · 6.81 KB
/
SequenceTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*******************************************************************************
* Copyright (c) 2019, 2020 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.test.diagram.tools.ju.sequence;
import org.eclipse.sirius.business.api.session.Session;
import org.polarsys.capella.core.data.pa.PhysicalComponentNature;
import org.polarsys.capella.core.model.helpers.BlockArchitectureExt;
import org.polarsys.capella.core.sirius.analysis.IDiagramNameConstants;
import org.polarsys.capella.test.diagram.common.ju.context.CapabilityDiagram;
import org.polarsys.capella.test.diagram.common.ju.context.ESDiagram;
import org.polarsys.capella.test.diagram.common.ju.context.FSDiagram;
import org.polarsys.capella.test.diagram.common.ju.context.ISDiagram;
import org.polarsys.capella.test.diagram.common.ju.context.OA_ESDiagram;
import org.polarsys.capella.test.diagram.common.ju.context.PA_ESDiagram;
import org.polarsys.capella.test.diagram.common.ju.context.SA_ESDiagram;
import org.polarsys.capella.test.diagram.common.ju.context.SequenceDiagram;
import org.polarsys.capella.test.diagram.tools.ju.model.SequenceDiagramProject;
import org.polarsys.capella.test.framework.context.SessionContext;
import org.polarsys.capella.test.framework.helpers.SkeletonHelper;
import org.polarsys.capella.test.framework.model.GenericModel;
public abstract class SequenceTest extends SequenceDiagramProject {
protected SessionContext context = null;
protected String scenario = GenericModel.SCENARIO_1;
protected String capability = GenericModel.CAPABILITY_1;
protected String actor1 = "";
protected String actor2 = "";
protected String component1 = "";
protected String component2 = "";
protected String function1 = "";
protected String function2 = "";
public enum SequenceType {ES, FS, IS, OES, OAS}
public void testOnAllLevels(BlockArchitectureExt.Type[] types, SequenceType seqType) {
for (BlockArchitectureExt.Type type : types) {
doTest(type, seqType, getCapabilitiesId(type),
capability, scenario);
}
}
public abstract void test(SequenceDiagram diagram);
protected void setUpDiagram(SequenceDiagram diagram) {
if(diagram instanceof FSDiagram) {
function1 = ((FSDiagram) diagram).createFunction();
function2 = ((FSDiagram) diagram).createFunction();
}
else {
actor1 = diagram.createActor();
actor2 = diagram.createActor();
BlockArchitectureExt.Type type = diagram.getDiagramBlockArchitecture();
if(diagram instanceof ESDiagram) {
switch(type) {
case SA:
break;
case PA:
component1 = ((PA_ESDiagram) diagram).createComponent(PhysicalComponentNature.BEHAVIOR);
component2 = ((PA_ESDiagram) diagram).createComponent(PhysicalComponentNature.NODE);
break;
default:
component1 = ((ESDiagram) diagram).createComponent();
component2 = ((ESDiagram) diagram).createComponent();
break;
}
}
}
}
protected SequenceDiagram createDiagram(SessionContext context, BlockArchitectureExt.Type type, SequenceType seqType, String containerId,
String capabilityId, String scenarioId) {
SequenceDiagram diagram = null;
switch(seqType) {
case ES:
diagram = ESDiagram.createDiagram(context, scenarioId);
break;
case FS:
diagram = FSDiagram.createDiagram(context, scenarioId);
break;
case IS:
diagram = ISDiagram.createDiagram(context, scenarioId);
break;
default:
break;
}
return diagram;
}
protected void doTest(BlockArchitectureExt.Type type, SequenceType seqType, String containerId, String capabilityId,
String scenarioId) {
Session session = getSession(getRequiredTestModel());
context = new SessionContext(session);
SequenceDiagram diagram = openDiagram(type, seqType);
if (diagram != null) {
test(diagram);
diagram.close();
}
}
protected SequenceDiagram openDiagram(BlockArchitectureExt.Type type, SequenceType seqType) {
SequenceDiagram diagram = null;
switch (type) {
case OA:
switch (seqType) {
case ES:
diagram = OA_ESDiagram.openDiagram(context, OA_ES, type);
break;
default:
break;
}
break;
case SA:
switch (seqType) {
case ES:
diagram = SA_ESDiagram.openDiagram(context, SA_ES, type);
break;
case IS:
diagram = ISDiagram.openDiagram(context, SA_IS, type);
break;
case FS:
diagram = FSDiagram.openDiagram(context, SA_FS, type);
break;
default:
break;
}
break;
case LA:
switch (seqType) {
case ES:
diagram = ESDiagram.openDiagram(context, LA_ES, type);
break;
case IS:
diagram = ISDiagram.openDiagram(context, LA_IS, type);
break;
case FS:
diagram = FSDiagram.openDiagram(context, LA_FS, type);
break;
default:
break;
}
break;
case PA:
switch (seqType) {
case ES:
diagram = PA_ESDiagram.openDiagram(context, PA_ES, type);
break;
case IS:
diagram = ISDiagram.openDiagram(context, PA_IS, type);
break;
case FS:
diagram = FSDiagram.openDiagram(context, PA_FS, type);
break;
default:
break;
}
break;
default:
break;
}
return diagram;
}
// helper
protected String createCapability(SessionContext context, BlockArchitectureExt.Type type, String containerId, String capabilityId) {
CapabilityDiagram capabilityDiagram = CapabilityDiagram.createDiagram(context, containerId,
getCapabilityDiagramName(type));
capabilityDiagram.createCapability(capabilityId);
return capabilityId;
}
// helper
protected String createScenario(SessionContext context, String scenarioId, String capabilityId) {
SkeletonHelper.createScenario(capabilityId, scenarioId, context);
return scenarioId;
}
// helper
protected String getCapabilityDiagramName(BlockArchitectureExt.Type type) {
String capabilityDiagramName = "";
switch (type) {
case OA:
capabilityDiagramName = IDiagramNameConstants.OPERATIONAL_CAPABILITIES_ENTITYIES_BLANK_DIAGRAM_NAME;
break;
case SA:
capabilityDiagramName = IDiagramNameConstants.MISSIONS_CAPABILITIES_BLANK_DIAGRAM_NAME;
break;
default:
capabilityDiagramName = IDiagramNameConstants.CAPABILITY_REALIZATION_BLANK;
break;
}
return capabilityDiagramName;
}
}