use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class BaseSpringBootDecisionTracingTest method testSyncListenerAndCollectorWithRealEventsIsWorking.
@Test
void testSyncListenerAndCollectorWithRealEventsIsWorking() throws IOException {
final DMNRuntime runtime = buildDMNRuntime();
final DecisionModel model = buildDecisionModel(runtime);
final List<EvaluateEvent> events = testListener(false, runtime, model);
testCollector(events, model);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DecisionTracingListenerTest method testWithRealRuntime.
private static List<EvaluateEvent> testWithRealRuntime(Map<String, Object> contextVariables, int expectedEvents, BiConsumer<DecisionModel, DMNContext> modelConsumer) {
final DMNRuntime runtime = createDMNRuntime();
Consumer<EvaluateEvent> eventConsumer = mock(Consumer.class);
DecisionTracingListener listener = new DecisionTracingListener(eventConsumer);
runtime.addListener(listener);
final DecisionModel model = new DmnDecisionModel(runtime, MODEL_NAMESPACE, MODEL_NAME, () -> TEST_EXECUTION_ID_2);
final DMNContext context = model.newContext(contextVariables);
modelConsumer.accept(model, context);
ArgumentCaptor<EvaluateEvent> eventCaptor = ArgumentCaptor.forClass(EvaluateEvent.class);
verify(eventConsumer, times(expectedEvents)).accept(eventCaptor.capture());
return eventCaptor.getAllValues();
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DecisionTracingListenerTest method assertEvaluateAllEvents.
private static void assertEvaluateAllEvents(List<EvaluateEvent> evaluateEvents, String modelNamespace, String modelName, String executionId) {
assertTrue(evaluateEvents.size() >= 2);
evaluateEvents.forEach(e -> assertEventMatches(modelNamespace, modelName, executionId, e));
EvaluateEvent beforeEvent = evaluateEvents.get(0);
assertSame(EvaluateEventType.BEFORE_EVALUATE_ALL, beforeEvent.getType());
EvaluateEvent afterEvent = evaluateEvents.get(evaluateEvents.size() - 1);
assertSame(EvaluateEventType.AFTER_EVALUATE_ALL, afterEvent.getType());
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregatorTest method testAggregateOnEvaluateDecisionServiceWithListWithMissingAfterEvaluateDecisionEventReturnsNoExecutionStepHierarchy.
@Test
void testAggregateOnEvaluateDecisionServiceWithListWithMissingAfterEvaluateDecisionEventReturnsNoExecutionStepHierarchy() throws IOException {
final DefaultAggregator aggregator = new DefaultAggregator();
final List<EvaluateEvent> events = DecisionTracingTestUtils.readEvaluateEventsFromJsonResource(EVALUATE_DECISION_SERVICE_JSON_RESOURCE).stream().filter(e -> !(e.getType() == EvaluateEventType.AFTER_EVALUATE_DECISION && DECISION_SERVICE_DECISION_ID.equals(e.getNodeId()))).collect(Collectors.toList());
CloudEvent cloudEvent = aggregator.aggregate(model, EVALUATE_DECISION_SERVICE_EXECUTION_ID, events, configBean).orElseThrow(IllegalStateException::new);
TraceEvent traceEvent = assertValidCloudEventAndGetData(cloudEvent, EVALUATE_DECISION_SERVICE_EXECUTION_ID);
assertTraceEventWithNoExecutionStepsHierarchy(traceEvent, 1, 1, 2);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregatorTest method testAggregateOnEvaluateAllWithListWithMissingLastBeforeEvaluateDecisionEventReturnsNoExecutionStepHierarchy.
@Test
void testAggregateOnEvaluateAllWithListWithMissingLastBeforeEvaluateDecisionEventReturnsNoExecutionStepHierarchy() throws IOException {
final DefaultAggregator aggregator = new DefaultAggregator();
final List<EvaluateEvent> events = DecisionTracingTestUtils.readEvaluateEventsFromJsonResource(EVALUATE_ALL_JSON_RESOURCE).stream().filter(e -> !(e.getType() == EvaluateEventType.BEFORE_EVALUATE_DECISION && LAST_DECISION_NODE_ID.equals(e.getNodeId()))).collect(Collectors.toList());
CloudEvent cloudEvent = aggregator.aggregate(model, EVALUATE_ALL_EXECUTION_ID, events, configBean).orElseThrow(IllegalStateException::new);
TraceEvent traceEvent = assertValidCloudEventAndGetData(cloudEvent, EVALUATE_ALL_EXECUTION_ID);
assertTraceEventWithNoExecutionStepsHierarchy(traceEvent, 2, 2, 6);
}
Aggregations