### Question:
IntegrationRequestSender { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void sendIntegrationRequest(IntegrationRequest event) { resolver.resolveDestination(event.getIntegrationContext().getConnectorType()).send(buildIntegrationRequestMessage(event)); sendAuditEvent(event); } IntegrationRequestSender(RuntimeBundleProperties runtimeBundleProperties,
                                    MessageChannel auditProducer,
                                    BinderAwareChannelResolver resolver,
                                    RuntimeBundleInfoAppender runtimeBundleInfoAppender,
                                    IntegrationContextMessageBuilderFactory messageBuilderFactory); @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) void sendIntegrationRequest(IntegrationRequest event); static final String CONNECTOR_TYPE; }### Answer:
@Test public void shouldSendIntegrationRequestMessage() { integrationRequestSender.sendIntegrationRequest(integrationRequest); verify(integrationProducer).send(integrationRequestMessageCaptor.capture()); Message<IntegrationRequest> integrationRequestMessage = integrationRequestMessageCaptor.getValue(); IntegrationRequest sentIntegrationRequestEvent = integrationRequestMessage.getPayload(); assertThat(sentIntegrationRequestEvent).isEqualTo(integrationRequest); assertThat(integrationRequestMessage.getHeaders().get(IntegrationRequestSender.CONNECTOR_TYPE)).isEqualTo(CONNECTOR_TYPE); }
@Test public void shouldNotSendIntegrationAuditEventWhenIntegrationAuditEventsAreDisabled() { given(eventsProperties.isIntegrationAuditEventsEnabled()).willReturn(false); integrationRequestSender.sendIntegrationRequest(integrationRequest); verify(auditProducer, never()).send(ArgumentMatchers.any()); }
@Test public void shouldSendIntegrationAuditEventWhenIntegrationAuditEventsAreEnabled() { given(eventsProperties.isIntegrationAuditEventsEnabled()).willReturn(true); integrationRequestSender.sendIntegrationRequest(integrationRequest); verify(auditProducer).send(auditMessageArgumentCaptor.capture()); Message<CloudRuntimeEvent<?, ?>[]> message = auditMessageArgumentCaptor.getValue(); assertThat(message.getPayload()[0]).isInstanceOf(CloudIntegrationRequestedEventImpl.class); Assertions.assertThat(message.getHeaders()) .containsKey("routingKey") .containsKey("messagePayloadType") .containsEntry("parentProcessInstanceId",MY_PARENT_PROC_ID) .containsEntry("processDefinitionKey", MY_PROC_DEF_KEY) .containsEntry("processDefinitionVersion", PROC_DEF_VERSION) .containsEntry("businessKey", BUSINESS_KEY) .containsEntry("connectorType", PAYMENT_CONNECTOR_TYPE) .containsEntry("integrationContextId", INTEGRATION_CONTEXT_ID) .containsEntry("processInstanceId", PROC_INST_ID) .containsEntry("processDefinitionId", PROC_DEF_ID) .containsEntry("appName", APP_NAME) .containsEntry("serviceName",SPRING_APP_NAME) .containsEntry("serviceType",SERVICE_TYPE) .containsEntry("serviceVersion",SERVICE_VERSION) .containsEntry("serviceFullName",APP_NAME); CloudIntegrationRequestedEventImpl integrationRequested = (CloudIntegrationRequestedEventImpl) (message.getPayload())[0]; assertThat(integrationRequested.getEntity().getId()).isEqualTo(INTEGRATION_CONTEXT_ID); assertThat(integrationRequested.getEntity().getProcessInstanceId()).isEqualTo(PROC_INST_ID); assertThat(integrationRequested.getEntity().getProcessDefinitionId()).isEqualTo(PROC_DEF_ID); verify(runtimeBundleInfoAppender).appendRuntimeBundleInfoTo(integrationRequested); }