use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class OperationExecutionTestCase method operationWhichReturnsListOfMessages.
@Test
public void operationWhichReturnsListOfMessages() throws Exception {
TypedValue<List<Message>> payload = runFlow("getAllEnemies").getMessage().getPayload();
assertThat(payload.getDataType(), is(assignableTo(MULE_MESSAGE_COLLECTION)));
List<Message> enemies = payload.getValue();
HeisenbergExtension heisenberg = getConfig(HEISENBERG);
assertThat(enemies, hasSize(heisenberg.getEnemies().size()));
int index = 0;
for (Message enemyMessage : enemies) {
assertEnemyMessage(heisenberg, index, enemyMessage);
index++;
}
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class OperationExecutionTestCase method getInlineGroupDefinition.
@Test
public void getInlineGroupDefinition() throws Exception {
Message message = flowRunner("getBarberPreferences").withPayload(EMPTY_STRING).run().getMessage();
assertThat(message.getPayload().getValue(), is(notNullValue()));
assertThat(message.getPayload().getDataType().getMediaType().matches(APPLICATION_JAVA), is(true));
BarberPreferences preferences = (BarberPreferences) message.getPayload().getValue();
assertThat(preferences.getBeardTrimming(), is(BarberPreferences.BEARD_KIND.MUSTACHE));
assertThat(preferences.isFullyBald(), is(false));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class OperationExecutionTestCase method operationWithReturnValueOnTarget.
@Test
public void operationWithReturnValueOnTarget() throws Exception {
FlowRunner runner = flowRunner("sayMyNameOnTarget").withPayload(EMPTY_STRING);
CoreEvent responseEvent = runner.run();
assertThat(responseEvent.getMessage().getPayload().getValue(), is(EMPTY_STRING));
Message responseMessage = (Message) responseEvent.getVariables().get("myFace").getValue();
assertThat(responseMessage.getPayload().getValue(), is(HEISENBERG));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class TransformationServiceTestCase method skipsConverterThatDoesNotMatchWhenOriginalPayloadMatchesExpectedOutputType.
@Test
public void skipsConverterThatDoesNotMatchWhenOriginalPayloadMatchesExpectedOutputType() throws MuleException {
// Converter(B->C), payload C: OK - skips transformer but C is the expected output type -> OK
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();
Message message = of(new C());
message = transformationService.applyTransformers(message, null, converter1);
assertTrue(message.getPayload().getValue() instanceof C);
verifyTransformerNotExecuted(converter1);
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class TransformationServiceTestCase method failsOnConverterWhenSourceAndReturnTypeDoesNotMatchAndThereIsNoImplicitConversion.
@Test
public void failsOnConverterWhenSourceAndReturnTypeDoesNotMatchAndThereIsNoImplicitConversion() throws MuleException {
// Converter(B->C), payload A: FAIL
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();
Message message = of(new A());
try {
transformationService.applyTransformers(message, null, converter1);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(converter1);
}
Aggregations