use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TypeMatchingVertexesFilterTestCase method matchingResultTypeConvertersAreReturned.
@Test
public void matchingResultTypeConvertersAreReturned() throws Exception {
Converter stringToOrange = new MockConverterBuilder().named("stringToOrange").from(STRING).to(ORANGE_DATA_TYPE).build();
Converter objectToApple = new MockConverterBuilder().named("objectToApple").from(OBJECT).to(APPLE_DATA_TYPE).build();
Converter stringToSeed = new MockConverterBuilder().named("stringToSeed").from(STRING).to(SEED_DATA_TYPE).build();
List<Converter> converters = asList(stringToOrange, objectToApple, stringToSeed);
List<Converter> filtered = filter.filter(converters, SEED_DATA_TYPE, ORANGE_DATA_TYPE);
assertThat(filtered, hasSize(1));
assertThat(filtered, contains(stringToOrange));
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TypeMatchingVertexesFilterTestCase method resultMimeTypeIsFiltered.
@Test
public void resultMimeTypeIsFiltered() throws Exception {
Converter bananaToString = new MockConverterBuilder().named("BananaToString").from(BANANA_DATA_TYPE).to(STRING).build();
Converter bananaToJsonString = new MockConverterBuilder().named("BananaToJsonString").from(BANANA_DATA_TYPE).to(JSON_STRING).build();
List<Converter> converters = asList(bananaToString, bananaToJsonString);
List<Converter> filtered = filter.filter(converters, BANANA_DATA_TYPE, JSON_STRING);
assertThat(filtered, hasSize(1));
assertThat(filtered, contains(bananaToJsonString));
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TypeMatchingVertexesFilterTestCase method sameListIsReturnedIfNoMatch.
@Test
public void sameListIsReturnedIfNoMatch() throws Exception {
Converter stringToOrange = new MockConverterBuilder().named("stringToOrange").from(STRING).to(ORANGE_DATA_TYPE).build();
Converter bananaToApple = new MockConverterBuilder().named("bananaToApple").from(BANANA_DATA_TYPE).to(APPLE_DATA_TYPE).build();
List<Converter> converters = asList(stringToOrange, bananaToApple);
List<Converter> filtered = filter.filter(converters, PEACH_DATA_TYPE, SEED_DATA_TYPE);
assertThat(filtered, is(equalTo(converters)));
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TransformationServiceTestCase method skipsConverterThatDoesNotMatchWhenOriginalPayloadMatchesExpectedOutputType.
@Test
public void skipsConverterThatDoesNotMatchWhenOriginalPayloadMatchesExpectedOutputType() throws MuleException {
// Converter(B->C), payload C: OK - skips transformer but C is the expected output type -> OK
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();
Message message = of(new C());
message = transformationService.applyTransformers(message, null, converter1);
assertTrue(message.getPayload().getValue() instanceof C);
verifyTransformerNotExecuted(converter1);
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TransformationServiceTestCase method failsOnConverterWhenSourceAndReturnTypeDoesNotMatchAndThereIsNoImplicitConversion.
@Test
public void failsOnConverterWhenSourceAndReturnTypeDoesNotMatchAndThereIsNoImplicitConversion() throws MuleException {
// Converter(B->C), payload A: FAIL
Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();
Message message = of(new A());
try {
transformationService.applyTransformers(message, null, converter1);
fail("Transformation is supposed to fail");
} catch (IllegalArgumentException expected) {
}
verifyTransformerNotExecuted(converter1);
}
Aggregations