Search in sources :

Example 1 with EvaluateEvent

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);
}
Also used : DecisionModel(org.kie.kogito.decision.DecisionModel) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) Test(org.junit.jupiter.api.Test)

Example 2 with EvaluateEvent

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();
}
Also used : DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DMNContext(org.kie.dmn.api.core.DMNContext) DecisionModel(org.kie.kogito.decision.DecisionModel) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DecisionTestUtils.createDMNRuntime(org.kie.kogito.dmn.DecisionTestUtils.createDMNRuntime) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent)

Example 3 with EvaluateEvent

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());
}
Also used : EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent)

Example 4 with EvaluateEvent

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);
}
Also used : TraceEventType(org.kie.kogito.tracing.event.trace.TraceEventType) Assertions.fail(org.junit.jupiter.api.Assertions.fail) DecisionTestUtils.createDMNModel(org.kie.kogito.dmn.DecisionTestUtils.createDMNModel) CloudEvent(io.cloudevents.CloudEvent) MessageCategory(org.kie.kogito.tracing.event.message.MessageCategory) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) EVALUATE_DECISION_SERVICE_JSON_RESOURCE(org.kie.kogito.tracing.decision.DecisionTracingTestUtils.EVALUATE_DECISION_SERVICE_JSON_RESOURCE) EVALUATE_ALL_JSON_RESOURCE(org.kie.kogito.tracing.decision.DecisionTracingTestUtils.EVALUATE_ALL_JSON_RESOURCE) EVALUATE_DECISION_SERVICE_EXECUTION_ID(org.kie.kogito.dmn.DecisionTestUtils.EVALUATE_DECISION_SERVICE_EXECUTION_ID) DMNModel(org.kie.dmn.api.core.DMNModel) BeforeAll(org.junit.jupiter.api.BeforeAll) DECISION_SERVICE_DECISION_ID(org.kie.kogito.dmn.DecisionTestUtils.DECISION_SERVICE_DECISION_ID) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InternalMessageType(org.kie.kogito.tracing.decision.message.InternalMessageType) EvaluateEventType(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEventType) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) FIRST_DECISION_NODE_ID(org.kie.kogito.dmn.DecisionTestUtils.FIRST_DECISION_NODE_ID) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) Test(org.junit.jupiter.api.Test) List(java.util.List) DecisionTestUtils(org.kie.kogito.dmn.DecisionTestUtils) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Collections(java.util.Collections) EVALUATE_ALL_EXECUTION_ID(org.kie.kogito.dmn.DecisionTestUtils.EVALUATE_ALL_EXECUTION_ID) LAST_DECISION_NODE_ID(org.kie.kogito.dmn.DecisionTestUtils.LAST_DECISION_NODE_ID) DecisionTracingTestUtils(org.kie.kogito.tracing.decision.DecisionTracingTestUtils) StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) CloudEvent(io.cloudevents.CloudEvent) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent) Test(org.junit.jupiter.api.Test)

Example 5 with EvaluateEvent

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);
}
Also used : TraceEventType(org.kie.kogito.tracing.event.trace.TraceEventType) Assertions.fail(org.junit.jupiter.api.Assertions.fail) DecisionTestUtils.createDMNModel(org.kie.kogito.dmn.DecisionTestUtils.createDMNModel) CloudEvent(io.cloudevents.CloudEvent) MessageCategory(org.kie.kogito.tracing.event.message.MessageCategory) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) EVALUATE_DECISION_SERVICE_JSON_RESOURCE(org.kie.kogito.tracing.decision.DecisionTracingTestUtils.EVALUATE_DECISION_SERVICE_JSON_RESOURCE) EVALUATE_ALL_JSON_RESOURCE(org.kie.kogito.tracing.decision.DecisionTracingTestUtils.EVALUATE_ALL_JSON_RESOURCE) EVALUATE_DECISION_SERVICE_EXECUTION_ID(org.kie.kogito.dmn.DecisionTestUtils.EVALUATE_DECISION_SERVICE_EXECUTION_ID) DMNModel(org.kie.dmn.api.core.DMNModel) BeforeAll(org.junit.jupiter.api.BeforeAll) DECISION_SERVICE_DECISION_ID(org.kie.kogito.dmn.DecisionTestUtils.DECISION_SERVICE_DECISION_ID) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InternalMessageType(org.kie.kogito.tracing.decision.message.InternalMessageType) EvaluateEventType(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEventType) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) FIRST_DECISION_NODE_ID(org.kie.kogito.dmn.DecisionTestUtils.FIRST_DECISION_NODE_ID) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) Test(org.junit.jupiter.api.Test) List(java.util.List) DecisionTestUtils(org.kie.kogito.dmn.DecisionTestUtils) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Collections(java.util.Collections) EVALUATE_ALL_EXECUTION_ID(org.kie.kogito.dmn.DecisionTestUtils.EVALUATE_ALL_EXECUTION_ID) LAST_DECISION_NODE_ID(org.kie.kogito.dmn.DecisionTestUtils.LAST_DECISION_NODE_ID) DecisionTracingTestUtils(org.kie.kogito.tracing.decision.DecisionTracingTestUtils) StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) CloudEvent(io.cloudevents.CloudEvent) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent) Test(org.junit.jupiter.api.Test)

Aggregations

EvaluateEvent (org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent)28 Test (org.junit.jupiter.api.Test)17 TraceEvent (org.kie.kogito.tracing.event.trace.TraceEvent)16 CloudEvent (io.cloudevents.CloudEvent)15 List (java.util.List)10 Collections (java.util.Collections)9 Collectors (java.util.stream.Collectors)9 DMNModel (org.kie.dmn.api.core.DMNModel)9 EvaluateEventType (org.kie.kogito.tracing.decision.event.evaluate.EvaluateEventType)9 InternalMessageType (org.kie.kogito.tracing.decision.message.InternalMessageType)9 TraceEventType (org.kie.kogito.tracing.event.trace.TraceEventType)9 IOException (java.io.IOException)6 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)6 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)6 Assertions.assertSame (org.junit.jupiter.api.Assertions.assertSame)6 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)6 Assertions.fail (org.junit.jupiter.api.Assertions.fail)6 BeforeAll (org.junit.jupiter.api.BeforeAll)6 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)6 ArrayList (java.util.ArrayList)4