use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class EvaluateEventJsonGeneratorTest method generate.
private void generate(String executionId, Map<String, Object> contextVariables, BiConsumer<DecisionModel, DMNContext> modelConsumer, int expectedEvents) throws JsonProcessingException {
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, () -> executionId);
final DMNContext context = model.newContext(contextVariables);
modelConsumer.accept(model, context);
ArgumentCaptor<EvaluateEvent> eventCaptor = ArgumentCaptor.forClass(EvaluateEvent.class);
verify(eventConsumer, times(expectedEvents)).accept(eventCaptor.capture());
System.out.println(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(eventCaptor.getAllValues()));
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregatorTest method testAggregateOnEvaluateAllWithListWithOnlyFirstEventReturnsNoExecutionSteps.
@Test
void testAggregateOnEvaluateAllWithListWithOnlyFirstEventReturnsNoExecutionSteps() throws IOException {
final DefaultAggregator aggregator = new DefaultAggregator();
final List<EvaluateEvent> events = DecisionTracingTestUtils.readEvaluateEventsFromJsonResource(EVALUATE_ALL_JSON_RESOURCE).stream().limit(1).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);
assertTraceEvent(traceEvent, 2, 2, 0);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregatorTest method testAggregateOnEvaluateAllWithListWithMissingLastAfterEvaluateDecisionEventReturnsNoExecutionStepHierarchy.
@Test
void testAggregateOnEvaluateAllWithListWithMissingLastAfterEvaluateDecisionEventReturnsNoExecutionStepHierarchy() throws IOException {
final DefaultAggregator aggregator = new DefaultAggregator();
final List<EvaluateEvent> events = DecisionTracingTestUtils.readEvaluateEventsFromJsonResource(EVALUATE_ALL_JSON_RESOURCE).stream().filter(e -> !(e.getType() == EvaluateEventType.AFTER_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, 5);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregatorTest method testAggregateOnEvaluateDecisionServiceWithNullModelReturnsDmnModelNotFound.
@Test
void testAggregateOnEvaluateDecisionServiceWithNullModelReturnsDmnModelNotFound() throws IOException {
final DefaultAggregator aggregator = new DefaultAggregator();
List<EvaluateEvent> events = DecisionTracingTestUtils.readEvaluateEventsFromJsonResource(EVALUATE_DECISION_SERVICE_JSON_RESOURCE);
CloudEvent cloudEvent = aggregator.aggregate(null, EVALUATE_DECISION_SERVICE_EXECUTION_ID, events, configBean).orElseThrow(IllegalStateException::new);
TraceEvent traceEvent = assertValidCloudEventAndGetData(cloudEvent, EVALUATE_DECISION_SERVICE_EXECUTION_ID);
assertTraceEvent(traceEvent, 1, 1, 1);
assertTraceEventInternalMessage(traceEvent, InternalMessageType.DMN_MODEL_NOT_FOUND);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregatorTest method testAggregateOnEvaluateDecisionServiceWithListWithMissingBeforeEvaluateDecisionEventReturnsNoExecutionStepHierarchy.
@Test
void testAggregateOnEvaluateDecisionServiceWithListWithMissingBeforeEvaluateDecisionEventReturnsNoExecutionStepHierarchy() throws IOException {
final DefaultAggregator aggregator = new DefaultAggregator();
final List<EvaluateEvent> events = DecisionTracingTestUtils.readEvaluateEventsFromJsonResource(EVALUATE_DECISION_SERVICE_JSON_RESOURCE).stream().filter(e -> !(e.getType() == EvaluateEventType.BEFORE_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, 3);
}
Aggregations