use of org.mule.runtime.core.api.transformer.Transformer in project mule by mulesoft.
the class TransformationServiceTestCase method failsTransformationUsingConverterWhenSourceAndReturnTypeDoesNotMatch2.
@Test
public void failsTransformationUsingConverterWhenSourceAndReturnTypeDoesNotMatch2() throws MuleException {
// Converter(B -> C) Converter(C->D), payload A: FAIL
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();
Transformer converter2 = new MockConverterBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new A());
try {
transformationService.applyTransformers(message, null, converter1, converter2);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(converter1);
verifyTransformerNotExecuted(converter2);
}
use of org.mule.runtime.core.api.transformer.Transformer in project mule by mulesoft.
the class TransformationServiceTestCase method failsTransformerIgnoringMatchingConverter.
@Test
public void failsTransformerIgnoringMatchingConverter() throws MuleException {
// Transformer(B -> D) Converter(C->D), payload C: FAIL
Transformer transformer1 = new MockTransformerBuilder().from(dataTypeB).to(dataTypeD).build();
Transformer converter2 = new MockConverterBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new C());
try {
transformationService.applyTransformers(message, null, transformer1, converter2);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(transformer1);
verifyTransformerNotExecuted(converter2);
}
use of org.mule.runtime.core.api.transformer.Transformer in project mule by mulesoft.
the class TransformationServiceTestCase method failsTransformerIgnoringNonMatchingConverter.
@Test
public void failsTransformerIgnoringNonMatchingConverter() throws MuleException {
// Transformer(B -> D) Converter(C->D), payload A: FAIL
Transformer transformer1 = new MockTransformerBuilder().from(dataTypeB).to(dataTypeD).build();
Transformer converter2 = new MockConverterBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new A());
try {
transformationService.applyTransformers(message, null, transformer1, converter2);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(transformer1);
verifyTransformerNotExecuted(converter2);
}
use of org.mule.runtime.core.api.transformer.Transformer in project mule by mulesoft.
the class TransformationServiceTestCase method failsOnTransformerWhenOriginalPayloadMatchesExpectedOutputType.
@Test
public void failsOnTransformerWhenOriginalPayloadMatchesExpectedOutputType() throws MuleException {
// Transformer(B->C), payload C: FAIL
Transformer transformer1 = new MockTransformerBuilder().from(dataTypeB).to(dataTypeC).build();
Message message = of(new C());
try {
transformationService.applyTransformers(message, null, transformer1);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(transformer1);
}
use of org.mule.runtime.core.api.transformer.Transformer 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);
}
Aggregations