use of org.drools.mvel.MVELConstraint in project drools by kiegroup.
the class RuleBuilderTest method testBuildBigIntegerLiteralConstraint.
@Test
public void testBuildBigIntegerLiteralConstraint() throws Exception {
final PackageDescr pkgDescr = new PackageDescr("org.drools");
final RuleDescr ruleDescr = new RuleDescr("Test Rule");
AndDescr andDescr = new AndDescr();
PatternDescr patDescr = new PatternDescr("java.math.BigInteger", "$bd");
ExprConstraintDescr fcd = new ExprConstraintDescr("this==10");
patDescr.addConstraint(fcd);
andDescr.addDescr(patDescr);
ruleDescr.setLhs(andDescr);
ruleDescr.setConsequence("");
pkgDescr.addRule(ruleDescr);
final KnowledgeBuilderImpl kBuilder = new KnowledgeBuilderImpl();
kBuilder.addPackage(pkgDescr);
assertTrue(kBuilder.getErrors().toString(), kBuilder.getErrors().isEmpty());
final RuleImpl rule = kBuilder.getPackages()[0].getRule("Test Rule");
final GroupElement and = rule.getLhs();
final Pattern pat = (Pattern) and.getChildren().get(0);
if (pat.getConstraints().get(0) instanceof MVELConstraint) {
final MVELConstraint fc = (MVELConstraint) pat.getConstraints().get(0);
assertTrue("Wrong class. Expected java.math.BigInteger. Found: " + fc.getField().getValue().getClass(), fc.getField().getValue() instanceof BigInteger);
}
}
Aggregations