Skip to content

Package: RuleTestHelper

RuleTestHelper

nameinstructionbranchcomplexitylinemethod
addFalseLeafCondition(Rule)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addTrueLeafCondition(Rule)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createDisabledEnableRule()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createEnableRule()
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%
createEnabledEnableRule()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createFalseLeafCondition()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createInvisibleShowRule()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createLeafCondition()
M: 0 C: 21
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
createRuleContainerAndAddRule(Rule)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createRuleHandle(Rule)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
createTrueLeafCondition()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createVisibleShowRule()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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: * Jonas - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.rule.test;
15:
16: import org.eclipse.emf.ecp.view.spi.model.VElement;
17: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
18: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
19: import org.eclipse.emf.ecp.view.spi.rule.model.EnableRule;
20: import org.eclipse.emf.ecp.view.spi.rule.model.LeafCondition;
21: import org.eclipse.emf.ecp.view.spi.rule.model.Rule;
22: import org.eclipse.emf.ecp.view.spi.rule.model.RuleFactory;
23: import org.eclipse.emf.ecp.view.spi.rule.model.ShowRule;
24: import org.eclipse.emf.emfstore.bowling.BowlingFactory;
25: import org.eclipse.emf.emfstore.bowling.BowlingPackage;
26: import org.eclipse.emf.emfstore.bowling.Fan;
27: import org.eclipse.emf.emfstore.bowling.Merchandise;
28:
29: /**
30: * Tests Rule Evaluation and its impact on node with conditions.
31: *
32: * @author jonas
33: */
34: public final class RuleTestHelper {
35:
36:         private RuleTestHelper() {
37:                 // util
38:         }
39:
40:         public static void addFalseLeafCondition(Rule rule) {
41:                 final LeafCondition leafCondition = createFalseLeafCondition();
42:                 rule.setCondition(leafCondition);
43:         }
44:
45:         private static LeafCondition createFalseLeafCondition() {
46:                 final LeafCondition leafCondition = createLeafCondition();
47:                 leafCondition.setExpectedValue("bar");
48:                 return leafCondition;
49:         }
50:
51:         private static LeafCondition createTrueLeafCondition() {
52:                 final LeafCondition leafCondition = createLeafCondition();
53:                 leafCondition.setExpectedValue("foo");
54:                 return leafCondition;
55:         }
56:
57:         public static void addTrueLeafCondition(Rule rule) {
58:                 final LeafCondition leafCondition = createTrueLeafCondition();
59:                 rule.setCondition(leafCondition);
60:         }
61:
62:         private static LeafCondition createLeafCondition() {
63:                 final LeafCondition leafCondition = RuleFactory.eINSTANCE.createLeafCondition();
64:                 final VFeaturePathDomainModelReference modelReference = VViewFactory.eINSTANCE
65:                         .createFeaturePathDomainModelReference();
66:                 modelReference.setDomainModelEFeature(BowlingPackage.eINSTANCE.getMerchandise_Name());
67:                 modelReference.getDomainModelEReferencePath().add(BowlingPackage.eINSTANCE.getFan_FavouriteMerchandise());
68:                 leafCondition.setDomainModelReference(modelReference);
69:
70:                 return leafCondition;
71:         }
72:
73:         public static RuleHandle createDisabledEnableRule() {
74:                 final EnableRule enableRule = createEnableRule();
75:                 enableRule.setDisable(true);
76:                 return createRuleHandle(enableRule);
77:         }
78:
79:         public static RuleHandle createEnabledEnableRule() {
80:                 final EnableRule enableRule = createEnableRule();
81:                 enableRule.setDisable(false);
82:                 return createRuleHandle(enableRule);
83:         }
84:
85:         private static RuleHandle createRuleHandle(Rule enableRule) {
86:                 final VElement renderable = createRuleContainerAndAddRule(enableRule);
87:                 final Fan fan = BowlingFactory.eINSTANCE.createFan();
88:                 final Merchandise merchandise = BowlingFactory.eINSTANCE.createMerchandise();
89:                 merchandise.setName("foo");
90:                 fan.setFavouriteMerchandise(merchandise);
91:                 return new RuleHandle(enableRule, renderable, fan);
92:         }
93:
94:         private static VElement createRuleContainerAndAddRule(Rule rule) {
95:                 final VElement renderable = VViewFactory.eINSTANCE.createView();
96:                 renderable.getAttachments().add(rule);
97:                 return renderable;
98:         }
99:
100:         private static EnableRule createEnableRule() {
101:                 return RuleFactory.eINSTANCE.createEnableRule();
102:         }
103:
104:         public static RuleHandle createVisibleShowRule() {
105:                 final ShowRule showRule = RuleFactory.eINSTANCE.createShowRule();
106:                 showRule.setHide(false);
107:                 return createRuleHandle(showRule);
108:         }
109:
110:         public static RuleHandle createInvisibleShowRule() {
111:                 final ShowRule showRule = RuleFactory.eINSTANCE.createShowRule();
112:                 showRule.setHide(true);
113:                 return createRuleHandle(showRule);
114:         }
115:
116: }