Search in sources :

Example 1 with MessageContext

use of org.mule.runtime.core.internal.el.context.MessageContext in project mule by mulesoft.

the class WildcardExpressionLanguageFunctionTestCase method addMessageToContextWithPayload.

@SuppressWarnings("unchecked")
protected void addMessageToContextWithPayload(String payload) throws MuleException {
    message = mock(InternalMessage.class);
    event = getEventBuilder().message(message).build();
    eventBuilder = CoreEvent.builder(event);
    InternalMessage transformedMessage = mock(InternalMessage.class, RETURNS_DEEP_STUBS);
    when(transformedMessage.getPayload()).thenReturn(new TypedValue<>(payload, STRING));
    TransformationService transformationService = mock(TransformationService.class);
    when(muleContext.getTransformationService()).thenReturn(transformationService);
    when(transformationService.transform(any(InternalMessage.class), any(DataType.class))).thenReturn(transformedMessage);
    context.addFinalVariable("message", new MessageContext(event, eventBuilder, muleContext));
}
Also used : InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) DataType(org.mule.runtime.api.metadata.DataType) TransformationService(org.mule.runtime.api.transformation.TransformationService) MessageContext(org.mule.runtime.core.internal.el.context.MessageContext)

Example 2 with MessageContext

use of org.mule.runtime.core.internal.el.context.MessageContext in project mule by mulesoft.

the class RegexExpressionLanguageFunctionTestCase method addMessageToContextWithPayload.

protected void addMessageToContextWithPayload(String payload) throws MuleException {
    message = mock(InternalMessage.class);
    event = getEventBuilder().message(message).build();
    eventBuilder = CoreEvent.builder(event);
    InternalMessage transformedMessage = mock(InternalMessage.class, RETURNS_DEEP_STUBS);
    when(transformedMessage.getPayload()).thenReturn(new TypedValue<>(payload, DataType.fromObject(payload)));
    TransformationService transformationService = mock(TransformationService.class);
    when(muleContext.getTransformationService()).thenReturn(transformationService);
    when(transformationService.transform(any(InternalMessage.class), any(DataType.class))).thenReturn(transformedMessage);
    context.addFinalVariable("message", new MessageContext(event, eventBuilder, muleContext));
}
Also used : InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) DataType(org.mule.runtime.api.metadata.DataType) TransformationService(org.mule.runtime.api.transformation.TransformationService) MessageContext(org.mule.runtime.core.internal.el.context.MessageContext)

Aggregations

DataType (org.mule.runtime.api.metadata.DataType)2 TransformationService (org.mule.runtime.api.transformation.TransformationService)2 MessageContext (org.mule.runtime.core.internal.el.context.MessageContext)2 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)2