use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregatorTest method testAggregateOnEvaluateDecisionServiceWithValidListReturnsWorking.
@Test
void testAggregateOnEvaluateDecisionServiceWithValidListReturnsWorking() throws IOException {
final DefaultAggregator aggregator = new DefaultAggregator();
List<EvaluateEvent> events = DecisionTracingTestUtils.readEvaluateEventsFromJsonResource(EVALUATE_DECISION_SERVICE_JSON_RESOURCE);
CloudEvent cloudEvent = aggregator.aggregate(model, EVALUATE_DECISION_SERVICE_EXECUTION_ID, events, configBean).orElseThrow(IllegalStateException::new);
TraceEvent traceEvent = assertValidCloudEventAndGetData(cloudEvent, EVALUATE_DECISION_SERVICE_EXECUTION_ID);
assertTraceEvent(traceEvent, 1, 1, 1);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregator method buildDmnContextEntryTraceExecutionStep.
private static TraceExecutionStep buildDmnContextEntryTraceExecutionStep(long duration, EvaluateEvent afterEvent, List<TraceExecutionStep> children, DMNModel model) {
JsonNode result = EventUtils.jsonNodeFrom(afterEvent.getContextEntryResult().getExpressionResult());
Map<String, String> additionalData = new HashMap<>();
additionalData.put(EXPRESSION_ID_KEY, afterEvent.getContextEntryResult().getExpressionId());
additionalData.put(VARIABLE_ID_KEY, afterEvent.getContextEntryResult().getVariableId());
Optional<String> optDecisionNodeId = Optional.ofNullable(model).map(m -> m.getDecisionByName(afterEvent.getNodeName())).map(DecisionNode::getId);
if (optDecisionNodeId.isPresent()) {
additionalData.put(NODE_ID_KEY, optDecisionNodeId.get());
} else {
additionalData.put(NODE_NAME_KEY, afterEvent.getNodeName());
}
return new TraceExecutionStep(TraceExecutionStepType.DMN_CONTEXT_ENTRY, duration, afterEvent.getContextEntryResult().getVariableName(), result, Collections.emptyList(), additionalData, children);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class BaseQuarkusDecisionTracingTest method testAsyncListenerAndCollectorWithRealEventsIsWorking.
@Test
void testAsyncListenerAndCollectorWithRealEventsIsWorking() throws IOException {
final DMNRuntime runtime = buildDMNRuntime();
final DecisionModel model = buildDecisionModel(runtime);
final List<EvaluateEvent> events = testListener(true, runtime, model);
assertEquals(getEvaluationEventCount(), events.size());
testCollector(events, model);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class BaseQuarkusDecisionTracingTest method testSyncListenerAndCollectorWithRealEventsIsWorking.
@Test
void testSyncListenerAndCollectorWithRealEventsIsWorking() throws IOException {
final DMNRuntime runtime = buildDMNRuntime();
final DecisionModel model = buildDecisionModel(runtime);
final List<EvaluateEvent> events = testListener(false, runtime, model);
assertEquals(getEvaluationEventCount(), events.size());
testCollector(events, model);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class BaseQuarkusDecisionTracingTest method testListener.
private List<EvaluateEvent> testListener(boolean asyncEnabled, DMNRuntime runtime, DecisionModel model) {
final EventBus mockedEventBus = mock(EventBus.class);
final QuarkusDecisionTracingCollector mockedCollector = mock(QuarkusDecisionTracingCollector.class);
QuarkusDecisionTracingListener listener = new QuarkusDecisionTracingListener(mockedEventBus, mockedCollector, asyncEnabled);
runtime.addListener(listener);
final DMNContext context = model.newContext(getContextVariables());
model.evaluateAll(context);
ArgumentCaptor<EvaluateEvent> eventCaptor = ArgumentCaptor.forClass(EvaluateEvent.class);
if (asyncEnabled) {
verify(mockedEventBus, times(getEvaluationEventCount())).send(eq("kogito-tracing-decision_EvaluateEvent"), eventCaptor.capture());
verify(mockedCollector, never()).onEvent(any());
} else {
verify(mockedEventBus, never()).send(eq("kogito-tracing-decision_EvaluateEvent"), any());
verify(mockedCollector, times(getEvaluationEventCount())).onEvent(eventCaptor.capture());
}
return eventCaptor.getAllValues();
}
Aggregations