use of org.mule.runtime.core.internal.registry.TransformerWeighting in project mule by mulesoft.
the class TransformerWeightingTestCase method testNearMatch.
@Test
public void testNearMatch() throws Exception {
Transformer trans = new MockConverterBuilder().from(DataType.INPUT_STREAM).to(DataType.BYTE_ARRAY).build();
TransformerWeighting weighting = new TransformerWeighting(FilterInputStream.class, byte[].class, trans);
assertFalse(weighting.isNotMatch());
assertFalse(weighting.isExactMatch());
assertEquals(1, weighting.getInputWeighting());
assertEquals(0, weighting.getOutputWeighting());
}
use of org.mule.runtime.core.internal.registry.TransformerWeighting in project mule by mulesoft.
the class TransformerWeightingTestCase method testNoMatchWeighting.
@Test
public void testNoMatchWeighting() throws Exception {
Transformer trans = new MockConverterBuilder().from(DataType.fromType(Serializable.class)).to(DataType.BYTE_ARRAY).build();
TransformerWeighting weighting = new TransformerWeighting(FruitBowl.class, byte[].class, trans);
assertTrue(weighting.isNotMatch());
assertEquals(-1, weighting.getInputWeighting());
assertEquals(0, weighting.getOutputWeighting());
}
use of org.mule.runtime.core.internal.registry.TransformerWeighting in project mule by mulesoft.
the class PriorityWeightingConverterFilter method getTransformerWeightings.
private List<TransformerWeighting> getTransformerWeightings(List<Converter> converters, Class input, Class output) {
List<TransformerWeighting> weightings = new LinkedList<>();
for (Converter converter : converters) {
TransformerWeighting current = new TransformerWeighting(input, output, converter);
weightings.add(current);
}
Collections.sort(weightings);
return weightings;
}
Aggregations