use of org.mule.runtime.core.api.event.CoreEvent 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);
}
use of org.mule.runtime.core.api.event.CoreEvent 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());
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class VariablesTestCase method variableFromFlowScope.
@Test
public void variableFromFlowScope() throws Exception {
Message message = of("");
CoreEvent event = InternalEvent.builder(context).message(message).addVariable("foo", "bar").build();
((PrivilegedEvent) event).getSession().setProperty("foo", "NOTbar");
assertEquals(event.getVariables().get("foo").getValue(), evaluate("foo", event));
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class StreamingUtilsTestCase method consumeRepeatableIteratorPayload.
@Test
@Description("Test that repeatable iterator is consumed into a list")
public void consumeRepeatableIteratorPayload() throws Exception {
CursorIteratorProvider payload = asCursorProvider(TEST_LIST);
CoreEvent event = consumeRepeatablePayload(getEventBuilder().message(Message.of(payload)).build());
assertConsumedObjectStream(payload, event);
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class StreamingUtilsTestCase method consumeJsonRepeatableInputStreamPayload.
@Test
@Description("Test that repeatable stream in the payload is consumed into another fully in memory stream provider while maintaining " + "the original media type")
public void consumeJsonRepeatableInputStreamPayload() throws Exception {
CursorStreamProvider payload = asCursorProvider(TEST_PAYLOAD);
CoreEvent event = consumeRepeatablePayload(getEventBuilder().message(Message.builder().payload(TypedValue.of(payload)).mediaType(APPLICATION_JSON).build()).build());
assertConsumedRepeatableInputStream(payload, event);
assertThat(event.getMessage().getPayload().getDataType().getMediaType(), is(APPLICATION_JSON));
}
Aggregations