Package org.mule.transformer.builder

Examples of org.mule.transformer.builder.MockConverterBuilder


    private Transformer t2;

    @Before
    public void setUp() throws Exception
    {
        t1 = new MockConverterBuilder().named("t1").from(DataTypeFactory.create(Orange.class)).to(DataTypeFactory.create(Fruit.class)).build();
        muleContext.getRegistry().registerTransformer(t1);

        t2 = new MockConverterBuilder().named("t2").from(DataTypeFactory.OBJECT).to(DataTypeFactory.create(Fruit.class)).build();
        muleContext.getRegistry().registerTransformer(t2);
    }
View Full Code Here


    @Test
    public void resolvesTypeWithOneMatchingTransformer() throws ResolverException, TransformerException
    {
        MuleRegistry muleRegistry = mock(MuleRegistry.class);
        when(muleContext.getRegistry()).thenReturn(muleRegistry);
        Transformer aToBConverter = new MockConverterBuilder().from(dataTypeA).to(dataTypeB).build();

        ArrayList<Transformer> transformers = new ArrayList<Transformer>();
        transformers.add(aToBConverter);
        when(muleRegistry.lookupTransformers(dataTypeA, dataTypeB)).thenReturn(transformers);
View Full Code Here

    @Test
    public void resolvesTypeWithTwoMatchingTransformer() throws ResolverException, TransformerException
    {
        MuleRegistry muleRegistry = mock(MuleRegistry.class);
        when(muleContext.getRegistry()).thenReturn(muleRegistry);
        Transformer aToBConverter = new MockConverterBuilder().from(dataTypeA).to(dataTypeB).weighting(1).build();
        Transformer betterAToBConverter = new MockConverterBuilder().from(dataTypeA).to(dataTypeB).weighting(2).build();

        ArrayList<Transformer> transformers = new ArrayList<Transformer>();
        transformers.add(aToBConverter);
        transformers.add(betterAToBConverter);
        when(muleRegistry.lookupTransformers(dataTypeA, dataTypeB)).thenReturn(transformers);
View Full Code Here

    }

    @Test
    public void findsExpectedConverter() throws TransformerException
    {
        Transformer expectedConverter = new MockConverterBuilder().from(DataTypeFactory.BYTE_ARRAY).to(DataTypeFactory.STRING).build();

        when(muleContext.getRegistry()).thenReturn(muleRegistry);
        when(muleRegistry.lookupTransformer(DataTypeFactory.BYTE_ARRAY, DataTypeFactory.STRING)).thenReturn(expectedConverter);

        DynamicDataTypeConversionResolver resolver = new DynamicDataTypeConversionResolver(muleContext);
View Full Code Here

{

    @Test
    public void testExactMatch() throws Exception
    {
        Transformer trans = new MockConverterBuilder().from(DataTypeFactory.create(IOException.class)).to(DataTypeFactory.BYTE_ARRAY).build();

        TransformerWeighting weighting = new TransformerWeighting(IOException.class, byte[].class, trans);

        assertFalse(weighting.isNotMatch());
        assertTrue(weighting.isExactMatch());
View Full Code Here

    }

    @Test
    public void testNearMatch() throws Exception
    {
        Transformer trans = new MockConverterBuilder().from(DataTypeFactory.INPUT_STREAM).to(DataTypeFactory.BYTE_ARRAY).build();

        TransformerWeighting weighting = new TransformerWeighting(FilterInputStream.class, byte[].class, trans);

        assertFalse(weighting.isNotMatch());
        assertFalse(weighting.isExactMatch());
View Full Code Here

    }

    @Test
    public void testNoMatchWeighting() throws Exception
    {
        Transformer trans = new MockConverterBuilder().from(DataTypeFactory.create(Serializable.class)).to(DataTypeFactory.BYTE_ARRAY).build();

        TransformerWeighting weighting = new TransformerWeighting(FruitBowl.class, byte[].class, trans);

        assertTrue(weighting.isNotMatch());
        assertEquals(-1, weighting.getInputWeighting());
View Full Code Here

    }

    @Test
    public void testCompareWeightingWithNearMatches() throws Exception
    {
        Transformer trans1 = new MockConverterBuilder().from(DataTypeFactory.create(Serializable.class)).to(DataTypeFactory.BYTE_ARRAY).build();
        Transformer trans2 = new MockConverterBuilder().from(DataTypeFactory.create(Exception.class)).to(DataTypeFactory.BYTE_ARRAY).build();

        TransformerWeighting weighting1 = new TransformerWeighting(IOException.class, byte[].class, trans1);
        TransformerWeighting weighting2 = new TransformerWeighting(IOException.class, byte[].class, trans2);

        assertFalse(weighting1.isNotMatch());
View Full Code Here

    }

    @Test
    public void testCompareWeightingWithExactMatch() throws Exception
    {
        Transformer trans1 = new MockConverterBuilder().from(DataTypeFactory.create(Serializable.class)).to(DataTypeFactory.BYTE_ARRAY).build();
        Transformer trans2 = new MockConverterBuilder().from(DataTypeFactory.create(IOException.class)).to(DataTypeFactory.BYTE_ARRAY).build();

        TransformerWeighting weighting1 = new TransformerWeighting(IOException.class, byte[].class, trans1);
        TransformerWeighting weighting2 = new TransformerWeighting(IOException.class, byte[].class, trans2);

        assertFalse(weighting1.isNotMatch());
View Full Code Here

    }

    @Test
    public void testCompareWeightingWithNoMatch() throws Exception
    {
        Transformer trans1 = new MockConverterBuilder().from(DataTypeFactory.create(Serializable.class)).to(DataTypeFactory.BYTE_ARRAY).build();
        Transformer trans2 = new MockConverterBuilder().from(DataTypeFactory.create(FruitBowl.class)).to(DataTypeFactory.BYTE_ARRAY).build();

        TransformerWeighting weighting1 = new TransformerWeighting(IOException.class, byte[].class, trans1);
        TransformerWeighting weighting2 = new TransformerWeighting(IOException.class, byte[].class, trans2);

        assertFalse(weighting1.isNotMatch());
View Full Code Here

TOP

Related Classes of org.mule.transformer.builder.MockConverterBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.