use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class PetStoreSerializableParameterTestCase method inputStreamParameter.
@Test
public void inputStreamParameter() throws Exception {
InputStream inputStream = new ByteArrayInputStream(DONKEY.getBytes());
Message message = flowRunner("dynamicSerializableParameter").withVariable("animal", inputStream).run().getMessage();
assertThat(message.getPayload().getValue(), is(DONKEY));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class PetStoreSerializableParameterTestCase method dynamicSerializableParameter.
@Test
public void dynamicSerializableParameter() throws Exception {
Message message = flowRunner("dynamicSerializableParameter").withVariable("animal", DONKEY).run().getMessage();
assertThat(message.getPayload().getValue(), is(DONKEY));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class DefaultSourceCallback method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(Result<T, A> result, SourceCallbackContext context) {
checkArgument(context instanceof SourceCallbackContextAdapter, "The supplied context was not created through this callback, " + "you naughty developer");
SourceCallbackContextAdapter contextAdapter = (SourceCallbackContextAdapter) context;
validateNotifications(contextAdapter);
MessageProcessContext messageProcessContext = processContextSupplier.get();
SourceResultAdapter resultAdapter = new SourceResultAdapter(result, cursorProviderFactory, defaultMediaType, returnsListOfMessages, context.getCorrelationId());
Message message = of(resultAdapter);
executeFlow(context, messageProcessContext, message);
contextAdapter.dispatched();
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class OperationMessageProcessorTestCase method operationReturnsPayloadValueWithTarget.
@Test
public void operationReturnsPayloadValueWithTarget() throws Exception {
target = TARGET_VAR;
messageProcessor = setUpOperationMessageProcessor();
Object value = new Object();
when(operationExecutor.execute(any(ExecutionContext.class))).thenReturn(just(value));
Message message = (Message) messageProcessor.process(event).getVariables().get(TARGET_VAR).getValue();
assertThat(message, is(notNullValue()));
assertThat(message.getPayload().getValue(), is(sameInstance(value)));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class OperationMessageProcessorTestCase method operationReturnsResultMapWithCorrectDataType.
@Test
public void operationReturnsResultMapWithCorrectDataType() throws Exception {
Object payload = new HashMap<>();
setUpOperationReturning(Result.builder().output(payload).build(), new TypeToken<Map<String, String>>() {
}.getType());
Message message = messageProcessor.process(event).getMessage();
assertThat(message, is(notNullValue()));
assertThat(message.getPayload().getValue(), is(sameInstance(payload)));
DataType dataType = message.getPayload().getDataType();
assertThat(dataType, instanceOf(MapDataType.class));
assertThat(((MapDataType) dataType).getKeyDataType(), like(String.class, ANY.withCharset(null)));
assertThat(((MapDataType) dataType).getValueDataType(), like(String.class, ANY));
}
Aggregations