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);
}
Aggregations