use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class TransformationServiceTestCase method skipsFirstConverterAppliesSecond.
@Test
public void skipsFirstConverterAppliesSecond() throws MuleException {
// Converter(B -> C) Converter(C->D), payload C: skips converter(B->C), applies Converter(C->D)
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();
Transformer converter2 = new MockConverterBuilder().from(dataTypeC).to(dataTypeD).returning(new D()).build();
Message message = of(new C());
message = transformationService.applyTransformers(message, null, converter1, converter2);
assertTrue(message.getPayload().getValue() instanceof D);
verifyTransformerNotExecuted(converter1);
verifyTransformerExecuted(converter2);
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class TransformationServiceTestCase method failsOnFirstTransformerIgnoresSecondTransformer.
@Test
public void failsOnFirstTransformerIgnoresSecondTransformer() throws MuleException {
// Transformer(B ->D) Transformer(C->D), payload C: FAIL
Transformer transformer1 = new MockTransformerBuilder().from(dataTypeB).to(dataTypeD).build();
Transformer transformer2 = new MockTransformerBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new C());
try {
transformationService.applyTransformers(message, null, transformer1, transformer2);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(transformer1);
verifyTransformerNotExecuted(transformer2);
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class TransformationServiceTestCase method appliesTransformerSkipsConverter.
@Test
public void appliesTransformerSkipsConverter() throws MuleException {
// Transformer(B -> D) Converter(C->D), payload B: converts B->D, skips converter C->D, resulting output is of the expected
// type -> OK
Transformer transformer1 = new MockTransformerBuilder().from(dataTypeB).to(dataTypeD).returning(new D()).build();
Transformer converter2 = new MockConverterBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new B());
message = transformationService.applyTransformers(message, null, transformer1, converter2);
assertTrue(message.getPayload().getValue() instanceof D);
verifyTransformerExecuted(transformer1);
verifyTransformerNotExecuted(converter2);
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class TransformerChainingTestCase method testIgnoreBadInputBreaksChainWithTransformationOrderValidInvalid.
@Test
public void testIgnoreBadInputBreaksChainWithTransformationOrderValidInvalid() throws Exception {
AbstractTransformer invalidTransformer = (AbstractTransformer) this.getInvalidTransformer();
assertNotNull(invalidTransformer);
invalidTransformer.setIgnoreBadInput(false);
AbstractTransformer validTransformer = (AbstractTransformer) this.getIncreaseByOneTransformer();
assertNotNull(validTransformer);
Message message = of(new Integer(0));
Transformer messageTransformer = new TransformerChain(validTransformer, invalidTransformer);
try {
transformationService.applyTransformers(message, eventBuilder(muleContext).message(of(0)).build(), messageTransformer);
fail("Transformer chain is expected to fail because of invalid transformer within chain.");
} catch (MuleException tfe) {
assertNotNull(tfe);
}
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class DefaultMessageContextTestCase method noCorrelationIdInContext.
@Test
public void noCorrelationIdInContext() {
final Message message = of(TEST_PAYLOAD);
final CoreEvent event = InternalEvent.builder(executionContext).message(message).build();
assertThat(event.getCorrelationId(), is(GENERATED_CORRELATION_ID));
}
Aggregations