use of org.mule.runtime.core.privileged.transformer.TransformerChain in project mule by mulesoft.
the class TransformerChainingTestCase method testTwoChainedTransformers.
@Test
public void testTwoChainedTransformers() throws Exception {
AbstractTransformer validTransformer = (AbstractTransformer) this.getIncreaseByOneTransformer();
assertNotNull(validTransformer);
Message message = of(new Integer(0));
Transformer messageTransformer = new TransformerChain(validTransformer, validTransformer);
message = transformationService.applyTransformers(message, eventBuilder(muleContext).message(of(0)).build(), singletonList(messageTransformer));
Object transformedMessage = message.getPayload().getValue();
assertNotNull(transformedMessage);
assertEquals(new Integer(2), transformedMessage);
}
use of org.mule.runtime.core.privileged.transformer.TransformerChain in project mule by mulesoft.
the class TransformerChainingTestCase method testIgnoreBadInputBreaksChainWithTransformationOrderInvalidValid.
@Test
public void testIgnoreBadInputBreaksChainWithTransformationOrderInvalidValid() 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(invalidTransformer, validTransformer);
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) {
// ignore
}
}
Aggregations