use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class TypedValueParameterOperationExecutionTestCase method typedValueForObject.
@Test
public void typedValueForObject() throws Exception {
CoreEvent event = flowRunner("typedValueForObject").keepStreamsOpen().run();
TypedValue jsonObject = (TypedValue) event.getMessage().getPayload().getValue();
InputStream content = (InputStream) jsonObject.getValue();
assertThat(IOUtils.toString(content), is(JSON_OBJECT));
assertThat(jsonObject.getDataType(), is(like(jsonObject.getDataType().getType(), APPLICATION_JSON, UTF8)));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class TypedValueParameterOperationExecutionTestCase method typedValueForInputStream.
@Test
public void typedValueForInputStream() throws Exception {
CoreEvent event = flowRunner("typedValueForInputStream").run();
TypedValue jsonObject = (TypedValue) event.getMessage().getPayload().getValue();
assertThat(IOUtils.toString((InputStream) jsonObject.getValue()), is(JSON_OBJECT));
assertThat(jsonObject.getDataType(), is(like(jsonObject.getDataType().getType(), APPLICATION_JSON, UTF8)));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class AbstractAddVariablePropertyProcessorTestCase method setUpTest.
@Before
public void setUpTest() throws Exception {
when(mockMuleContext.getExpressionManager()).thenReturn(mockExpressionManager);
when(mockMuleContext.getConfiguration()).thenReturn(mock(MuleConfiguration.class));
typedValue = new TypedValue(EXPRESSION_VALUE, STRING);
when(mockExpressionManager.evaluate(eq(EXPRESSION), eq(STRING), any(), any(CoreEvent.class))).thenReturn(typedValue);
when(mockExpressionManager.evaluate(eq(EXPRESSION), any(CoreEvent.class))).thenReturn(typedValue);
addVariableProcessor.setMuleContext(mockMuleContext);
message = of("");
event = createTestEvent(message);
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class AbstractAddVariablePropertyProcessorTestCase method testAddVariableWithNullPayloadExpressionValueResult.
@Test
public void testAddVariableWithNullPayloadExpressionValueResult() throws MuleException {
addVariableProcessor.setIdentifier(PLAIN_STRING_KEY);
addVariableProcessor.setValue(EXPRESSION);
TypedValue typedValue = new TypedValue(null, DataType.OBJECT);
when(mockExpressionManager.evaluate(EXPRESSION, event)).thenReturn(typedValue);
addVariableProcessor.initialise();
event = addVariableProcessor.process(event);
verifyRemoved(event, PLAIN_STRING_KEY);
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class AbstractAddVariablePropertyProcessorTestCase method testAddVariableWithNullExpressionKeyResult.
@Test
public void testAddVariableWithNullExpressionKeyResult() throws MuleException {
TypedValue typedValue = new TypedValue(null, OBJECT);
when(mockExpressionManager.evaluate(eq(NULL_EXPRESSION), eq(DataType.STRING), any(), eq(event))).thenReturn(typedValue);
addVariableProcessor.setIdentifier(NULL_EXPRESSION);
addVariableProcessor.setValue(PLAIN_STRING_VALUE);
addVariableProcessor.initialise();
event = addVariableProcessor.process(event);
verifyNotAdded(event);
}
Aggregations