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