use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener in project camunda-engine-dmn by camunda.
the class DecisionTableEvaluationHandler method evaluate.
@Override
public DmnDecisionLogicEvaluationEvent evaluate(DmnDecision decision, VariableContext variableContext) {
DmnDecisionTableEvaluationEventImpl evaluationResult = new DmnDecisionTableEvaluationEventImpl();
evaluationResult.setDecisionTable(decision);
DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
evaluationResult.setExecutedDecisionElements(calculateExecutedDecisionElements(decisionTable));
evaluateDecisionTable(decisionTable, variableContext, evaluationResult);
// apply hit policy
decisionTable.getHitPolicyHandler().apply(evaluationResult);
// notify listeners
for (DmnDecisionTableEvaluationListener evaluationListener : evaluationListeners) {
evaluationListener.notify(evaluationResult);
}
return evaluationResult;
}
use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener in project camunda-bpm-platform by camunda.
the class DmnEngineConfigurationTest method setCustomPostTableExecutionListener.
@Test
public void setCustomPostTableExecutionListener() {
// given a DMN engine configuration with custom listener
DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration) DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
DmnDecisionTableEvaluationListener customEvaluationListener = mock(DmnDecisionTableEvaluationListener.class);
List<DmnDecisionTableEvaluationListener> customListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
customListeners.add(customEvaluationListener);
dmnEngineConfiguration.setCustomPostDecisionTableEvaluationListeners(customListeners);
ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();
processEngineConfiguration.setDmnEngineConfiguration(dmnEngineConfiguration);
// when the engine is initialized
engine = processEngineConfiguration.buildProcessEngine();
// then the custom listener should be set on the DMN engine
assertThat(getConfigurationOfDmnEngine().getCustomPostDecisionTableEvaluationListeners(), hasItem(customEvaluationListener));
}
use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener in project camunda-engine-dmn by camunda.
the class DefaultDmnEngineConfigurationApiTest method shouldSetFluentCustomPreDecisionTableEvaluationListeners.
@Test
public void shouldSetFluentCustomPreDecisionTableEvaluationListeners() {
configuration.customPreDecisionTableEvaluationListeners(null);
assertThat(configuration.getCustomPreDecisionTableEvaluationListeners()).isNull();
configuration.customPreDecisionTableEvaluationListeners(Collections.<DmnDecisionTableEvaluationListener>emptyList());
assertThat(configuration.getCustomPreDecisionTableEvaluationListeners()).isEmpty();
ArrayList<DmnDecisionTableEvaluationListener> listeners = new ArrayList<DmnDecisionTableEvaluationListener>();
listeners.add(new DefaultEngineMetricCollector());
listeners.add(new DefaultEngineMetricCollector());
configuration.customPreDecisionTableEvaluationListeners(listeners);
assertThat(configuration.getCustomPreDecisionTableEvaluationListeners()).containsExactlyElementsOf(listeners);
}
use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener in project camunda-engine-dmn by camunda.
the class DefaultDmnEngineConfigurationApiTest method shouldSetFluentCustomPostDecisionTableEvaluationListeners.
@Test
public void shouldSetFluentCustomPostDecisionTableEvaluationListeners() {
configuration.customPostDecisionTableEvaluationListeners(null);
assertThat(configuration.getCustomPostDecisionTableEvaluationListeners()).isNull();
configuration.customPostDecisionTableEvaluationListeners(Collections.<DmnDecisionTableEvaluationListener>emptyList());
assertThat(configuration.getCustomPostDecisionTableEvaluationListeners()).isEmpty();
ArrayList<DmnDecisionTableEvaluationListener> listeners = new ArrayList<DmnDecisionTableEvaluationListener>();
listeners.add(new DefaultEngineMetricCollector());
listeners.add(new DefaultEngineMetricCollector());
configuration.customPostDecisionTableEvaluationListeners(listeners);
assertThat(configuration.getCustomPostDecisionTableEvaluationListeners()).containsExactlyElementsOf(listeners);
}
use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener in project camunda-engine-dmn by camunda.
the class DefaultDmnEngineConfigurationApiTest method shouldInitDecisionTableEvaluationListeners.
@Test
public void shouldInitDecisionTableEvaluationListeners() {
ArrayList<DmnDecisionTableEvaluationListener> preListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
preListeners.add(new DefaultEngineMetricCollector());
ArrayList<DmnDecisionTableEvaluationListener> postListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
postListeners.add(new DefaultEngineMetricCollector());
configuration.customPreDecisionTableEvaluationListeners(preListeners).customPostDecisionTableEvaluationListeners(postListeners).buildEngine();
ArrayList<DmnDecisionTableEvaluationListener> expectedListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
expectedListeners.addAll(preListeners);
expectedListeners.addAll(postListeners);
assertThat(configuration.getDecisionTableEvaluationListeners()).containsExactlyElementsOf(expectedListeners);
}
Aggregations