Skip to content

Package: DynamicRuleService_PTest

DynamicRuleService_PTest

nameinstructionbranchcomplexitylinemethod
DynamicRuleService_PTest()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createContainerView()
M: 0 C: 31
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
createDomainObject()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
createEnableRule(double)
M: 0 C: 25
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
createEnableRule(double, double)
M: 0 C: 55
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 16
100%
M: 0 C: 1
100%
createShowRule(double)
M: 0 C: 25
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
createSimpleView()
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
getVerticalLayout(VView)
M: 5 C: 18
78%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 3
75%
M: 0 C: 1
100%
initialize()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setUp()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
tearDown()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
testAddAndRemoveEmptyEnableRuleOnContainer()
M: 0 C: 74
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddAndRemoveEmptyEnableRuleOnContainerAndControl()
M: 0 C: 61
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testAddAndRemoveEmptyEnableRuleOnControl()
M: 0 C: 46
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testAddAndRemoveEmptyShowRuleOnContainer()
M: 0 C: 74
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddAndRemoveEmptyShowRuleOnContainerAndControl()
M: 0 C: 73
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testAddAndRemoveEmptyShowRuleOnControl()
M: 0 C: 46
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testAddAndRemoveEnableRuleOnContainer()
M: 0 C: 75
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddAndRemoveEnableRuleOnContainerAndControl()
M: 0 C: 63
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testAddAndRemoveEnableRuleOnControl()
M: 0 C: 47
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testAddAndRemoveShowRuleOnContainer()
M: 0 C: 75
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddAndRemoveShowRuleOnContainerAndControl()
M: 0 C: 75
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testAddAndRemoveShowRuleOnControl()
M: 0 C: 47
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testAddEmptyConditionOnControl()
M: 0 C: 34
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testAddEmptyEnableRuleOnContainer()
M: 0 C: 42
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
testAddEmptyEnableRuleOnContainerAndControl()
M: 0 C: 46
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddEmptyEnableRuleOnControl()
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
testAddEmptyShowRuleOnContainer()
M: 0 C: 42
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
testAddEmptyShowRuleOnContainerAndControl()
M: 0 C: 46
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddEmptyShowRuleOnControl()
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
testAddEmptyShowRuleOppositeOnControl()
M: 0 C: 31
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
testAddEnableRuleOnContainer()
M: 0 C: 43
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
testAddEnableRuleOnContainerAndControl()
M: 0 C: 48
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddEnableRuleOnControl()
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
testAddNewVElementWithLeafCondition()
M: 0 C: 53
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testAddNewVElementWithNonLeafCondition()
M: 0 C: 54
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testAddNewVElementWithoutRule()
M: 0 C: 30
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
testAddShowRuleOnContainer()
M: 0 C: 43
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
testAddShowRuleOnContainerAndControl()
M: 0 C: 48
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testAddShowRuleOnControl()
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
testInitEmptyConditionOnControl()
M: 0 C: 34
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testInitEmptyDMROnControl()
M: 0 C: 40
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testInitEmptyShowRuleOnControl()
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
testInitEmptyShowRuleOppositeOnControl()
M: 0 C: 31
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
testUnsetDMROnControl()
M: 0 C: 55
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.rule.test;
15:
16: import static org.junit.Assert.assertFalse;
17: import static org.junit.Assert.assertTrue;
18:
19: import java.util.NoSuchElementException;
20:
21: import org.eclipse.emf.ecp.test.common.DefaultRealm;
22: import org.eclipse.emf.ecp.view.internal.rule.RuleService;
23: import org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory;
24: import org.eclipse.emf.ecp.view.spi.model.VContainedContainer;
25: import org.eclipse.emf.ecp.view.spi.model.VContainedElement;
26: import org.eclipse.emf.ecp.view.spi.model.VControl;
27: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
28: import org.eclipse.emf.ecp.view.spi.model.VView;
29: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
30: import org.eclipse.emf.ecp.view.spi.rule.model.EnableRule;
31: import org.eclipse.emf.ecp.view.spi.rule.model.LeafCondition;
32: import org.eclipse.emf.ecp.view.spi.rule.model.OrCondition;
33: import org.eclipse.emf.ecp.view.spi.rule.model.RuleFactory;
34: import org.eclipse.emf.ecp.view.spi.rule.model.ShowRule;
35: import org.eclipse.emf.ecp.view.spi.vertical.model.VVerticalFactory;
36: import org.eclipse.emf.ecp.view.spi.vertical.model.VVerticalLayout;
37: import org.eclipse.emf.emfstore.bowling.BowlingFactory;
38: import org.eclipse.emf.emfstore.bowling.BowlingPackage;
39: import org.eclipse.emf.emfstore.bowling.Player;
40: import org.junit.After;
41: import org.junit.Before;
42: import org.junit.Test;
43:
44: /**
45: * @author Eugen
46: * @author jfaltermeier
47: *
48: */
49: public class DynamicRuleService_PTest {
50:
51:         private static final double HEIGHT = 2;
52:         private static final double HEIGHT_ALT = 3;
53:         private static final double PLAYER_HEIGHT = 1;
54:
55:         private RuleService rs;
56:         private VView view;
57:         private Player domainObject;
58:         private DefaultRealm realm;
59:
60:         /**
61:          * @throws java.lang.Exception
62:          */
63:         @Before
64:         public void setUp() throws Exception {
65:                 realm = new DefaultRealm();
66:                 rs = new RuleService();
67:                 domainObject = createDomainObject();
68:         }
69:
70:         @After
71:         public void tearDown() {
72:                 realm.dispose();
73:         }
74:
75:         private void initialize() {
76:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domainObject,
77:                         rs);
78:         }
79:
80:         private Player createDomainObject() {
81:                 final Player player = BowlingFactory.eINSTANCE.createPlayer();
82:                 player.setName("Test");
83:                 player.setHeight(PLAYER_HEIGHT);
84:                 return player;
85:         }
86:
87:         private ShowRule createShowRule(double expectedValue) {
88:                 final ShowRule showRule = RuleFactory.eINSTANCE.createShowRule();
89:                 final LeafCondition lc = RuleFactory.eINSTANCE.createLeafCondition();
90:                 showRule.setCondition(lc);
91:                 final VFeaturePathDomainModelReference dmr = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
92:                 dmr.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Height());
93:                 lc.setDomainModelReference(dmr);
94:                 lc.setExpectedValue(expectedValue);
95:                 return showRule;
96:         }
97:
98:         private EnableRule createEnableRule(double expectedValue) {
99:                 final EnableRule enabelRule = RuleFactory.eINSTANCE.createEnableRule();
100:                 final LeafCondition lc = RuleFactory.eINSTANCE.createLeafCondition();
101:                 enabelRule.setCondition(lc);
102:                 final VFeaturePathDomainModelReference dmr = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
103:                 dmr.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Height());
104:                 lc.setDomainModelReference(dmr);
105:                 lc.setExpectedValue(expectedValue);
106:                 return enabelRule;
107:         }
108:
109:         private EnableRule createEnableRule(double expectedValue1, double expectedValue2) {
110:                 final EnableRule enableRule = RuleFactory.eINSTANCE.createEnableRule();
111:
112:                 final OrCondition oc = RuleFactory.eINSTANCE.createOrCondition();
113:
114:                 final LeafCondition lc1 = RuleFactory.eINSTANCE.createLeafCondition();
115:                 final VFeaturePathDomainModelReference dmr1 = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
116:                 dmr1.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Height());
117:                 lc1.setDomainModelReference(dmr1);
118:                 lc1.setExpectedValue(expectedValue1);
119:                 oc.getConditions().add(lc1);
120:
121:                 final LeafCondition lc2 = RuleFactory.eINSTANCE.createLeafCondition();
122:                 final VFeaturePathDomainModelReference dmr2 = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
123:                 dmr2.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Height());
124:                 lc2.setDomainModelReference(dmr2);
125:                 lc2.setExpectedValue(expectedValue2);
126:                 oc.getConditions().add(lc2);
127:
128:                 enableRule.setCondition(oc);
129:
130:                 return enableRule;
131:         }
132:
133:         private VView createSimpleView() {
134:                 final VView view = VViewFactory.eINSTANCE.createView();
135:                 final VControl controlName = VViewFactory.eINSTANCE.createControl();
136:                 final VFeaturePathDomainModelReference dmrName = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
137:                 dmrName.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Name());
138:                 controlName.setDomainModelReference(dmrName);
139:                 view.getChildren().add(controlName);
140:                 return view;
141:         }
142:
143:         private VView createContainerView() {
144:                 final VView view = VViewFactory.eINSTANCE.createView();
145:                 final VVerticalLayout verticalLayout = VVerticalFactory.eINSTANCE.createVerticalLayout();
146:                 view.getChildren().add(verticalLayout);
147:                 final VControl controlName = VViewFactory.eINSTANCE.createControl();
148:                 final VFeaturePathDomainModelReference dmrName = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
149:                 dmrName.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Name());
150:                 controlName.setDomainModelReference(dmrName);
151:                 verticalLayout.getChildren().add(controlName);
152:                 return view;
153:         }
154:
155:         private VVerticalLayout getVerticalLayout(VView view) {
156:•                for (final VContainedElement element : view.getChildren()) {
157:•                        if (element instanceof VVerticalLayout) {
158:                                 return (VVerticalLayout) element;
159:                         }
160:                 }
161:                 throw new NoSuchElementException("No vertical layout found in the view's children.");
162:         }
163:
164:         @Test
165:         public void testInitEmptyShowRuleOnControl() {
166:                 view = createSimpleView();
167:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
168:                 view.getChildren().get(0).getAttachments().add(sr);
169:                 initialize();
170:
171:                 assertTrue(view.getChildren().get(0).isVisible());
172:         }
173:
174:         @Test
175:         public void testInitEmptyShowRuleOppositeOnControl() {
176:                 view = createSimpleView();
177:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
178:                 sr.setHide(true);
179:                 view.getChildren().get(0).getAttachments().add(sr);
180:                 initialize();
181:
182:                 assertTrue(view.getChildren().get(0).isVisible());
183:         }
184:
185:         @Test
186:         public void testInitEmptyConditionOnControl() {
187:                 view = createSimpleView();
188:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
189:                 final LeafCondition lc = RuleFactory.eINSTANCE.createLeafCondition();
190:                 sr.setCondition(lc);
191:                 view.getChildren().get(0).getAttachments().add(sr);
192:                 initialize();
193:
194:                 assertTrue(view.getChildren().get(0).isVisible());
195:         }
196:
197:         @Test
198:         public void testInitEmptyDMROnControl() {
199:                 view = createSimpleView();
200:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
201:                 final LeafCondition lc = RuleFactory.eINSTANCE.createLeafCondition();
202:                 final VFeaturePathDomainModelReference dmr = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
203:                 lc.setDomainModelReference(dmr);
204:                 sr.setCondition(lc);
205:                 view.getChildren().get(0).getAttachments().add(sr);
206:                 initialize();
207:
208:                 assertTrue(view.getChildren().get(0).isVisible());
209:         }
210:
211:         @Test
212:         public void testUnsetDMROnControl() {
213:                 view = createSimpleView();
214:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
215:                 final LeafCondition lc = RuleFactory.eINSTANCE.createLeafCondition();
216:                 final VFeaturePathDomainModelReference dmr = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
217:                 dmr.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Height());
218:                 lc.setDomainModelReference(dmr);
219:                 sr.setCondition(lc);
220:                 view.getChildren().get(0).getAttachments().add(sr);
221:                 initialize();
222:
223:                 assertFalse(view.getChildren().get(0).isVisible());
224:
225:                 dmr.setDomainModelEFeature(null);
226:
227:                 assertTrue(view.getChildren().get(0).isVisible());
228:
229:         }
230:
231:         @Test
232:         public void testAddEmptyShowRuleOnControl() {
233:                 view = createSimpleView();
234:                 initialize();
235:
236:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
237:                 view.getChildren().get(0).getAttachments().add(sr);
238:                 assertTrue(view.getChildren().get(0).isVisible());
239:         }
240:
241:         @Test
242:         public void testAddEmptyConditionOnControl() {
243:                 view = createSimpleView();
244:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
245:                 view.getChildren().get(0).getAttachments().add(sr);
246:                 initialize();
247:                 final LeafCondition lc = RuleFactory.eINSTANCE.createLeafCondition();
248:                 sr.setCondition(lc);
249:                 assertTrue(view.getChildren().get(0).isVisible());
250:         }
251:
252:         @Test
253:         public void testAddEmptyShowRuleOppositeOnControl() {
254:                 view = createSimpleView();
255:                 initialize();
256:
257:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
258:                 sr.setHide(true);
259:                 view.getChildren().get(0).getAttachments().add(sr);
260:                 assertTrue(view.getChildren().get(0).isVisible());
261:         }
262:
263:         @Test
264:         public void testAddAndRemoveEmptyShowRuleOnControl() {
265:                 view = createSimpleView();
266:                 initialize();
267:
268:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
269:                 view.getChildren().get(0).getAttachments().add(sr);
270:                 assertTrue(view.getChildren().get(0).isVisible());
271:                 view.getChildren().get(0).getAttachments().remove(sr);
272:                 assertTrue(view.getChildren().get(0).isVisible());
273:         }
274:
275:         @Test
276:         public void testAddEmptyEnableRuleOnControl() {
277:                 view = createSimpleView();
278:                 initialize();
279:
280:                 final EnableRule er = RuleFactory.eINSTANCE.createEnableRule();
281:                 view.getChildren().get(0).getAttachments().add(er);
282:                 assertTrue(view.getChildren().get(0).isEnabled());
283:         }
284:
285:         @Test
286:         public void testAddAndRemoveEmptyEnableRuleOnControl() {
287:                 view = createSimpleView();
288:                 initialize();
289:
290:                 final EnableRule er = RuleFactory.eINSTANCE.createEnableRule();
291:                 view.getChildren().get(0).getAttachments().add(er);
292:                 assertTrue(view.getChildren().get(0).isEnabled());
293:                 view.getChildren().get(0).getAttachments().remove(er);
294:                 assertTrue(view.getChildren().get(0).isEnabled());
295:         }
296:
297:         @Test
298:         public void testAddEmptyShowRuleOnContainer() {
299:                 view = createContainerView();
300:                 initialize();
301:
302:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
303:                 view.getChildren().get(0).getAttachments().add(sr);
304:                 assertTrue(view.getChildren().get(0).isVisible());
305:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
306:         }
307:
308:         @Test
309:         public void testAddAndRemoveEmptyShowRuleOnContainer() {
310:                 view = createContainerView();
311:                 initialize();
312:
313:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
314:                 view.getChildren().get(0).getAttachments().add(sr);
315:                 assertTrue(view.getChildren().get(0).isVisible());
316:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
317:                 view.getChildren().get(0).getAttachments().remove(sr);
318:                 assertTrue(view.getChildren().get(0).isVisible());
319:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
320:         }
321:
322:         @Test
323:         public void testAddEmptyEnableRuleOnContainer() {
324:                 view = createContainerView();
325:                 initialize();
326:
327:                 final EnableRule er = RuleFactory.eINSTANCE.createEnableRule();
328:                 view.getChildren().get(0).getAttachments().add(er);
329:                 assertTrue(view.getChildren().get(0).isEnabled());
330:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isEnabled());
331:         }
332:
333:         @Test
334:         public void testAddAndRemoveEmptyEnableRuleOnContainer() {
335:                 view = createContainerView();
336:                 initialize();
337:
338:                 final EnableRule er = RuleFactory.eINSTANCE.createEnableRule();
339:                 view.getChildren().get(0).getAttachments().add(er);
340:                 assertTrue(view.getChildren().get(0).isEnabled());
341:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isEnabled());
342:                 view.getChildren().get(0).getAttachments().remove(er);
343:                 assertTrue(view.getChildren().get(0).isEnabled());
344:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isEnabled());
345:         }
346:
347:         @Test
348:         public void testAddEmptyShowRuleOnContainerAndControl() {
349:                 view = createContainerView();
350:                 initialize();
351:
352:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
353:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
354:                 final ShowRule sr2 = RuleFactory.eINSTANCE.createShowRule();
355:                 container.getAttachments().add(sr);
356:                 container.getChildren().get(0).getAttachments().add(sr2);
357:
358:                 assertTrue(container.isVisible());
359:                 assertTrue(container.getChildren().get(0).isVisible());
360:         }
361:
362:         @Test
363:         public void testAddAndRemoveEmptyShowRuleOnContainerAndControl() {
364:                 view = createContainerView();
365:                 initialize();
366:
367:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
368:                 final ShowRule sr = RuleFactory.eINSTANCE.createShowRule();
369:                 final ShowRule sr2 = RuleFactory.eINSTANCE.createShowRule();
370:                 container.getAttachments().add(sr);
371:                 container.getChildren().get(0).getAttachments().add(sr2);
372:
373:                 assertTrue(view.getChildren().get(0).isVisible());
374:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
375:                 container.getAttachments().remove(sr);
376:                 assertTrue(container.isVisible());
377:                 assertTrue(container.getChildren().get(0).isVisible());
378:         }
379:
380:         @Test
381:         public void testAddEmptyEnableRuleOnContainerAndControl() {
382:                 view = createContainerView();
383:                 initialize();
384:
385:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
386:                 final EnableRule er = RuleFactory.eINSTANCE.createEnableRule();
387:                 final EnableRule er2 = RuleFactory.eINSTANCE.createEnableRule();
388:                 container.getAttachments().add(er);
389:                 container.getChildren().get(0).getAttachments().add(er2);
390:                 assertTrue(container.isEnabled());
391:                 assertTrue(container.getChildren().get(0).isEnabled());
392:         }
393:
394:         @Test
395:         public void testAddAndRemoveEmptyEnableRuleOnContainerAndControl() {
396:                 view = createContainerView();
397:                 initialize();
398:
399:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
400:                 final EnableRule er = RuleFactory.eINSTANCE.createEnableRule();
401:                 final EnableRule er2 = RuleFactory.eINSTANCE.createEnableRule();
402:                 container.getAttachments().add(er);
403:                 container.getChildren().get(0).getAttachments().add(er2);
404:                 assertTrue(container.isEnabled());
405:                 assertTrue(container.getChildren().get(0).isEnabled());
406:
407:                 container.getAttachments().remove(er);
408:                 assertTrue(container.isEnabled());
409:                 assertTrue(container.getChildren().get(0).isEnabled());
410:         }
411:
412:         @Test
413:         public void testAddShowRuleOnControl() {
414:                 view = createSimpleView();
415:                 initialize();
416:
417:                 final ShowRule sr = createShowRule(HEIGHT);
418:                 view.getChildren().get(0).getAttachments().add(sr);
419:                 assertFalse(view.getChildren().get(0).isVisible());
420:         }
421:
422:         @Test
423:         public void testAddAndRemoveShowRuleOnControl() {
424:                 view = createSimpleView();
425:                 initialize();
426:
427:                 final ShowRule sr = createShowRule(HEIGHT);
428:                 view.getChildren().get(0).getAttachments().add(sr);
429:                 assertFalse(view.getChildren().get(0).isVisible());
430:                 view.getChildren().get(0).getAttachments().remove(sr);
431:                 assertTrue(view.getChildren().get(0).isVisible());
432:         }
433:
434:         @Test
435:         public void testAddEnableRuleOnControl() {
436:                 view = createSimpleView();
437:                 initialize();
438:
439:                 final EnableRule er = createEnableRule(HEIGHT);
440:                 view.getChildren().get(0).getAttachments().add(er);
441:                 assertFalse(view.getChildren().get(0).isEnabled());
442:         }
443:
444:         @Test
445:         public void testAddAndRemoveEnableRuleOnControl() {
446:                 view = createSimpleView();
447:                 initialize();
448:
449:                 final EnableRule er = createEnableRule(HEIGHT);
450:                 view.getChildren().get(0).getAttachments().add(er);
451:                 assertFalse(view.getChildren().get(0).isEnabled());
452:                 view.getChildren().get(0).getAttachments().remove(er);
453:                 assertTrue(view.getChildren().get(0).isEnabled());
454:         }
455:
456:         @Test
457:         public void testAddShowRuleOnContainer() {
458:                 view = createContainerView();
459:                 initialize();
460:
461:                 final ShowRule sr = createShowRule(HEIGHT);
462:                 view.getChildren().get(0).getAttachments().add(sr);
463:                 assertFalse(view.getChildren().get(0).isVisible());
464:                 assertFalse(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
465:         }
466:
467:         @Test
468:         public void testAddAndRemoveShowRuleOnContainer() {
469:                 view = createContainerView();
470:                 initialize();
471:
472:                 final ShowRule sr = createShowRule(HEIGHT);
473:                 view.getChildren().get(0).getAttachments().add(sr);
474:                 assertFalse(view.getChildren().get(0).isVisible());
475:                 assertFalse(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
476:                 view.getChildren().get(0).getAttachments().remove(sr);
477:                 assertTrue(view.getChildren().get(0).isVisible());
478:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
479:         }
480:
481:         @Test
482:         public void testAddEnableRuleOnContainer() {
483:                 view = createContainerView();
484:                 initialize();
485:
486:                 final EnableRule er = createEnableRule(HEIGHT);
487:                 view.getChildren().get(0).getAttachments().add(er);
488:                 assertFalse(view.getChildren().get(0).isEnabled());
489:                 assertFalse(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isEnabled());
490:         }
491:
492:         @Test
493:         public void testAddAndRemoveEnableRuleOnContainer() {
494:                 view = createContainerView();
495:                 initialize();
496:
497:                 final EnableRule er = createEnableRule(HEIGHT);
498:                 view.getChildren().get(0).getAttachments().add(er);
499:                 assertFalse(view.getChildren().get(0).isEnabled());
500:                 assertFalse(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isEnabled());
501:                 view.getChildren().get(0).getAttachments().remove(er);
502:                 assertTrue(view.getChildren().get(0).isEnabled());
503:                 assertTrue(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isEnabled());
504:         }
505:
506:         @Test
507:         public void testAddShowRuleOnContainerAndControl() {
508:                 view = createContainerView();
509:                 initialize();
510:
511:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
512:                 final ShowRule sr = createShowRule(HEIGHT);
513:                 final ShowRule sr2 = createShowRule(HEIGHT);
514:                 container.getAttachments().add(sr);
515:                 container.getChildren().get(0).getAttachments().add(sr2);
516:
517:                 assertFalse(container.isVisible());
518:                 assertFalse(container.getChildren().get(0).isVisible());
519:         }
520:
521:         @Test
522:         public void testAddAndRemoveShowRuleOnContainerAndControl() {
523:                 view = createContainerView();
524:                 initialize();
525:
526:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
527:                 final ShowRule sr = createShowRule(HEIGHT);
528:                 final ShowRule sr2 = createShowRule(HEIGHT);
529:                 container.getAttachments().add(sr);
530:                 container.getChildren().get(0).getAttachments().add(sr2);
531:
532:                 assertFalse(view.getChildren().get(0).isVisible());
533:                 assertFalse(VContainedContainer.class.cast(view.getChildren().get(0)).getChildren().get(0).isVisible());
534:                 container.getAttachments().remove(sr);
535:                 assertTrue(container.isVisible());
536:                 assertFalse(container.getChildren().get(0).isVisible());
537:         }
538:
539:         @Test
540:         public void testAddEnableRuleOnContainerAndControl() {
541:                 view = createContainerView();
542:                 initialize();
543:
544:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
545:                 final EnableRule er = createEnableRule(HEIGHT);
546:                 final EnableRule er2 = createEnableRule(HEIGHT);
547:                 container.getAttachments().add(er);
548:                 container.getChildren().get(0).getAttachments().add(er2);
549:                 assertFalse(container.isEnabled());
550:                 assertFalse(container.getChildren().get(0).isEnabled());
551:         }
552:
553:         @Test
554:         public void testAddAndRemoveEnableRuleOnContainerAndControl() {
555:                 view = createContainerView();
556:                 initialize();
557:
558:                 final VContainedContainer container = VContainedContainer.class.cast(view.getChildren().get(0));
559:                 final EnableRule er = createEnableRule(HEIGHT);
560:                 final EnableRule er2 = createEnableRule(HEIGHT);
561:                 container.getAttachments().add(er);
562:                 container.getChildren().get(0).getAttachments().add(er2);
563:                 assertFalse(container.isEnabled());
564:                 assertFalse(container.getChildren().get(0).isEnabled());
565:
566:                 container.getAttachments().remove(er);
567:                 assertTrue(container.isEnabled());
568:                 assertFalse(container.getChildren().get(0).isEnabled());
569:         }
570:
571:         @Test
572:         public void testAddNewVElementWithoutRule() {
573:                 // setup
574:                 view = createContainerView();
575:                 initialize();
576:
577:                 // act
578:                 final VVerticalLayout verticalLayout = getVerticalLayout(view);
579:                 final VControl controlName = VViewFactory.eINSTANCE.createControl();
580:                 final VFeaturePathDomainModelReference dmrName = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
581:                 dmrName.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Name());
582:                 controlName.setDomainModelReference(dmrName);
583:                 verticalLayout.getChildren().add(controlName);
584:
585:                 // assert
586:                 // no exceptions expected
587:         }
588:
589:         @Test
590:         public void testAddNewVElementWithLeafCondition() {
591:                 // setup
592:                 view = createContainerView();
593:                 initialize();
594:
595:                 // act
596:                 final VVerticalLayout verticalLayout = getVerticalLayout(view);
597:                 final VControl controlName = VViewFactory.eINSTANCE.createControl();
598:                 final VFeaturePathDomainModelReference dmrName = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
599:                 dmrName.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Name());
600:                 controlName.setDomainModelReference(dmrName);
601:
602:                 final EnableRule er = createEnableRule(HEIGHT);
603:                 controlName.getAttachments().add(er);
604:
605:                 verticalLayout.getChildren().add(controlName);
606:
607:                 // assert
608:                 assertTrue(verticalLayout.getChildren().get(0).isEnabled());
609:                 assertFalse(verticalLayout.getChildren().get(1).isEnabled());
610:         }
611:
612:         @Test
613:         public void testAddNewVElementWithNonLeafCondition() {
614:                 // setup
615:                 view = createContainerView();
616:                 initialize();
617:
618:                 // act
619:                 final VVerticalLayout verticalLayout = getVerticalLayout(view);
620:                 final VControl controlName = VViewFactory.eINSTANCE.createControl();
621:                 final VFeaturePathDomainModelReference dmrName = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
622:                 dmrName.setDomainModelEFeature(BowlingPackage.eINSTANCE.getPlayer_Name());
623:                 controlName.setDomainModelReference(dmrName);
624:
625:                 final EnableRule er = createEnableRule(HEIGHT, HEIGHT_ALT);
626:                 controlName.getAttachments().add(er);
627:
628:                 verticalLayout.getChildren().add(controlName);
629:
630:                 // assert
631:                 assertTrue(verticalLayout.getChildren().get(0).isEnabled());
632:                 assertFalse(verticalLayout.getChildren().get(1).isEnabled());
633:         }
634:
635: }