Search in sources :

Example 1 with StaticConfigBean

use of org.kie.kogito.conf.StaticConfigBean in project kogito-runtimes by kiegroup.

the class DecisionTracingCollectorTest method initModel.

@BeforeAll
static void initModel() {
    model = createDMNModel();
    configBean = new StaticConfigBean();
}
Also used : StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with StaticConfigBean

use of org.kie.kogito.conf.StaticConfigBean in project kogito-runtimes by kiegroup.

the class BaseSpringBootDecisionTracingTest method testCollector.

@SuppressWarnings("unchecked")
private void testCollector(List<EvaluateEvent> events, DecisionModel model) throws IOException {
    final DecisionModels mockedDecisionModels = mock(DecisionModels.class);
    when(mockedDecisionModels.getDecisionModel(getTestModelNameSpace(), getTestModelName())).thenReturn(model);
    final Application mockedApplication = mock(Application.class);
    when(mockedApplication.get(any())).thenReturn(mockedDecisionModels);
    final ConfigBean configBean = new StaticConfigBean(TEST_SERVICE_URL, true, null);
    final KafkaTemplate<String, String> mockedTemplate = mock(KafkaTemplate.class);
    final SpringBootTraceEventEmitter eventEmitter = new SpringBootTraceEventEmitter(mockedTemplate, TEST_KAFKA_TOPIC);
    SpringBootDecisionTracingCollector collector = new SpringBootDecisionTracingCollector(eventEmitter, configBean, mockedApplication);
    events.forEach(collector::onApplicationEvent);
    ArgumentCaptor<String> payloadCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockedTemplate).send(eq(TEST_KAFKA_TOPIC), payloadCaptor.capture());
    CloudEvent cloudEvent = CloudEventUtils.decode(payloadCaptor.getValue()).orElseThrow(() -> new IllegalStateException("Can't decode CloudEvent"));
    assertEquals(TEST_EXECUTION_ID, cloudEvent.getId());
    assertNotNull(cloudEvent.getData());
    TraceEvent traceEvent = MAPPER.readValue(cloudEvent.getData().toBytes(), TraceEvent.class);
    assertNotNull(traceEvent);
    assertEquals(TEST_SERVICE_URL, traceEvent.getHeader().getResourceId().getServiceUrl());
}
Also used : StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) ConfigBean(org.kie.kogito.conf.ConfigBean) StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) DecisionModels(org.kie.kogito.decision.DecisionModels) Application(org.kie.kogito.Application) CloudEvent(io.cloudevents.CloudEvent) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent)

Example 3 with StaticConfigBean

use of org.kie.kogito.conf.StaticConfigBean in project kogito-runtimes by kiegroup.

the class DefaultAggregatorTest method initModel.

@BeforeAll
static void initModel() {
    model = createDMNModel();
    configBean = new StaticConfigBean();
}
Also used : StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with StaticConfigBean

use of org.kie.kogito.conf.StaticConfigBean in project kogito-runtimes by kiegroup.

the class BaseQuarkusDecisionTracingTest method testCollector.

private void testCollector(List<EvaluateEvent> events, DecisionModel model) throws IOException {
    AssertSubscriber<String> subscriber = AssertSubscriber.create(1);
    final DecisionModels mockedDecisionModels = mock(DecisionModels.class);
    when(mockedDecisionModels.getDecisionModel(getTestModelNameSpace(), getTestModelName())).thenReturn(model);
    final Application mockedApplication = mock(Application.class);
    when(mockedApplication.get(any())).thenReturn(mockedDecisionModels);
    final ConfigBean configBean = new StaticConfigBean(TEST_SERVICE_URL, true, null);
    final QuarkusTraceEventEmitter eventEmitter = new QuarkusTraceEventEmitter();
    QuarkusDecisionTracingCollector collector = new QuarkusDecisionTracingCollector(eventEmitter, configBean, mockedApplication);
    eventEmitter.getEventPublisher().subscribe(subscriber);
    events.forEach(collector::onEvent);
    subscriber.assertNotTerminated();
    List<String> items = subscriber.getItems();
    assertEquals(1, items.size());
    CloudEvent cloudEvent = CloudEventUtils.decode(items.get(0)).orElseThrow(() -> new IllegalStateException("Can't decode CloudEvent"));
    assertEquals(TEST_EXECUTION_ID, cloudEvent.getId());
    assertNotNull(cloudEvent.getData());
    TraceEvent traceEvent = MAPPER.readValue(cloudEvent.getData().toBytes(), TraceEvent.class);
    assertNotNull(traceEvent);
    assertEquals(TEST_SERVICE_URL, traceEvent.getHeader().getResourceId().getServiceUrl());
}
Also used : StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) ConfigBean(org.kie.kogito.conf.ConfigBean) StaticConfigBean(org.kie.kogito.conf.StaticConfigBean) DecisionModels(org.kie.kogito.decision.DecisionModels) Application(org.kie.kogito.Application) CloudEvent(io.cloudevents.CloudEvent) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent)

Aggregations

StaticConfigBean (org.kie.kogito.conf.StaticConfigBean)4 CloudEvent (io.cloudevents.CloudEvent)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 Application (org.kie.kogito.Application)2 ConfigBean (org.kie.kogito.conf.ConfigBean)2 DecisionModels (org.kie.kogito.decision.DecisionModels)2 TraceEvent (org.kie.kogito.tracing.event.trace.TraceEvent)2