Search in sources :

Example 6 with CompositeConverter

use of org.mule.runtime.core.privileged.transformer.CompositeConverter in project mule by mulesoft.

the class ShortestTransformationLengthTransformerFilterTestCase method filtersDifferentLengthWithBetterTrasnformerFist.

@Test
public void filtersDifferentLengthWithBetterTrasnformerFist() throws ResolverException {
    Converter xmlToString = new MockConverterBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).build();
    Converter stringToJson = new MockConverterBuilder().named("stringToJson").from(STRING_DATA_TYPE).to(JSON_DATA_TYPE).build();
    List<Converter> availableConverters = new ArrayList<Converter>();
    availableConverters.add(xmlToString);
    CompositeConverter compositeConverter = new CompositeConverter(xmlToString, stringToJson);
    availableConverters.add(compositeConverter);
    List<Converter> transformers = filter.filter(availableConverters, UNUSED_DATA_TYPE, UNUSED_DATA_TYPE);
    assertEquals(1, transformers.size());
    assertEquals(xmlToString, transformers.get(0));
}
Also used : MockConverterBuilder(org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder) ArrayList(java.util.ArrayList) Converter(org.mule.runtime.core.api.transformer.Converter) CompositeConverter(org.mule.runtime.core.privileged.transformer.CompositeConverter) CompositeConverter(org.mule.runtime.core.privileged.transformer.CompositeConverter) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

Converter (org.mule.runtime.core.api.transformer.Converter)6 CompositeConverter (org.mule.runtime.core.privileged.transformer.CompositeConverter)6 Test (org.junit.Test)4 MockConverterBuilder (org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder)4 SmallTest (org.mule.tck.size.SmallTest)4 ArrayList (java.util.ArrayList)3 Transformer (org.mule.runtime.core.api.transformer.Transformer)2 HashSet (java.util.HashSet)1