use of org.drools.drl.ast.descr.AndDescr in project drools by kiegroup.
the class AndDescrTest method testAddUnboundPatternsEtc.
@Test
public void testAddUnboundPatternsEtc() {
final AndDescr and = new AndDescr();
and.addDescr(new NotDescr());
and.addDescr(new PatternDescr("Foo"));
and.addDescr(new NotDescr());
assertEquals(3, and.getDescrs().size());
}
use of org.drools.drl.ast.descr.AndDescr in project drools by kiegroup.
the class AccumulateDescrBuilderImpl method source.
public CEDescrBuilder<AccumulateDescrBuilder<P>, AndDescr> source() {
CEDescrBuilder<AccumulateDescrBuilder<P>, AndDescr> and = new CEDescrBuilderImpl<AccumulateDescrBuilder<P>, AndDescr>(this, new AndDescr());
descr.setInput(and.getDescr());
return and;
}
use of org.drools.drl.ast.descr.AndDescr in project drools by kiegroup.
the class VerifierDataMapsTest method testSaveVerifierComponentAndGetForAllComponentTypes.
@Test
public void testSaveVerifierComponentAndGetForAllComponentTypes() {
RulePackage rulePackage = VerifierComponentMockFactory.createPackage1();
saveVerifierComponentAndGet(rulePackage);
VerifierRule rule = VerifierComponentMockFactory.createRule1();
saveVerifierComponentAndGet(rule);
Pattern pattern = VerifierComponentMockFactory.createPattern1();
saveVerifierComponentAndGet(pattern);
saveVerifierComponentAndGet(new InlineEvalDescr(pattern));
saveVerifierComponentAndGet(new ObjectType(new PackageDescr("testPackage1")));
saveVerifierComponentAndGet(new RuleOperatorDescr(new AndDescr(), rule, OperatorDescrType.AND));
saveVerifierComponentAndGet(new PatternOperatorDescr(pattern, OperatorDescrType.AND));
saveVerifierComponentAndGet(new SubPattern(pattern, 0));
saveVerifierComponentAndGet(new ReturnValueFieldDescr(pattern));
saveVerifierComponentAndGet(new SubRule(rule, 0));
saveVerifierComponentAndGet(new TextConsequence(rule));
saveVerifierComponentAndGet(new PatternVariable(rule));
saveVerifierComponentAndGet(new VerifierAccessorDescr(rule));
saveVerifierComponentAndGet(new VerifierAccumulateDescr(pattern));
saveVerifierComponentAndGet(new VerifierCollectDescr(pattern));
saveVerifierComponentAndGet(new RuleEval(rule));
saveVerifierComponentAndGet(new VerifierFieldAccessDescr(rule));
saveVerifierComponentAndGet(new VerifierFromDescr(pattern));
saveVerifierComponentAndGet(new VerifierMethodAccessDescr(rule));
saveVerifierComponentAndGet(new PatternEval(pattern));
}
use of org.drools.drl.ast.descr.AndDescr in project drools by kiegroup.
the class KiePMMLDescrLhsFactoryTest method declareLhs.
@Test
public void declareLhs() {
String name = "NAME";
String statusToSet = "STATUS_TO_SET";
KiePMMLDroolsRule rule = KiePMMLDroolsRule.builder(name, statusToSet, Collections.emptyList()).build();
KiePMMLDescrLhsFactory.factory(lhsBuilder).declareLhs(rule);
assertNotNull(lhsBuilder.getDescr());
assertNotNull(lhsBuilder.getDescr().getDescrs());
assertEquals(1, lhsBuilder.getDescr().getDescrs().size());
assertTrue(lhsBuilder.getDescr().getDescrs().get(0) instanceof PatternDescr);
PatternDescr patternDescr = (PatternDescr) lhsBuilder.getDescr().getDescrs().get(0);
assertEquals(KiePMMLStatusHolder.class.getSimpleName(), patternDescr.getObjectType());
assertEquals(STATUS_HOLDER, patternDescr.getIdentifier());
assertTrue(patternDescr.getConstraint() instanceof AndDescr);
AndDescr andDescr = (AndDescr) patternDescr.getConstraint();
assertTrue(andDescr.getDescrs().isEmpty());
}
use of org.drools.drl.ast.descr.AndDescr in project drools by kiegroup.
the class KiePMMLDescrLhsFactoryTest method declareConstraintAnd.
@Test
public void declareConstraintAnd() {
String temperatureField = "TEMPERATURE";
String humidityField = "HUMIDITY";
List<KiePMMLFieldOperatorValue> kiePMMLOperatorValues = Arrays.asList(new KiePMMLFieldOperatorValue(temperatureField, BOOLEAN_OPERATOR.AND, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.LESS_THAN, 35)), null), new KiePMMLFieldOperatorValue(humidityField, BOOLEAN_OPERATOR.OR, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.GREATER_THAN, 85)), null));
KiePMMLDescrLhsFactory.factory(lhsBuilder).declareConstraintsAndOr(kiePMMLOperatorValues, lhsBuilder.and());
assertNotNull(lhsBuilder.getDescr());
assertEquals(1, lhsBuilder.getDescr().getDescrs().size());
assertTrue(lhsBuilder.getDescr().getDescrs().get(0) instanceof AndDescr);
AndDescr baseAndDescr = (AndDescr) lhsBuilder.getDescr().getDescrs().get(0);
final List<BaseDescr> descrs = baseAndDescr.getDescrs();
assertNotNull(descrs);
assertEquals(2, descrs.size());
// First KiePMMLFieldOperatorValue
assertTrue(descrs.get(0) instanceof PatternDescr);
PatternDescr patternDescr = (PatternDescr) descrs.get(0);
assertEquals(temperatureField, 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());
String expected = "value < 35";
assertEquals(expected, exprConstraintDescr.getExpression());
// Second KiePMMLFieldOperatorValue
assertTrue(descrs.get(1) instanceof PatternDescr);
patternDescr = (PatternDescr) descrs.get(1);
assertEquals(humidityField, patternDescr.getObjectType());
assertNull(patternDescr.getIdentifier());
assertTrue(patternDescr.getConstraint() instanceof AndDescr);
andDescr = (AndDescr) patternDescr.getConstraint();
assertEquals(1, andDescr.getDescrs().size());
assertTrue(andDescr.getDescrs().get(0) instanceof ExprConstraintDescr);
exprConstraintDescr = (ExprConstraintDescr) andDescr.getDescrs().get(0);
assertFalse(exprConstraintDescr.isNegated());
assertEquals(ExprConstraintDescr.Type.NAMED, exprConstraintDescr.getType());
expected = "value > 85";
assertEquals(expected, exprConstraintDescr.getExpression());
}
Aggregations