Search in sources :

Example 6 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method assignValueToNewSessionVariable.

@Test
public void assignValueToNewSessionVariable() throws Exception {
    Message message = of("");
    CoreEvent event = InternalEvent.builder(context).message(message).build();
    evaluate("sessionVars['foo']='bar'", event);
    assertEquals("bar", ((PrivilegedEvent) event).getSession().getProperty("foo"));
}
Also used : PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 7 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method reassignValueToLocalVariable.

/**
 * See MULE-6381
 */
@Test
public void reassignValueToLocalVariable() throws Exception {
    Message message = of("");
    CoreEvent event = InternalEvent.builder(context).message(message).build();
    evaluate("localVar='bar';localVar='bar2'", event);
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 8 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method assignValueToSessionVariable.

@Test
public void assignValueToSessionVariable() throws Exception {
    Message message = of("");
    PrivilegedEvent event = (PrivilegedEvent) InternalEvent.builder(context).message(message).build();
    event.getSession().setProperty("foo", "bar_old");
    evaluate("sessionVars['foo']='bar'", event);
    assertEquals("bar", event.getSession().getProperty("foo"));
}
Also used : PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) Message(org.mule.runtime.api.message.Message) Test(org.junit.Test)

Example 9 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method sessionVariablesMap.

@Test
public void sessionVariablesMap() throws Exception {
    Message message = of("");
    CoreEvent event = InternalEvent.builder(context).message(message).build();
    ((PrivilegedEvent) event).getSession().setProperty("foo", "bar");
    assertTrue(evaluate("sessionVars", event) instanceof Map);
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Map(java.util.Map) Test(org.junit.Test)

Example 10 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method assignValueToNewFlowVariable.

@Test
public void assignValueToNewFlowVariable() throws Exception {
    Message message = of("");
    CoreEvent event = InternalEvent.builder(context).message(message).build();
    CoreEvent.Builder eventBuilder = CoreEvent.builder(event);
    evaluate("flowVars['foo']='bar'", event, eventBuilder);
    assertEquals("bar", eventBuilder.build().getVariables().get("foo").getValue());
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Aggregations

Message (org.mule.runtime.api.message.Message)226 Test (org.junit.Test)189 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)104 SmallTest (org.mule.tck.size.SmallTest)68 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)46 Transformer (org.mule.runtime.core.api.transformer.Transformer)35 DataType (org.mule.runtime.api.metadata.DataType)33 ArrayList (java.util.ArrayList)26 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)26 Processor (org.mule.runtime.core.api.processor.Processor)25 List (java.util.List)20 Assert.assertThat (org.junit.Assert.assertThat)19 ExpectedException (org.junit.rules.ExpectedException)19 MuleContextUtils.eventBuilder (org.mule.tck.util.MuleContextUtils.eventBuilder)19 Map (java.util.Map)18 Rule (org.junit.Rule)18 MockConverterBuilder (org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder)18 ExpectedException.none (org.junit.rules.ExpectedException.none)17 MockTransformerBuilder (org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder)17 TypedValue (org.mule.runtime.api.metadata.TypedValue)16