FPLParser parser = new FPLParser(string, null, null);
Predicate pred = parser.expression();
Assert.assertTrue("Parsed predicate should be a AndPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof AndPredicate);
AndPredicate val = (AndPredicate)pred;
Assert.assertTrue("Left side is a bool value", val.getLeft() instanceof BooleanValue);
Assert.assertTrue("Right side is a and pred", val.getRight() instanceof AndPredicate);
FreeVars vars = val.getFreeVariables();
Assert.assertEquals("Should only contain 4 free variables", 4, vars.size());
vars = val.getLeft().getFreeVariables();
Assert.assertEquals("Should only contain one free variables", 1, vars.size());
Assert.assertEquals("a should have a boolean type", "boolean", vars.getType(new SpecVar("a")));
vars = val.getRight().getFreeVariables();
Assert.assertEquals("Should only contain 3 free variables", 3, vars.size());
val = (AndPredicate)val.getRight();
Assert.assertTrue("Left side is a bool value", val.getLeft() instanceof BooleanValue);
Assert.assertTrue("Right side is a and pred", val.getRight() instanceof AndPredicate);
vars = val.getLeft().getFreeVariables();
Assert.assertEquals("Should only contain one free variables", 1, vars.size());
Assert.assertEquals("b should have a boolean type", "boolean", vars.getType(new SpecVar("b")));
vars = val.getRight().getFreeVariables();
Assert.assertEquals("Should only contain 2 free variables", 2, vars.size());
val = (AndPredicate)val.getRight();
Assert.assertTrue("Left side is a bool value", val.getLeft() instanceof BooleanValue);
Assert.assertTrue("Right side is a bool value", val.getRight() instanceof BooleanValue);
vars = val.getLeft().getFreeVariables();
Assert.assertEquals("Should only contain one free variables", 1, vars.size());
Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));
vars = val.getRight().getFreeVariables();
Assert.assertEquals("Should only contain one free variables", 1, vars.size());
Assert.assertEquals("d should have a boolean type", "boolean", vars.getType(new SpecVar("d")));
}