001: package org.drools.common;
002:
003: import java.util.ArrayList;
004: import java.util.List;
005:
006: import org.drools.Cheese;
007: import org.drools.RuleBaseConfiguration;
008: import org.drools.base.ClassFieldExtractorCache;
009: import org.drools.base.ClassObjectType;
010: import org.drools.base.evaluators.Operator;
011: import org.drools.base.evaluators.StringFactory;
012: import org.drools.reteoo.BetaMemory;
013: import org.drools.rule.Declaration;
014: import org.drools.rule.Pattern;
015: import org.drools.rule.VariableConstraint;
016: import org.drools.spi.BetaNodeFieldConstraint;
017: import org.drools.spi.Evaluator;
018: import org.drools.spi.FieldExtractor;
019: import org.drools.util.FactHandleIndexHashTable;
020: import org.drools.util.FactHashTable;
021: import org.drools.util.TupleHashTable;
022: import org.drools.util.TupleIndexHashTable;
023: import org.drools.util.AbstractHashTable.FieldIndex;
024: import org.drools.util.AbstractHashTable.Index;
025:
026: import junit.framework.TestCase;
027:
028: public class TripleBetaConstraintsTest extends BaseBetaConstraintsTest {
029:
030: public void testNoneIndxed() {
031: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
032: "cheeseType0", Operator.NOT_EQUAL, "type", Cheese.class);
033: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
034: "cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
035: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
036: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
037: VariableConstraint[] constraints = new VariableConstraint[] {
038: constraint0, constraint1, constraint3 };
039: checkBetaConstraints(constraints, TripleBetaConstraints.class);
040: }
041:
042: public void testOneIndxed() {
043: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
044: "cheeseType0", Operator.EQUAL, "type", Cheese.class);
045: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
046: "cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
047: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
048: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
049: VariableConstraint[] constraints = new VariableConstraint[] {
050: constraint0, constraint1, constraint3 };
051: checkBetaConstraints(constraints, TripleBetaConstraints.class);
052:
053: constraint0 = (VariableConstraint) getConstraint("cheeseType0",
054: Operator.NOT_EQUAL, "type", Cheese.class);
055: constraint1 = (VariableConstraint) getConstraint("cheeseType1",
056: Operator.EQUAL, "type", Cheese.class);
057: constraint3 = (VariableConstraint) getConstraint("cheeseType2",
058: Operator.NOT_EQUAL, "type", Cheese.class);
059: constraints = new VariableConstraint[] { constraint0,
060: constraint1, constraint3 };
061: checkBetaConstraints(constraints, TripleBetaConstraints.class);
062:
063: constraint0 = (VariableConstraint) getConstraint("cheeseType0",
064: Operator.NOT_EQUAL, "type", Cheese.class);
065: constraint1 = (VariableConstraint) getConstraint("cheeseType1",
066: Operator.NOT_EQUAL, "type", Cheese.class);
067: constraint3 = (VariableConstraint) getConstraint("cheeseType2",
068: Operator.EQUAL, "type", Cheese.class);
069: constraints = new VariableConstraint[] { constraint0,
070: constraint1, constraint3 };
071: checkBetaConstraints(constraints, TripleBetaConstraints.class);
072: }
073:
074: public void testTwoIndxed() {
075: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
076: "cheeseType0", Operator.EQUAL, "type", Cheese.class);
077: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
078: "cheeseType1", Operator.EQUAL, "type", Cheese.class);
079: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
080: "cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
081: VariableConstraint[] constraints = new VariableConstraint[] {
082: constraint0, constraint1, constraint3 };
083: checkBetaConstraints(constraints, TripleBetaConstraints.class);
084:
085: constraint0 = (VariableConstraint) getConstraint("cheeseType0",
086: Operator.EQUAL, "type", Cheese.class);
087: constraint1 = (VariableConstraint) getConstraint("cheeseType1",
088: Operator.NOT_EQUAL, "type", Cheese.class);
089: constraint3 = (VariableConstraint) getConstraint("cheeseType2",
090: Operator.EQUAL, "type", Cheese.class);
091: constraints = new VariableConstraint[] { constraint0,
092: constraint1, constraint3 };
093: checkBetaConstraints(constraints, TripleBetaConstraints.class);
094:
095: constraint0 = (VariableConstraint) getConstraint("cheeseType0",
096: Operator.NOT_EQUAL, "type", Cheese.class);
097: constraint1 = (VariableConstraint) getConstraint("cheeseType1",
098: Operator.EQUAL, "type", Cheese.class);
099: constraint3 = (VariableConstraint) getConstraint("cheeseType2",
100: Operator.EQUAL, "type", Cheese.class);
101: constraints = new VariableConstraint[] { constraint0,
102: constraint1, constraint3 };
103: checkBetaConstraints(constraints, TripleBetaConstraints.class);
104: }
105:
106: public void testThreeIndxed() {
107: VariableConstraint constraint0 = (VariableConstraint) getConstraint(
108: "cheeseType0", Operator.EQUAL, "type", Cheese.class);
109: VariableConstraint constraint1 = (VariableConstraint) getConstraint(
110: "cheeseType1", Operator.EQUAL, "type", Cheese.class);
111: VariableConstraint constraint3 = (VariableConstraint) getConstraint(
112: "cheeseType2", Operator.EQUAL, "type", Cheese.class);
113: VariableConstraint[] constraints = new VariableConstraint[] {
114: constraint0, constraint1, constraint3 };
115: checkBetaConstraints(constraints, TripleBetaConstraints.class);
116: }
117: }
|