use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method compatibleConverterShouldBeReturnedEvenIfTargetDataTypeDoesNotExist.
@Test
public void compatibleConverterShouldBeReturnedEvenIfTargetDataTypeDoesNotExist() throws Exception {
Converter jsonToTextString = new MockConverterBuilder().named("jsonToTextString").from(JSON_STRING).to(TEXT_STRING).build();
graph.addConverter(jsonToTextString);
List<Converter> converters = lookupStrategyTransformation.lookupConverters(JSON_STRING, STRING);
assertThat(converters, hasSize(1));
assertThat(converters.get(0).getName(), is("jsonToTextString"));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method findsDirectTransformationWhileChangingGraph.
@Test
public void findsDirectTransformationWhileChangingGraph() throws Exception {
Converter inputStreamToXml = new MockConverterBuilder().from(INPUT_STREAM_DATA_TYPE).to(XML_DATA_TYPE).build();
graph.addConverter(inputStreamToXml);
List<Converter> converters = lookupStrategyTransformation.lookupConverters(INPUT_STREAM_DATA_TYPE, XML_DATA_TYPE);
assertThat(converters, hasSize(1));
assertThat(converters.get(0), is(inputStreamToXml));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method lookupTransformersNoSourceInGraph.
@Test
public void lookupTransformersNoSourceInGraph() throws Exception {
Converter inputStreamToXml = new MockConverterBuilder().from(INPUT_STREAM_DATA_TYPE).to(XML_DATA_TYPE).build();
graph.addConverter(inputStreamToXml);
List<Converter> converters = lookupStrategyTransformation.lookupConverters(JSON_DATA_TYPE, INPUT_STREAM_DATA_TYPE);
assertEquals(0, converters.size());
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method compatibleConverterShouldBeReturnedEvenIfTSourceDataTypeDoesNotExist.
@Test
public void compatibleConverterShouldBeReturnedEvenIfTSourceDataTypeDoesNotExist() throws Exception {
Converter xmlToTextString = new MockConverterBuilder().named("textStringToXML").from(XML_DATA_TYPE).to(TEXT_STRING).build();
graph.addConverter(xmlToTextString);
List<Converter> converters = lookupStrategyTransformation.lookupConverters(XML_DATA_TYPE, STRING);
assertThat(converters, hasSize(1));
assertThat(converters.get(0).getName(), is("textStringToXML"));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method assertContainsCompositeTransformer.
private void assertContainsCompositeTransformer(List<Converter> converters, Converter... composedConverters) {
for (Converter converter : converters) {
if (converter instanceof CompositeConverter) {
CompositeConverter compositeConverter = (CompositeConverter) converter;
if (compositeConverter.getConverters().size() != composedConverters.length) {
continue;
}
boolean matches = true;
for (int i = 0; i < composedConverters.length - 1; i++) {
if (composedConverters[i] != compositeConverter.getConverters().get(i)) {
matches = false;
break;
}
}
if (matches) {
return;
}
}
}
fail("Converter list does not contain a composite converter with: " + composedConverters);
}
Aggregations