Search in sources :

Example 96 with CoreEvent

use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.

the class OperationExecutionTestCase method optionalParameterWithDefaultOverride.

@Test
public void optionalParameterWithDefaultOverride() throws Exception {
    CoreEvent event = flowRunner("customKillWithoutDefault").withPayload(EMPTY_STRING).withVariable("goodbye", GOODBYE_MESSAGE).withVariable("victim", VICTIM).run();
    assertKillPayload(event);
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 97 with CoreEvent

use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.

the class ContentTypeHandlingTestCase method setEncodingInMimeTypeAndParam.

@Test
public void setEncodingInMimeTypeAndParam() throws Exception {
    CoreEvent response = runFlow("setEncodingInMimeTypeAndParam");
    DataType dataType = response.getMessage().getPayload().getDataType();
    assertThat(dataType.getMediaType().getPrimaryType(), is("application"));
    assertThat(dataType.getMediaType().getSubType(), is("json"));
    assertThat(dataType.getMediaType().getCharset().get(), is(StandardCharsets.UTF_16));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) Test(org.junit.Test)

Example 98 with CoreEvent

use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.

the class ContentTypeHandlingTestCase method overridesContentType.

@Test
public void overridesContentType() throws Exception {
    Charset lastSupportedEncoding = availableCharsets().values().stream().reduce((first, last) -> last).get();
    CoreEvent response = runFlow("setsContentTypeProgrammatically");
    final DataType dataType = response.getMessage().getPayload().getDataType();
    assertCustomMimeType(dataType);
    assertThat(dataType.getMediaType().getCharset().get(), is(lastSupportedEncoding));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) SystemProperty(org.mule.tck.junit4.rule.SystemProperty) Charset.defaultCharset(java.nio.charset.Charset.defaultCharset) BeforeClass(org.junit.BeforeClass) DataType(org.mule.runtime.api.metadata.DataType) UTF_8(java.nio.charset.StandardCharsets.UTF_8) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) TEXT(org.mule.runtime.api.metadata.MediaType.TEXT) Test(org.junit.Test) StandardCharsets(java.nio.charset.StandardCharsets) Assert.assertThat(org.junit.Assert.assertThat) Rule(org.junit.Rule) ISO_8859_1(java.nio.charset.StandardCharsets.ISO_8859_1) Charset(java.nio.charset.Charset) Charset.availableCharsets(java.nio.charset.Charset.availableCharsets) SystemUtils.getDefaultEncoding(org.mule.runtime.core.api.util.SystemUtils.getDefaultEncoding) FlowRunner(org.mule.functional.api.flow.FlowRunner) MediaType(org.mule.runtime.api.metadata.MediaType) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Charset.defaultCharset(java.nio.charset.Charset.defaultCharset) Charset(java.nio.charset.Charset) DataType(org.mule.runtime.api.metadata.DataType) Test(org.junit.Test)

Example 99 with CoreEvent

use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.

the class ContentTypeHandlingTestCase method strictMimeType.

@Test
public void strictMimeType() throws Exception {
    CoreEvent response = runFlow("strictMimeType");
    assertThat(response.getMessage().getPayload().getDataType().getMediaType().matches(TEXT), is(true));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 100 with CoreEvent

use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.

the class ContentTypeHandlingTestCase method onlySetEncodingOnXml.

@Test
public void onlySetEncodingOnXml() throws Exception {
    CoreEvent response = runFlow("onlySetEncodingOnXml");
    DataType dataType = response.getMessage().getPayload().getDataType();
    assertCustomEncoding(dataType);
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) 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