Search in sources :

Example 41 with CoreEvent

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);
}
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 42 with CoreEvent

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());
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 43 with CoreEvent

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));
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 44 with CoreEvent

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);
}
Also used : InMemoryCursorIteratorProvider(org.mule.runtime.core.internal.streaming.object.InMemoryCursorIteratorProvider) CursorIteratorProvider(org.mule.runtime.api.streaming.object.CursorIteratorProvider) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Description(io.qameta.allure.Description) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 45 with CoreEvent

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));
}
Also used : InMemoryCursorStreamProvider(org.mule.runtime.core.api.streaming.bytes.InMemoryCursorStreamProvider) CursorStreamProvider(org.mule.runtime.api.streaming.bytes.CursorStreamProvider) ByteArrayCursorStreamProvider(org.mule.runtime.core.internal.streaming.bytes.ByteArrayCursorStreamProvider) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Description(io.qameta.allure.Description) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

CoreEvent (org.mule.runtime.core.api.event.CoreEvent)485 Test (org.junit.Test)394 Message (org.mule.runtime.api.message.Message)103 SmallTest (org.mule.tck.size.SmallTest)100 TypedValue (org.mule.runtime.api.metadata.TypedValue)44 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)39 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)38 Description (io.qameta.allure.Description)37 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)37 List (java.util.List)36 MuleException (org.mule.runtime.api.exception.MuleException)33 Processor (org.mule.runtime.core.api.processor.Processor)33 DataType (org.mule.runtime.api.metadata.DataType)28 InternalEvent (org.mule.runtime.core.internal.message.InternalEvent)28 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)27 ArrayList (java.util.ArrayList)26 Map (java.util.Map)26 Optional (java.util.Optional)25 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)23 InOrder (org.mockito.InOrder)22