use of org.kie.dmn.feel.codegen.feel11.ProcessedExpression in project drools by kiegroup.
the class FEELParserSeverityTest method parseSeverity.
private ASTNode parseSeverity(String input, FEELEvent.Severity severity) {
FEELEventListenersManager mgr = new FEELEventListenersManager();
CompilerContext ctx = new CompilerContextImpl(mgr);
final FEELEventListener listener = mock(FEELEventListener.class);
mgr.addListener(listener);
mgr.addListener(e -> LOG.info("{}", e));
ProcessedExpression processedExpression = new ProcessedExpression(input, ctx, ProcessedFEELUnit.DefaultMode.Interpreted, Collections.emptyList());
final ArgumentCaptor<FEELEvent> captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, atLeastOnce()).onEvent(captor.capture());
assertThat(captor.getValue().getSeverity(), is(severity));
return processedExpression.getInterpreted().getASTNode();
}
use of org.kie.dmn.feel.codegen.feel11.ProcessedExpression in project drools by kiegroup.
the class DMNDTAnalyser method compileTableRules.
private void compileTableRules(DecisionTable dt, DDTATable ddtaTable) {
for (int jRowIdx = 0; jRowIdx < dt.getRule().size(); jRowIdx++) {
DecisionRule r = dt.getRule().get(jRowIdx);
DDTARule ddtaRule = new DDTARule();
int jColIdx = 0;
for (UnaryTests ie : r.getInputEntry()) {
ProcessedUnaryTest compileUnaryTests = (ProcessedUnaryTest) FEEL.compileUnaryTests(ie.getText(), FEEL.newCompilerContext());
UnaryTestInterpretedExecutableExpression interpreted = compileUnaryTests.getInterpreted();
UnaryTestListNode utln = (UnaryTestListNode) interpreted.getASTNode();
DDTAInputClause ddtaInputClause = ddtaTable.getInputs().get(jColIdx);
DDTAInputEntry ddtaInputEntry = new DDTAInputEntry(utln.getElements(), toIntervals(utln.getElements(), utln.isNegated(), ddtaInputClause.getDomainMinMax(), ddtaInputClause.getDiscreteValues(), jRowIdx + 1, jColIdx + 1));
for (Interval interval : ddtaInputEntry.getIntervals()) {
Interval domainMinMax = ddtaTable.getInputs().get(jColIdx).getDomainMinMax();
if (!domainMinMax.includes(interval)) {
throw new IllegalStateException(MsgUtil.createMessage(Msg.DTANALYSIS_ERROR_RULE_OUTSIDE_DOMAIN, jRowIdx + 1, interval, domainMinMax, jColIdx + 1));
}
}
ddtaRule.getInputEntry().add(ddtaInputEntry);
jColIdx++;
}
for (LiteralExpression oe : r.getOutputEntry()) {
ProcessedExpression compile = (ProcessedExpression) FEEL.compile(oe.getText(), FEEL.newCompilerContext());
InterpretedExecutableExpression interpreted = compile.getInterpreted();
BaseNode outputEntryNode = (BaseNode) interpreted.getASTNode();
Comparable<?> value = valueFromNode(outputEntryNode, outputClauseVisitor);
ddtaRule.getOutputEntry().add(value);
jColIdx++;
}
ddtaTable.addRule(ddtaRule);
}
}
Aggregations