Search in sources :

Example 11 with KiePMMLOperatorValue

use of org.kie.pmml.models.drools.tuples.KiePMMLOperatorValue in project drools by kiegroup.

the class KiePMMLDescrRulesFactoryTest method declareRule.

@Test
public void declareRule() {
    String name = "NAME";
    String statusToSet = "STATUS_TO_SET";
    String patternType = "TEMPERATURE";
    String agendaGroup = "agendaGroup";
    String activationGroup = "activationGroup";
    List<KiePMMLFieldOperatorValue> orConstraints = Arrays.asList(new KiePMMLFieldOperatorValue(patternType, BOOLEAN_OPERATOR.OR, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.LESS_THAN, 35)), null), new KiePMMLFieldOperatorValue(patternType, BOOLEAN_OPERATOR.AND, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.GREATER_THAN, 85)), null));
    KiePMMLDroolsRule rule = KiePMMLDroolsRule.builder(name, statusToSet, Collections.emptyList()).withAgendaGroup(agendaGroup).withActivationGroup(activationGroup).withOrConstraints(orConstraints).build();
    KiePMMLDescrRulesFactory.factory(builder).declareRule(rule);
    assertNotNull(builder.getDescr().getRules());
    assertEquals(1, builder.getDescr().getRules().size());
    final RuleDescr retrieved = builder.getDescr().getRules().get(0);
    assertEquals(name, retrieved.getName());
    assertEquals(2, retrieved.getAttributes().size());
    assertTrue(retrieved.getAttributes().containsKey("agenda-group"));
    assertEquals(agendaGroup, retrieved.getAttributes().get("agenda-group").getValue());
    assertTrue(retrieved.getAttributes().containsKey("activation-group"));
    assertEquals(activationGroup, retrieved.getAttributes().get("activation-group").getValue());
}
Also used : KiePMMLOperatorValue(org.kie.pmml.models.drools.tuples.KiePMMLOperatorValue) RuleDescr(org.drools.drl.ast.descr.RuleDescr) KiePMMLDroolsRule(org.kie.pmml.models.drools.ast.KiePMMLDroolsRule) KiePMMLFieldOperatorValue(org.kie.pmml.models.drools.ast.KiePMMLFieldOperatorValue) Test(org.junit.Test)

Aggregations

KiePMMLOperatorValue (org.kie.pmml.models.drools.tuples.KiePMMLOperatorValue)11 KiePMMLFieldOperatorValue (org.kie.pmml.models.drools.ast.KiePMMLFieldOperatorValue)9 Test (org.junit.Test)8 AndDescr (org.drools.drl.ast.descr.AndDescr)4 ExprConstraintDescr (org.drools.drl.ast.descr.ExprConstraintDescr)4 PatternDescr (org.drools.drl.ast.descr.PatternDescr)4 BaseDescr (org.drools.drl.ast.descr.BaseDescr)3 ArrayList (java.util.ArrayList)2 SimplePredicate (org.dmg.pmml.SimplePredicate)2 OrDescr (org.drools.drl.ast.descr.OrDescr)2 BOOLEAN_OPERATOR (org.kie.pmml.api.enums.BOOLEAN_OPERATOR)2 OPERATOR (org.kie.pmml.api.enums.OPERATOR)2 PMMLModelTestUtils.getRandomObject (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomObject)2 KiePMMLDroolsRule (org.kie.pmml.models.drools.ast.KiePMMLDroolsRule)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1