use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TypeMatchingVertexesFilterTestCase method matchingSourceTypeConvertersAreReturnedEvenWithSuperTypesPresent.
@Test
public void matchingSourceTypeConvertersAreReturnedEvenWithSuperTypesPresent() 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, STRING, PEACH_DATA_TYPE);
assertThat(filtered, hasSize(2));
assertThat(filtered, contains(stringToOrange, stringToSeed));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TypeMatchingVertexesFilterTestCase method matchingSourceTypeConvertersAreReturned.
@Test
public void matchingSourceTypeConvertersAreReturned() 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();
Converter stringToSeed = new MockConverterBuilder().named("stringToSeed").from(STRING).to(SEED_DATA_TYPE).build();
List<Converter> converters = asList(stringToOrange, bananaToApple, stringToSeed);
List<Converter> filtered = filter.filter(converters, STRING, PEACH_DATA_TYPE);
assertThat(filtered, hasSize(2));
assertThat(filtered, contains(stringToOrange, stringToSeed));
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class TypeMatchingVertexesFilterTestCase method bothVertexesMatchingIsBetterThanJustOne.
@Test
public void bothVertexesMatchingIsBetterThanJustOne() throws Exception {
Converter stringToOrange = new MockConverterBuilder().named("stringToOrange").from(STRING).to(ORANGE_DATA_TYPE).build();
Converter stringToBanana = new MockConverterBuilder().named("stringToBanana").from(STRING).to(BANANA_DATA_TYPE).build();
Converter seedToOrange = new MockConverterBuilder().named("seedToOrange").from(SEED_DATA_TYPE).to(ORANGE_DATA_TYPE).build();
List<Converter> converters = asList(stringToOrange, stringToBanana, seedToOrange);
List<Converter> filtered = filter.filter(converters, STRING, 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 CompositeConverterTestCase method isAcceptNull.
@Test
public void isAcceptNull() {
Converter converter = mock(Converter.class);
when(converter.isAcceptNull()).thenReturn(true);
CompositeConverter chain = new CompositeConverter(converter);
assertTrue(chain.isAcceptNull());
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class CompositeConverterTestCase method getSourceDataTypes.
@Test
public void getSourceDataTypes() {
DataType[] dataTypes = new DataType[] { DataType.STRING };
Converter converter = mock(Converter.class);
when(converter.getSourceDataTypes()).thenReturn(Arrays.asList(dataTypes));
CompositeConverter chain = new CompositeConverter(converter);
assertEquals(DataType.STRING, chain.getSourceDataTypes().get(0));
}
Aggregations