@Test public void testEmitEvent() throws JsonProcessingException { @SuppressWarnings("unchecked") final KafkaTemplate<String, String> mockedKarkaTemplate = mock(KafkaTemplate.class); final List<DecisionModelResource> models = Arrays.asList(makeModel(), makeModel()); final DecisionModelResourcesProvider mockedDecisionModelResourcesProvider = () -> models; final SpringBootModelEventEmitter eventEmitter = new SpringBootModelEventEmitter(mockedDecisionModelResourcesProvider, mockedKarkaTemplate, TEST_TOPIC); eventEmitter.publishDecisionModels(); final ArgumentCaptor<String> topicCaptor = ArgumentCaptor.forClass(String.class); final ArgumentCaptor<String> payloadCaptor = ArgumentCaptor.forClass(String.class); verify(mockedKarkaTemplate, times(2)).send(topicCaptor.capture(), payloadCaptor.capture()); topicCaptor.getAllValues().forEach(v -> assertEquals(TEST_TOPIC, v)); final String rawCloudEvent1 = payloadCaptor.getAllValues().get(0); final String rawCloudEvent2 = payloadCaptor.getAllValues().get(1); final CloudEvent cloudEvent1 = OBJECT_MAPPER.readValue(rawCloudEvent1, CloudEvent.class); final CloudEvent cloudEvent2 = OBJECT_MAPPER.readValue(rawCloudEvent2, CloudEvent.class); assertEquals("id", cloudEvent1.getId()); assertEquals("id", cloudEvent2.getId()); }
@Override @PostConstruct public void publishDecisionModels() { super.publishDecisionModels(); }
SpringBootModelEventEmitter extends BaseModelEventEmitter { @Override @PostConstruct public void publishDecisionModels() { super.publishDecisionModels(); } }
SpringBootModelEventEmitter extends BaseModelEventEmitter { @Override @PostConstruct public void publishDecisionModels() { super.publishDecisionModels(); } @Autowired  SpringBootModelEventEmitter(final DecisionModelResourcesProvider decisionModelResourcesProvider,
                                       final KafkaTemplate<String, String> template,
                                       final @Value(value = "${kogito.addon.tracing.decision.kafka.topic.name:kogito-tracing-model}") String kafkaTopicName); }
SpringBootModelEventEmitter extends BaseModelEventEmitter { @Override @PostConstruct public void publishDecisionModels() { super.publishDecisionModels(); } @Autowired  SpringBootModelEventEmitter(final DecisionModelResourcesProvider decisionModelResourcesProvider,
                                       final KafkaTemplate<String, String> template,
                                       final @Value(value = "${kogito.addon.tracing.decision.kafka.topic.name:kogito-tracing-model}") String kafkaTopicName); @Override @PostConstruct void publishDecisionModels(); @Override void emit(final String payload); }
SpringBootModelEventEmitter extends BaseModelEventEmitter { @Override @PostConstruct public void publishDecisionModels() { super.publishDecisionModels(); } @Autowired  SpringBootModelEventEmitter(final DecisionModelResourcesProvider decisionModelResourcesProvider,
                                       final KafkaTemplate<String, String> template,
                                       final @Value(value = "${kogito.addon.tracing.decision.kafka.topic.name:kogito-tracing-model}") String kafkaTopicName); @Override @PostConstruct void publishDecisionModels(); @Override void emit(final String payload);  }