use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TransformationGraphTestCase method processesConverterAdded.
@Test
public void processesConverterAdded() {
Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
TransformationGraph graph = new TransformationGraph();
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 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.api.transformer.Converter 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.api.transformer.Converter 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.api.transformer.Converter in project mule by mulesoft.
the class MuleRegistryHelper method notifyTransformerResolvers.
public void notifyTransformerResolvers(Transformer t, TransformerResolver.RegistryAction action) {
if (t instanceof Converter) {
Lock transformerResolversReadLock = transformerResolversLock.readLock();
transformerResolversReadLock.lock();
try {
for (TransformerResolver resolver : transformerResolvers) {
resolver.transformerChange(t, action);
}
} finally {
transformerResolversReadLock.unlock();
}
transformerListCache.clear();
exactTransformerCache.clear();
Lock transformersWriteLock = transformersLock.writeLock();
transformersWriteLock.lock();
try {
if (action == ADDED) {
transformers.add(t);
} else {
transformers.remove(t);
}
} finally {
transformersWriteLock.unlock();
}
}
}
Aggregations