use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class CompositeConverterTestCase method setReturnDataType.
@Test
public void setReturnDataType() {
Converter converter = mock(Converter.class);
CompositeConverter chain = new CompositeConverter(converter);
chain.setReturnDataType(DataType.STRING);
verify(converter, atLeastOnce()).setReturnDataType(DataType.STRING);
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class CompositeConverterTestCase method isIgnoreBadInput.
@Test
public void isIgnoreBadInput() {
Converter converter = mock(Converter.class);
when(converter.isIgnoreBadInput()).thenReturn(true);
CompositeConverter chain = new CompositeConverter(converter);
assertTrue(chain.isIgnoreBadInput());
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class CompositeConverter method transform.
@Override
public Object transform(Object src, Charset encoding) throws TransformerException {
Object current = src;
Charset currentEncoding = encoding;
for (Converter converter : chain) {
if (currentEncoding != null) {
current = converter.transform(current, currentEncoding);
} else {
current = converter.transform(current);
}
currentEncoding = converter.getReturnDataType().getMediaType().getCharset().orElse(encoding);
}
return current;
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class CompositeConverter method compositeConverterName.
private String compositeConverterName(Converter[] converters) {
StringBuilder builder = new StringBuilder();
for (Converter converter : converters) {
chain.addLast(converter);
builder.append(converter.getName());
}
return builder.toString();
}
use of org.mule.runtime.core.api.transformer.Converter in project mule by mulesoft.
the class AbstractMockConverterBuilder method build.
@Override
public Converter build() {
Transformer converter = super.build();
doReturn(weight).when((Converter) converter).getPriorityWeighting();
return (Converter) converter;
}
Aggregations