@Test public void closedShouldSendEventsRegisteredOnTheCommandContext() { processEngineEventsAggregator.add(event); given(commandContext.getGenericAttribute(MessageProducerCommandContextCloseListener.PROCESS_ENGINE_EVENTS)) .willReturn(Collections.singletonList(event)); closeListener.closed(commandContext); verify(auditChannel).send(messageArgumentCaptor.capture()); assertThat(messageArgumentCaptor.getValue() .getPayload()).containsExactly(event); CloudRuntimeEvent<?, ?>[] result = messageArgumentCaptor.getValue().getPayload(); assertThat(result).hasSize(1); assertThat(result[0].getProcessInstanceId()).isEqualTo(MOCK_PROCESS_INSTANCE_ID); assertThat(result[0].getParentProcessInstanceId()).isEqualTo(MOCK_PARENT_PROCESS_INSTANCE_ID); assertThat(result[0].getBusinessKey()).isEqualTo(MOCK_BUSINESS_KEY); assertThat(result[0].getProcessDefinitionId()).isEqualTo(MOCK_PROCESS_DEFINITION_ID); assertThat(result[0].getProcessDefinitionKey()).isEqualTo(MOCK_PROCESS_DEFINITION_KEY); assertThat(result[0].getProcessDefinitionVersion()).isEqualTo(MOCK_PROCESS_DEFINITION_VERSION); assertThat(result[0].getAppName()).isEqualTo(APP_NAME); assertThat(result[0].getServiceName()).isEqualTo(SPRING_APP_NAME); assertThat(result[0].getServiceType()).isEqualTo(SERVICE_TYPE); assertThat(result[0].getServiceVersion()).isEqualTo(SERVICE_VERSION); }
@Override public void closed(CommandContext commandContext) { List<CloudRuntimeEvent<?, ?>> events = commandContext.getGenericAttribute(PROCESS_ENGINE_EVENTS); if (events != null && !events.isEmpty()) { CloudRuntimeEvent<?, ?>[] payload = events.stream() .filter(CloudRuntimeEventImpl.class::isInstance) .map(CloudRuntimeEventImpl.class::cast) .map(runtimeBundleInfoAppender::appendRuntimeBundleInfoTo) .toArray(CloudRuntimeEvent<?, ?>[]::new); Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderChainFactory.create(null) .withPayload(payload) .build(); producer.auditProducer().send(message); } }
MessageProducerCommandContextCloseListener implements CommandContextCloseListener { @Override public void closed(CommandContext commandContext) { List<CloudRuntimeEvent<?, ?>> events = commandContext.getGenericAttribute(PROCESS_ENGINE_EVENTS); if (events != null && !events.isEmpty()) { CloudRuntimeEvent<?, ?>[] payload = events.stream() .filter(CloudRuntimeEventImpl.class::isInstance) .map(CloudRuntimeEventImpl.class::cast) .map(runtimeBundleInfoAppender::appendRuntimeBundleInfoTo) .toArray(CloudRuntimeEvent<?, ?>[]::new); Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderChainFactory.create(null) .withPayload(payload) .build(); producer.auditProducer().send(message); } } }
MessageProducerCommandContextCloseListener implements CommandContextCloseListener { @Override public void closed(CommandContext commandContext) { List<CloudRuntimeEvent<?, ?>> events = commandContext.getGenericAttribute(PROCESS_ENGINE_EVENTS); if (events != null && !events.isEmpty()) { CloudRuntimeEvent<?, ?>[] payload = events.stream() .filter(CloudRuntimeEventImpl.class::isInstance) .map(CloudRuntimeEventImpl.class::cast) .map(runtimeBundleInfoAppender::appendRuntimeBundleInfoTo) .toArray(CloudRuntimeEvent<?, ?>[]::new); Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderChainFactory.create(null) .withPayload(payload) .build(); producer.auditProducer().send(message); } } MessageProducerCommandContextCloseListener(ProcessEngineChannels producer,
            MessageBuilderChainFactory<ExecutionContext> messageBuilderChainFactory,
            RuntimeBundleInfoAppender runtimeBundleInfoAppender ); }
MessageProducerCommandContextCloseListener implements CommandContextCloseListener { @Override public void closed(CommandContext commandContext) { List<CloudRuntimeEvent<?, ?>> events = commandContext.getGenericAttribute(PROCESS_ENGINE_EVENTS); if (events != null && !events.isEmpty()) { CloudRuntimeEvent<?, ?>[] payload = events.stream() .filter(CloudRuntimeEventImpl.class::isInstance) .map(CloudRuntimeEventImpl.class::cast) .map(runtimeBundleInfoAppender::appendRuntimeBundleInfoTo) .toArray(CloudRuntimeEvent<?, ?>[]::new); Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderChainFactory.create(null) .withPayload(payload) .build(); producer.auditProducer().send(message); } } MessageProducerCommandContextCloseListener(ProcessEngineChannels producer,
            MessageBuilderChainFactory<ExecutionContext> messageBuilderChainFactory,
            RuntimeBundleInfoAppender runtimeBundleInfoAppender ); @Override void closed(CommandContext commandContext); @Override void closing(CommandContext commandContext); @Override void afterSessionsFlush(CommandContext commandContext); @Override void closeFailure(CommandContext commandContext); }
MessageProducerCommandContextCloseListener implements CommandContextCloseListener { @Override public void closed(CommandContext commandContext) { List<CloudRuntimeEvent<?, ?>> events = commandContext.getGenericAttribute(PROCESS_ENGINE_EVENTS); if (events != null && !events.isEmpty()) { CloudRuntimeEvent<?, ?>[] payload = events.stream() .filter(CloudRuntimeEventImpl.class::isInstance) .map(CloudRuntimeEventImpl.class::cast) .map(runtimeBundleInfoAppender::appendRuntimeBundleInfoTo) .toArray(CloudRuntimeEvent<?, ?>[]::new); Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderChainFactory.create(null) .withPayload(payload) .build(); producer.auditProducer().send(message); } } MessageProducerCommandContextCloseListener(ProcessEngineChannels producer,
            MessageBuilderChainFactory<ExecutionContext> messageBuilderChainFactory,
            RuntimeBundleInfoAppender runtimeBundleInfoAppender ); @Override void closed(CommandContext commandContext); @Override void closing(CommandContext commandContext); @Override void afterSessionsFlush(CommandContext commandContext); @Override void closeFailure(CommandContext commandContext); static final String PROCESS_ENGINE_EVENTS; }