use of org.mule.runtime.core.internal.interception.DefaultInterceptionEvent in project mule by mulesoft.
the class DefaultInterceptionEventTestCase method correlationIdLegacy.
@Test
public void correlationIdLegacy() throws MuleException {
final InternalEvent event = InternalEvent.builder(create("id", "serverId", TEST_CONNECTOR_LOCATION, mock(FlowExceptionHandler.class))).correlationId("corr1").message(of(TEST_PAYLOAD)).build();
final DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(event);
assertThat(interceptionEvent.getCorrelationId(), is("corr1"));
}
use of org.mule.runtime.core.internal.interception.DefaultInterceptionEvent in project mule by mulesoft.
the class DefaultInterceptionEventTestCase method updateSession.
@Test
public void updateSession() throws MuleException {
final InternalEvent event = this.<InternalEvent.Builder>getEventBuilder().message(of(TEST_PAYLOAD)).build();
final DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(event);
final MuleSession session = ((PrivilegedEvent) event).getSession();
session.setProperty("myKey", "myValue");
interceptionEvent.session(session);
assertThat(((PrivilegedEvent) interceptionEvent.resolve()).getSession().getProperty("myKey"), is("myValue"));
}
use of org.mule.runtime.core.internal.interception.DefaultInterceptionEvent in project mule by mulesoft.
the class ReactiveAroundInterceptorAdapter method doAround.
private CompletableFuture<InternalEvent> doAround(InternalEvent event, ProcessorInterceptor interceptor, Processor component, Map<String, String> dslParameters, ReactiveProcessor next) {
final InternalEvent eventWithResolvedParams = addResolvedParameters(event, component, dslParameters);
DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(eventWithResolvedParams);
final ReactiveInterceptionAction reactiveInterceptionAction = new ReactiveInterceptionAction(interceptionEvent, next, component, ((PrivilegedMuleContext) getMuleContext()).getErrorTypeLocator());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Calling around() for '{}' in processor '{}'...", interceptor, ((Component) component).getLocation().getLocation());
}
try {
return withContextClassLoader(interceptor.getClass().getClassLoader(), () -> interceptor.around(((Component) component).getLocation(), getResolvedParams(eventWithResolvedParams), interceptionEvent, reactiveInterceptionAction)).exceptionally(t -> {
if (t instanceof MessagingException) {
throw new CompletionException(t);
} else {
throw new CompletionException(createMessagingException(eventWithResolvedParams, t instanceof CompletionException ? t.getCause() : t, ((Component) component)));
}
}).thenApply(interceptedEvent -> interceptedEvent != null ? ((DefaultInterceptionEvent) interceptedEvent).resolve() : null);
} catch (Exception e) {
throw propagate(createMessagingException(interceptionEvent.resolve(), e, (Component) component));
}
}
use of org.mule.runtime.core.internal.interception.DefaultInterceptionEvent in project mule by mulesoft.
the class DefaultInterceptionEventTestCase method correlationIdGiven.
@Test
public void correlationIdGiven() throws MuleException {
final InternalEvent event = InternalEvent.builder(create("id", "serverId", TEST_CONNECTOR_LOCATION, "corr1", mock(FlowExceptionHandler.class))).message(of(TEST_PAYLOAD)).build();
final DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(event);
assertThat(interceptionEvent.getCorrelationId(), is("corr1"));
}
use of org.mule.runtime.core.internal.interception.DefaultInterceptionEvent in project mule by mulesoft.
the class DefaultInterceptionEventTestCase method correlationIdAutogenerated.
@Test
public void correlationIdAutogenerated() throws MuleException {
final InternalEvent event = InternalEvent.builder(create("id", "serverId", TEST_CONNECTOR_LOCATION, mock(FlowExceptionHandler.class))).message(of(TEST_PAYLOAD)).build();
final DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(event);
assertThat(interceptionEvent.getCorrelationId(), is("id"));
}
Aggregations