use of org.drools.drl.ast.dsl.CEDescrBuilder in project drools by kiegroup.
the class KiePMMLDescrLhsFactoryTest method commonDeclarePatternWithConstraint.
@Test
public void commonDeclarePatternWithConstraint() {
String patternType = "TEMPERATURE";
String constraintsString = "value < 35";
final CEDescrBuilder<CEDescrBuilder<CEDescrBuilder<RuleDescrBuilder, AndDescr>, NotDescr>, ExistsDescr> existsBuilder = lhsBuilder.not().exists();
KiePMMLDescrLhsFactory.factory(lhsBuilder).commonDeclarePatternWithConstraint(existsBuilder, patternType, constraintsString);
assertNotNull(existsBuilder.getDescr());
final List<BaseDescr> descrs = existsBuilder.getDescr().getDescrs();
assertNotNull(descrs);
assertEquals(1, descrs.size());
assertTrue(descrs.get(0) instanceof PatternDescr);
PatternDescr patternDescr = (PatternDescr) descrs.get(0);
assertEquals(patternType, patternDescr.getObjectType());
assertNull(patternDescr.getIdentifier());
assertTrue(patternDescr.getConstraint() instanceof AndDescr);
AndDescr andDescr = (AndDescr) patternDescr.getConstraint();
assertEquals(1, andDescr.getDescrs().size());
assertTrue(andDescr.getDescrs().get(0) instanceof ExprConstraintDescr);
ExprConstraintDescr exprConstraintDescr = (ExprConstraintDescr) andDescr.getDescrs().get(0);
assertFalse(exprConstraintDescr.isNegated());
assertEquals(ExprConstraintDescr.Type.NAMED, exprConstraintDescr.getType());
assertEquals(constraintsString, exprConstraintDescr.getExpression());
}
Aggregations