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