001: package org.drools.common;
002:
003: import org.drools.Cheese;
004: import org.drools.base.evaluators.Operator;
005: import org.drools.rule.VariableConstraint;
006:
007: public class DefaultBetaConstraintsTest extends BaseBetaConstraintsTest {
008:
009: public void testNoIndexConstraints() {
010: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
011: "cheeseType0", Operator.NOT_EQUAL, "type", Cheese.class);
012: VariableConstraint[] constraints = new VariableConstraint[] { constraint0 };
013: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
014:
015: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
016: "cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
017: constraints = new VariableConstraint[] { constraint0,
018: constraint1 };
019: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
020:
021: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
022: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
023: constraints = new VariableConstraint[] { constraint0,
024: constraint1, constraint2 };
025: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
026:
027: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
028: "cheeseType3", Operator.NOT_EQUAL, "type", Cheese.class);
029: constraints = new VariableConstraint[] { constraint0,
030: constraint1, constraint2, constraint3 };
031: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
032:
033: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
034: "cheeseType4", Operator.NOT_EQUAL, "type", Cheese.class);
035: constraints = new VariableConstraint[] { constraint0,
036: constraint1, constraint2, constraint3, constraint4 };
037: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
038:
039: VariableConstraint constraint5 = (VariableConstraint) getConstraint(
040: "cheeseType5", Operator.NOT_EQUAL, "type", Cheese.class);
041: constraints = new VariableConstraint[] { constraint0,
042: constraint1, constraint2, constraint3, constraint5 };
043: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
044:
045: VariableConstraint constraint6 = (VariableConstraint) getConstraint(
046: "cheeseType6", Operator.NOT_EQUAL, "type", Cheese.class);
047: constraints = new VariableConstraint[] { constraint0,
048: constraint1, constraint2, constraint3, constraint4,
049: constraint5, constraint6 };
050: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
051: }
052:
053: public void testIndexedConstraint() {
054: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
055: "cheeseType0", Operator.EQUAL, "type", Cheese.class);
056: VariableConstraint[] constraints = new VariableConstraint[] { constraint0 };
057: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
058:
059: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
060: "cheeseType1", Operator.EQUAL, "type", Cheese.class);
061: constraints = new VariableConstraint[] { constraint0,
062: constraint1 };
063: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
064:
065: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
066: "cheeseType2", Operator.EQUAL, "type", Cheese.class);
067: constraints = new VariableConstraint[] { constraint0,
068: constraint1, constraint2 };
069: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
070:
071: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
072: "cheeseType3", Operator.EQUAL, "type", Cheese.class);
073: constraints = new VariableConstraint[] { constraint0,
074: constraint1, constraint2, constraint3 };
075: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
076:
077: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
078: "cheeseType4", Operator.EQUAL, "type", Cheese.class);
079: constraints = new VariableConstraint[] { constraint0,
080: constraint1, constraint2, constraint3, constraint4 };
081: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
082:
083: VariableConstraint constraint5 = (VariableConstraint) getConstraint(
084: "cheeseType5", Operator.EQUAL, "type", Cheese.class);
085: constraints = new VariableConstraint[] { constraint0,
086: constraint1, constraint2, constraint3, constraint4,
087: constraint5 };
088: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
089:
090: VariableConstraint constraint6 = (VariableConstraint) getConstraint(
091: "cheeseType6", Operator.EQUAL, "type", Cheese.class);
092: constraints = new VariableConstraint[] { constraint0,
093: constraint1, constraint2, constraint3, constraint4,
094: constraint5, constraint6 };
095: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
096: }
097:
098: public void testSingleIndex() {
099: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
100: "cheeseType1", Operator.EQUAL, "type", Cheese.class);
101: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
102: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
103: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
104: "cheeseType3", Operator.NOT_EQUAL, "type", Cheese.class);
105: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
106: "cheeseType4", Operator.NOT_EQUAL, "type", Cheese.class);
107: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
108: "cheeseType5", Operator.NOT_EQUAL, "type", Cheese.class);
109:
110: VariableConstraint[] constraints = new VariableConstraint[] {
111: constraint0, constraint1, constraint2, constraint3,
112: constraint4 };
113: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
114: }
115:
116: public void testSingleIndexNotFirst() {
117: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
118: "cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
119: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
120: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
121: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
122: "cheeseType3", Operator.NOT_EQUAL, "type", Cheese.class);
123: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
124: "cheeseType4", Operator.NOT_EQUAL, "type", Cheese.class);
125: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
126: "cheeseType5", Operator.EQUAL, "type", Cheese.class);
127:
128: VariableConstraint[] constraints = new VariableConstraint[] {
129: constraint0, constraint1, constraint2, constraint3,
130: constraint4 };
131:
132: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
133: }
134:
135: public void testDoubleIndex() {
136: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
137: "cheeseType1", Operator.EQUAL, "type", Cheese.class);
138: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
139: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
140: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
141: "cheeseType3", Operator.NOT_EQUAL, "type", Cheese.class);
142: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
143: "cheeseType4", Operator.EQUAL, "type", Cheese.class);
144: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
145: "cheeseType5", Operator.NOT_EQUAL, "type", Cheese.class);
146:
147: VariableConstraint[] constraints = new VariableConstraint[] {
148: constraint0, constraint1, constraint2, constraint3,
149: constraint4 };
150:
151: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
152: }
153:
154: public void testDoubleIndexNotFirst() {
155: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
156: "cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
157: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
158: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
159: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
160: "cheeseType3", Operator.NOT_EQUAL, "type", Cheese.class);
161: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
162: "cheeseType4", Operator.EQUAL, "type", Cheese.class);
163: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
164: "cheeseType5", Operator.EQUAL, "type", Cheese.class);
165:
166: VariableConstraint[] constraints = new VariableConstraint[] {
167: constraint0, constraint1, constraint2, constraint3,
168: constraint4 };
169:
170: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
171: }
172:
173: public void testTripleIndex() {
174: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
175: "cheeseType1", Operator.EQUAL, "type", Cheese.class);
176: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
177: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
178: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
179: "cheeseType3", Operator.NOT_EQUAL, "type", Cheese.class);
180: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
181: "cheeseType4", Operator.EQUAL, "type", Cheese.class);
182: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
183: "cheeseType5", Operator.EQUAL, "type", Cheese.class);
184:
185: VariableConstraint[] constraints = new VariableConstraint[] {
186: constraint0, constraint1, constraint2, constraint3,
187: constraint4 };
188:
189: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
190: }
191:
192: public void testTripleIndexNotFirst() {
193: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
194: "cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
195: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
196: "cheeseType2", Operator.EQUAL, "type", Cheese.class);
197: VariableConstraint constraint2 = (VariableConstraint) getConstraint(
198: "cheeseType3", Operator.NOT_EQUAL, "type", Cheese.class);
199: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
200: "cheeseType4", Operator.EQUAL, "type", Cheese.class);
201: VariableConstraint constraint4 = (VariableConstraint) getConstraint(
202: "cheeseType5", Operator.EQUAL, "type", Cheese.class);
203:
204: VariableConstraint[] constraints = new VariableConstraint[] {
205: constraint0, constraint1, constraint2, constraint3,
206: constraint4 };
207:
208: checkBetaConstraints(constraints, DefaultBetaConstraints.class);
209: }
210:
211: }
|