use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method findsCompositeConverter.
@Test
public void findsCompositeConverter() throws Exception {
Converter inputStreamToString = new MockConverterBuilder().named("inputStreamToString").from(INPUT_STREAM_DATA_TYPE).to(STRING_DATA_TYPE).build();
graph.addConverter(inputStreamToString);
Converter stringToJson = new MockConverterBuilder().named("stringToJson").from(STRING_DATA_TYPE).to(JSON_DATA_TYPE).build();
graph.addConverter(stringToJson);
List<Converter> converters = lookupStrategyTransformation.lookupConverters(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE);
assertEquals(1, converters.size());
assertContainsCompositeTransformer(converters, inputStreamToString, stringToJson);
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method transformerWithNoCharsetDataTypeAsSourceFoundEvenWhenSpecified.
@Test
public void transformerWithNoCharsetDataTypeAsSourceFoundEvenWhenSpecified() throws Exception {
Converter utf16ToJson = new MockConverterBuilder().from(builder(UTF_16_DATA_TYPE).charset((String) null).build()).to(JSON_DATA_TYPE).build();
graph.addConverter(utf16ToJson);
List<Converter> converters = lookupStrategyTransformation.lookupConverters(UTF_16_DATA_TYPE, JSON_DATA_TYPE);
assertThat(converters, hasSize(1));
assertThat(converters, contains(utf16ToJson));
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TransformationGraphTestCase method removesSecondDuplicateConverterAdded.
@Test
public void removesSecondDuplicateConverterAdded() {
Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
Converter betterXmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
TransformationGraph graph = new TransformationGraph();
graph.addConverter(xmlToJson);
graph.addConverter(betterXmlToJson);
graph.removeConverter(betterXmlToJson);
assertEquals(2, graph.vertexSet().size());
assertTrue(graph.containsVertex(JSON_DATA_TYPE));
assertTrue(graph.containsVertex(XML_DATA_TYPE));
Set<TransformationEdge> transformationEdges = graph.edgesOf(JSON_DATA_TYPE);
assertEquals(1, transformationEdges.size());
assertContainsTransformer(transformationEdges, xmlToJson);
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TransformationGraphTestCase method processesConverterRemovedWithMultipleSourceTypes.
@Test
public void processesConverterRemovedWithMultipleSourceTypes() {
Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE, INPUT_STREAM_DATA_TYPE).to(JSON_DATA_TYPE).build();
TransformationGraph graph = new TransformationGraph();
graph.addConverter(xmlToJson);
graph.removeConverter(xmlToJson);
assertEquals(0, graph.vertexSet().size());
assertEquals(0, graph.edgeSet().size());
}
use of org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder in project mule by mulesoft.
the class TransformationGraphTestCase method removeFirstAddedConverterWithDifferentSourceToSameResultTypes.
@Test
public void removeFirstAddedConverterWithDifferentSourceToSameResultTypes() {
Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
Converter objectToJson = new MockConverterBuilder().from(INPUT_STREAM_DATA_TYPE).to(JSON_DATA_TYPE).build();
TransformationGraph graph = new TransformationGraph();
graph.addConverter(xmlToJson);
graph.addConverter(objectToJson);
graph.removeConverter(xmlToJson);
assertEquals(2, graph.vertexSet().size());
assertTrue(graph.containsVertex(JSON_DATA_TYPE));
assertTrue(graph.containsVertex(INPUT_STREAM_DATA_TYPE));
assertEquals(1, graph.edgeSet().size());
assertFalse(graph.containsEdge(XML_DATA_TYPE, JSON_DATA_TYPE));
assertFalse(graph.containsEdge(JSON_DATA_TYPE, XML_DATA_TYPE));
assertTrue(graph.containsEdge(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE));
assertFalse(graph.containsEdge(JSON_DATA_TYPE, INPUT_STREAM_DATA_TYPE));
}
Aggregations