use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class MuleMessageDataTypePropagationTestCase method setsCustomSessionVariableDataType.
@Test
public void setsCustomSessionVariableDataType() throws Exception {
DataType dataType = DataType.builder().type(String.class).mediaType(APPLICATION_XML).charset(CUSTOM_ENCODING).build();
((PrivilegedEvent) testEvent()).getSession().setProperty(TEST_PROPERTY, TEST_PAYLOAD, dataType);
assertSessionVariableDataType(testEvent(), dataType);
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class MuleMessageDataTypePropagationTestCase method updatesEncodingOnTransformation.
@Test
public void updatesEncodingOnTransformation() throws Exception {
Message message = Message.builder().value(TEST_PAYLOAD).mediaType(APPLICATION_XML_DEFAULT).build();
Transformer transformer = mock(Transformer.class);
when(transformer.isSourceDataTypeSupported(any())).thenReturn(true);
DataType outputDataType = DataType.builder().type(Integer.class).charset(CUSTOM_ENCODING).build();
when(transformer.getReturnDataType()).thenReturn(outputDataType);
when(transformer.transform(anyObject())).thenReturn(Integer.valueOf(1));
CoreEvent muleEvent = mock(CoreEvent.class);
Message result = transformationService.applyTransformers(message, muleEvent, singletonList(transformer));
assertDataType(result, Integer.class, APPLICATION_XML, CUSTOM_ENCODING);
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class MuleMessageDataTypePropagationTestCase method setsCustomFlowVariableDataType.
@Test
public void setsCustomFlowVariableDataType() throws Exception {
DataType dataType = DataType.builder().type(String.class).mediaType(APPLICATION_XML).charset(CUSTOM_ENCODING).build();
CoreEvent muleEvent = CoreEvent.builder(testEvent()).addVariable(TEST_PROPERTY, TEST_PAYLOAD, dataType).build();
assertVariableDataType(muleEvent, dataType);
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class MuleMessageDataTypePropagationTestCase method assertInboundPropertyDataType.
private void assertInboundPropertyDataType(InternalMessage muleMessage, DataType dataType) {
DataType actualDataType = muleMessage.getInboundPropertyDataType(TEST_PROPERTY);
assertThat(actualDataType, like(dataType));
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class SimpleDataTypeTestCase method acceptsSupportedEncoding.
@Test
public void acceptsSupportedEncoding() throws Exception {
DataType dataType = DataType.builder().charset(UTF_8.name()).build();
assertThat(dataType.getMediaType().getCharset().get(), equalTo(UTF_8));
}
Aggregations