Search in sources :

Example 1 with MockAfterEvaluateAllEvent

use of org.kie.kogito.tracing.decision.mock.MockAfterEvaluateAllEvent in project kogito-runtimes by kiegroup.

the class DecisionTracingListenerTest method testListenerWithMockedEventsIsWorking.

@Test
void testListenerWithMockedEventsIsWorking() {
    DMNContextImpl context = new DMNContextImpl();
    DecisionExecutionIdUtils.inject(context, () -> TEST_EXECUTION_ID_1);
    DMNResultImpl result = new DMNResultImpl(new DMNModelImpl());
    result.setContext(context);
    BeforeEvaluateAllEvent beforeEvent = new MockBeforeEvaluateAllEvent(MOCKED_MODEL_NAMESPACE, MOCKED_MODEL_NAME, result);
    AfterEvaluateAllEvent afterEvent = new MockAfterEvaluateAllEvent(MOCKED_MODEL_NAMESPACE, MOCKED_MODEL_NAME, result);
    Consumer<EvaluateEvent> eventConsumer = mock(Consumer.class);
    DecisionTracingListener listener = new DecisionTracingListener(eventConsumer);
    listener.beforeEvaluateAll(beforeEvent);
    listener.afterEvaluateAll(afterEvent);
    ArgumentCaptor<EvaluateEvent> eventCaptor = ArgumentCaptor.forClass(EvaluateEvent.class);
    verify(eventConsumer, times(2)).accept(eventCaptor.capture());
    assertEvaluateAllEvents(eventCaptor.getAllValues(), MOCKED_MODEL_NAMESPACE, MOCKED_MODEL_NAME, TEST_EXECUTION_ID_1);
}
Also used : DMNResultImpl(org.kie.dmn.core.impl.DMNResultImpl) MockAfterEvaluateAllEvent(org.kie.kogito.tracing.decision.mock.MockAfterEvaluateAllEvent) MockBeforeEvaluateAllEvent(org.kie.kogito.tracing.decision.mock.MockBeforeEvaluateAllEvent) AfterEvaluateAllEvent(org.kie.dmn.api.core.event.AfterEvaluateAllEvent) MockAfterEvaluateAllEvent(org.kie.kogito.tracing.decision.mock.MockAfterEvaluateAllEvent) MockBeforeEvaluateAllEvent(org.kie.kogito.tracing.decision.mock.MockBeforeEvaluateAllEvent) BeforeEvaluateAllEvent(org.kie.dmn.api.core.event.BeforeEvaluateAllEvent) DMNModelImpl(org.kie.dmn.core.impl.DMNModelImpl) DMNContextImpl(org.kie.dmn.core.impl.DMNContextImpl) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 AfterEvaluateAllEvent (org.kie.dmn.api.core.event.AfterEvaluateAllEvent)1 BeforeEvaluateAllEvent (org.kie.dmn.api.core.event.BeforeEvaluateAllEvent)1 DMNContextImpl (org.kie.dmn.core.impl.DMNContextImpl)1 DMNModelImpl (org.kie.dmn.core.impl.DMNModelImpl)1 DMNResultImpl (org.kie.dmn.core.impl.DMNResultImpl)1 EvaluateEvent (org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent)1 MockAfterEvaluateAllEvent (org.kie.kogito.tracing.decision.mock.MockAfterEvaluateAllEvent)1 MockBeforeEvaluateAllEvent (org.kie.kogito.tracing.decision.mock.MockBeforeEvaluateAllEvent)1