use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class MVELExpressionLanguageTestCase method testEvaluateStringMuleMessage.
@Test
public void testEvaluateStringMuleMessage() throws Exception {
PrivilegedEvent event = createEvent();
// Event context
assertEquals("foo", evaluate("message.payload", event));
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class MVELExpressionLanguageTestCase method messageTakesPrecedenceOverEverything.
@Test
public void messageTakesPrecedenceOverEverything() throws Exception {
mvel.setAliases(singletonMap("message", "'other1'"));
PrivilegedEvent event = this.<PrivilegedEvent.Builder>getEventBuilder().message(of("")).addVariable("message", "other2").build();
((MuleContextWithRegistries) muleContext).getRegistry().registerObject("foo", (ExpressionLanguageExtension) context -> context.addVariable("message", "other3"));
mvel.initialise();
assertEquals(MessageContext.class, evaluate("message", event).getClass());
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class MVELExpressionLanguageTestCase method testEvaluateAttributes.
@Test
public void testEvaluateAttributes() throws Exception {
PrivilegedEvent event = createEventWithAttributes();
// Event context
assertEquals("number 1", evaluate("attributes.one", event));
assertEquals("number 2", evaluate("attributes.two", event));
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class ExpressionLanguageEnrichmentTestCase method enrichSessionVariable.
@Test
public void enrichSessionVariable() throws Exception {
CoreEvent event = eventBuilder(muleContext).message(Message.of("")).build();
CoreEvent.Builder eventBuilder = CoreEvent.builder(event);
expressionLanguage.enrich("sessionVars['foo']", event, eventBuilder, ((Component) flowConstruct).getLocation(), "bar");
assertThat(((PrivilegedEvent) eventBuilder.build()).getSession().getProperty("foo"), equalTo("bar"));
assertThat(eventBuilder.build().getVariables().keySet(), not(hasItem("foo")));
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class MVELExpressionLanguageTestCase method appTakesPrecedenceOverEverything.
@Test
public void appTakesPrecedenceOverEverything() throws Exception {
mvel.setAliases(singletonMap("app", "'other1'"));
PrivilegedEvent event = this.<PrivilegedEvent.Builder>getEventBuilder().message(of("")).addVariable("app", "otherb").build();
((MuleContextWithRegistries) muleContext).getRegistry().registerObject("foo", (ExpressionLanguageExtension) context -> context.addVariable("app", "otherc"));
mvel.initialise();
assertEquals(MVELArtifactContext.class, evaluate("app", event).getClass());
}
Aggregations