Search in sources :

Example 11 with DefaultMuleSession

use of org.mule.runtime.core.privileged.event.DefaultMuleSession in project mule by mulesoft.

the class AbstractPolicyProcessorTestCase method sessionModifiedBeforeNextProcessorIsPropagatedToIt.

@Test
public void sessionModifiedBeforeNextProcessorIsPropagatedToIt() throws MuleException {
    DefaultMuleSession session = new DefaultMuleSession();
    CoreEvent modifiedSessionEvent = PrivilegedEvent.builder(initialEvent).session(session).build();
    when(flowProcessor.apply(any())).thenReturn(just(modifiedSessionEvent));
    when(policy.getPolicyChain().apply(any())).thenAnswer(invocation -> just(modifiedSessionEvent).transform(policyStateHandler.retrieveNextOperation(executionId)));
    just(initialEvent).transform(policyProcessor).block();
    verify(flowProcessor).apply(eventCaptor.capture());
    assertEquals(((PrivilegedEvent) from(eventCaptor.getValue()).block()).getSession(), session);
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DefaultMuleSession(org.mule.runtime.core.privileged.event.DefaultMuleSession) Test(org.junit.Test)

Aggregations

DefaultMuleSession (org.mule.runtime.core.privileged.event.DefaultMuleSession)11 Test (org.junit.Test)9 MuleSession (org.mule.runtime.core.privileged.event.MuleSession)9 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)8 Message (org.mule.runtime.api.message.Message)6 EventContext (org.mule.runtime.api.event.EventContext)4 Flow (org.mule.runtime.core.api.construct.Flow)4 MuleTestUtils.createAndRegisterFlow (org.mule.tck.MuleTestUtils.createAndRegisterFlow)4 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)2 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)2 MuleTestUtils.createFlow (org.mule.tck.MuleTestUtils.createFlow)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 Location (org.mule.runtime.api.component.location.Location)1 Builder (org.mule.runtime.core.api.event.CoreEvent.Builder)1 Processor (org.mule.runtime.core.api.processor.Processor)1