assertEquals("y", b.get(1));
}
public void testBoundFactFinder() {
final RuleModel model = new RuleModel();
assertNull(model.getBoundFact("x"));
model.lhs = new IPattern[3];
final FactPattern x = new FactPattern("Car");
model.lhs[0] = x;
x.boundName = "x";
assertNotNull(model.getBoundFact("x"));
assertEquals(x, model.getBoundFact("x"));
final FactPattern y = new FactPattern("Car");
model.lhs[1] = y;
y.boundName = "y";
final FactPattern other = new FactPattern("House");
model.lhs[2] = other;
assertEquals(y, model.getBoundFact("y"));
assertEquals(x, model.getBoundFact("x"));
model.rhs = new IAction[1];
final ActionSetField set = new ActionSetField();
set.variable = "x";
model.rhs[0] = set;
assertTrue(model.isBoundFactUsed("x"));
assertFalse(model.isBoundFactUsed("y"));
assertEquals(3, model.lhs.length);
assertFalse(model.removeLhsItem(0));
assertEquals(3, model.lhs.length);
final ActionRetractFact fact = new ActionRetractFact("q");
model.rhs[0] = fact;
assertTrue(model.isBoundFactUsed("q"));
assertFalse(model.isBoundFactUsed("x"));
final XStream xt = new XStream();
xt.alias("rule", RuleModel.class);
xt.alias("fact", FactPattern.class);
xt.alias("retract", ActionRetractFact.class);