use of org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder in project mule by mulesoft.
the class TransformationServiceTestCase method failsOnFirstTransformer.
@Test
public void failsOnFirstTransformer() throws MuleException {
// Transformer(B ->D) Transformer(C->D), payload A: FAIL
Transformer transformer1 = new MockTransformerBuilder().from(dataTypeB).to(dataTypeD).build();
Transformer transformer2 = new MockTransformerBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new A());
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.core.internal.transformer.builder.MockTransformerBuilder in project mule by mulesoft.
the class TransformationServiceTestCase method skipsConverterAppliesTransformer.
@Test
public void skipsConverterAppliesTransformer() throws MuleException {
// Converter(B -> D) Transformer(C->D), payload C: skips converter, transforms C to D -> OK
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeD).build();
Transformer transformer2 = new MockTransformerBuilder().from(dataTypeC).to(dataTypeD).returning(new D()).build();
Message message = of(new C());
message = transformationService.applyTransformers(message, null, converter1, transformer2);
assertTrue(message.getPayload().getValue() instanceof D);
verifyTransformerNotExecuted(converter1);
verifyTransformerExecuted(transformer2);
}
use of org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder in project mule by mulesoft.
the class TransformationServiceTestCase method appliesConverterFailsOnTransformer.
@Test
public void appliesConverterFailsOnTransformer() throws MuleException {
// Converter(B -> D) Transformer(C->D), payload B: converts B-> D, cannot apply transformer -> FAIL
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeD).returning(new D()).build();
Transformer transformer2 = new MockTransformerBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new B());
try {
transformationService.applyTransformers(message, null, converter1, transformer2);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerExecuted(converter1);
verifyTransformerNotExecuted(transformer2);
}
use of org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder in project mule by mulesoft.
the class TransformationServiceTestCase method failsOnTransformerWhenSourceAndReturnTypeDoesNotMatch.
@Test
public void failsOnTransformerWhenSourceAndReturnTypeDoesNotMatch() throws MuleException {
// Transformer(B->C), payload A: FAIL
Transformer transformer1 = new MockTransformerBuilder().from(dataTypeB).to(dataTypeC).build();
Message message = of(new A());
try {
transformationService.applyTransformers(message, null, transformer1);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(transformer1);
}
Aggregations