### Question:
CloudProcessDeployedProducer { @EventListener public void sendProcessDeployedEvents(ProcessDeployedEvents processDeployedEvents) { producer.auditProducer().send( runtimeBundleMessageBuilderFactory.create() .withPayload( processDeployedEvents.getProcessDeployedEvents() .stream() .map(processDeployedEvent -> { CloudProcessDeployedEventImpl cloudProcessDeployedEvent = new CloudProcessDeployedEventImpl(processDeployedEvent.getEntity()); cloudProcessDeployedEvent.setProcessModelContent(processDeployedEvent.getProcessModelContent()); runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudProcessDeployedEvent); return cloudProcessDeployedEvent; }) .toArray(CloudRuntimeEvent<?, ?>[]::new)) .build()); } CloudProcessDeployedProducer(RuntimeBundleInfoAppender runtimeBundleInfoAppender,
                                        ProcessEngineChannels producer,
                                        RuntimeBundleMessageBuilderFactory runtimeBundleMessageBuilderFactory); @EventListener void sendProcessDeployedEvents(ProcessDeployedEvents processDeployedEvents);  }### Answer:
@Test public void shouldSendMessageWithDeployedProcessesWhenWebApplicationTypeIsServlet() { ProcessDefinition def1 = mock(ProcessDefinition.class); ProcessDefinition def2 = mock(ProcessDefinition.class); List<ProcessDeployedEvent> processDeployedEventList = Arrays.asList(new ProcessDeployedEventImpl(def1, "content1"), new ProcessDeployedEventImpl(def2, "content2")); given(messageBuilderAppenderChain.withPayload(ArgumentMatchers.<CloudRuntimeEvent<?, ?>[]>any())).willReturn(MessageBuilder.withPayload(new CloudRuntimeEvent<?, ?>[2])); processDeployedProducer.sendProcessDeployedEvents(new ProcessDeployedEvents(processDeployedEventList)); verify(runtimeBundleInfoAppender, times(2)).appendRuntimeBundleInfoTo(any(CloudRuntimeEventImpl.class)); verify(auditProducer).send(any()); verify(messageBuilderAppenderChain).withPayload(messagePayloadCaptor.capture()); List<CloudProcessDeployedEvent> cloudProcessDeployedEvents = Arrays.stream(messagePayloadCaptor.getValue()) .map(CloudProcessDeployedEvent.class::cast) .collect(Collectors.toList()); assertThat(cloudProcessDeployedEvents) .extracting(CloudProcessDeployedEvent::getEntity, CloudProcessDeployedEvent::getProcessModelContent) .containsOnly(tuple(def1, "content1"), tuple(def2, "content2")); }