use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphLookupStrategyTestCase method findsMultipleDirectTransformations.
@Test
public void findsMultipleDirectTransformations() throws Exception {
Converter inputStreamToXml = new MockConverterBuilder().from(INPUT_STREAM_DATA_TYPE).to(XML_DATA_TYPE).build();
graph.addConverter(inputStreamToXml);
Converter betterInputStreamToXml = new MockConverterBuilder().from(INPUT_STREAM_DATA_TYPE).to(XML_DATA_TYPE).build();
graph.addConverter(betterInputStreamToXml);
List<Converter> converters = lookupStrategyTransformation.lookupConverters(INPUT_STREAM_DATA_TYPE, XML_DATA_TYPE);
assertEquals(2, converters.size());
Assert.assertTrue(converters.contains(inputStreamToXml));
Assert.assertTrue(converters.contains(betterInputStreamToXml));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphTestCase method ignoresConverterAddedTwice.
@Test
public void ignoresConverterAddedTwice() {
Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
TransformationGraph graph = new TransformationGraph();
graph.addConverter(xmlToJson);
graph.addConverter(xmlToJson);
assertEquals(2, graph.vertexSet().size());
assertTrue(graph.containsVertex(XML_DATA_TYPE));
assertTrue(graph.containsVertex(JSON_DATA_TYPE));
assertEquals(1, graph.edgeSet().size());
assertTrue(graph.containsEdge(XML_DATA_TYPE, JSON_DATA_TYPE));
assertFalse(graph.containsEdge(JSON_DATA_TYPE, XML_DATA_TYPE));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphTestCase method processesConverterAddedWithMultipleSourceTypes.
@Test
public void processesConverterAddedWithMultipleSourceTypes() {
Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE, INPUT_STREAM_DATA_TYPE).to(JSON_DATA_TYPE).build();
TransformationGraph graph = new TransformationGraph();
graph.addConverter(xmlToJson);
assertEquals(3, graph.vertexSet().size());
assertTrue(graph.containsVertex(XML_DATA_TYPE));
assertTrue(graph.containsVertex(JSON_DATA_TYPE));
assertTrue(graph.containsVertex(INPUT_STREAM_DATA_TYPE));
assertEquals(2, graph.edgeSet().size());
assertTrue(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));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphTestCase method removeSecondAddedConverterWithDifferentSourceToSameResultTypes.
@Test
public void removeSecondAddedConverterWithDifferentSourceToSameResultTypes() {
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(objectToJson);
assertEquals(2, graph.vertexSet().size());
assertTrue(graph.containsVertex(JSON_DATA_TYPE));
assertTrue(graph.containsVertex(XML_DATA_TYPE));
assertEquals(1, graph.edgeSet().size());
assertTrue(graph.containsEdge(XML_DATA_TYPE, JSON_DATA_TYPE));
assertFalse(graph.containsEdge(JSON_DATA_TYPE, XML_DATA_TYPE));
assertFalse(graph.containsEdge(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE));
assertFalse(graph.containsEdge(JSON_DATA_TYPE, INPUT_STREAM_DATA_TYPE));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphTestCase method ignoresRemovingConverterThatWasNeverAdded.
@Test
public void ignoresRemovingConverterThatWasNeverAdded() {
Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).weighting(1).build();
Converter betterXmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).weighting(2).build();
TransformationGraph graph = new TransformationGraph();
graph.addConverter(xmlToJson);
graph.removeConverter(betterXmlToJson);
assertEquals(2, graph.vertexSet().size());
assertTrue(graph.containsVertex(XML_DATA_TYPE));
assertTrue(graph.containsVertex(JSON_DATA_TYPE));
assertEquals(1, graph.edgeSet().size());
assertTrue(graph.containsEdge(XML_DATA_TYPE, JSON_DATA_TYPE));
}
Aggregations