use of org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder in project mule by mulesoft.
the class GraphTransformerResolverTestCase method ignoresAddedTransformer.
@Test
public void ignoresAddedTransformer() throws ResolverException {
Converter xmlToJson = new MockConverterBuilder().named("xmlToJson").from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
Converter inputStreamToXml = new MockConverterBuilder().named("inputStreamToXml").from(INPUT_STREAM_DATA_TYPE).to(XML_DATA_TYPE).build();
graphResolver.transformerChange(inputStreamToXml, TransformerResolver.RegistryAction.ADDED);
graphResolver.transformerChange(xmlToJson, TransformerResolver.RegistryAction.ADDED);
Transformer transformer1 = graphResolver.resolve(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE);
assertNotNull(transformer1);
Transformer xmlToString = new MockTransformerBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).build();
graphResolver.transformerChange(xmlToString, TransformerResolver.RegistryAction.ADDED);
Transformer transformer2 = graphResolver.resolve(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE);
assertSame(transformer1, transformer2);
}
use of org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder in project mule by mulesoft.
the class GraphTransformerResolverTestCase method ignoresRemovedTransformer.
@Test
public void ignoresRemovedTransformer() throws ResolverException {
Converter xmlToJson = new MockConverterBuilder().named("xmlToJson").from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
Converter inputStreamToXml = new MockConverterBuilder().named("inputStreamToXml").from(INPUT_STREAM_DATA_TYPE).to(XML_DATA_TYPE).build();
graphResolver.transformerChange(inputStreamToXml, TransformerResolver.RegistryAction.ADDED);
graphResolver.transformerChange(xmlToJson, TransformerResolver.RegistryAction.ADDED);
Transformer transformer1 = graphResolver.resolve(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE);
assertNotNull(transformer1);
Transformer xmlToString = new MockTransformerBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).build();
graphResolver.transformerChange(xmlToString, TransformerResolver.RegistryAction.REMOVED);
Transformer transformer2 = graphResolver.resolve(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE);
assertSame(transformer1, transformer2);
}
use of org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder in project mule by mulesoft.
the class TransformationServiceTestCase method skipsConverterFailsOnTransformerWhenOriginalPayloadMatchesExpectedOutputType.
@Test
public void skipsConverterFailsOnTransformerWhenOriginalPayloadMatchesExpectedOutputType() throws MuleException {
// Converter(B -> D) Transformer(C->D), payload D: FAIL
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeD).build();
Transformer transformer2 = new MockTransformerBuilder().from(dataTypeC).to(dataTypeD).build();
Message message = of(new D());
try {
transformationService.applyTransformers(message, null, converter1, transformer2);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(converter1);
verifyTransformerNotExecuted(transformer2);
}
use of org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder 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.internal.transformer.builder.MockTransformerBuilder 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);
}
Aggregations