Package org.mule.transformer.builder

Examples of org.mule.transformer.builder.MockConverterBuilder


    }

    @Test
    public void clearsCacheWhenRemovesTransformer() throws ResolverException
    {
        Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();
        Converter inputStreamToXml = new MockConverterBuilder().from(INPUT_STREAM_DATA_TYPE).to(XML_DATA_TYPE).build();

        graphResolver.transformerChange(inputStreamToXml, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(xmlToJson, TransformerResolver.RegistryAction.ADDED);

        Transformer transformer = graphResolver.resolve(INPUT_STREAM_DATA_TYPE, JSON_DATA_TYPE);
View Full Code Here


    }

    @Test
    public void resolvesTransformersWithDifferentLength() throws ResolverException
    {
        Converter xmlToInputStream = new MockConverterBuilder().named("xmlToInputStream").from(XML_DATA_TYPE).to(INPUT_STREAM_DATA_TYPE).weighting(1).build();
        Converter xmlToJson = new MockConverterBuilder().named("xmlToJson").from(XML_DATA_TYPE).to(JSON_DATA_TYPE).weighting(1).build();
        Converter inputStreamToJson = new MockConverterBuilder().named("inputStreamToJson").from(INPUT_STREAM_DATA_TYPE).to(JSON_DATA_TYPE).weighting(1).build();

        graphResolver.transformerChange(xmlToInputStream, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(xmlToJson, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(inputStreamToJson, TransformerResolver.RegistryAction.ADDED);
View Full Code Here

    }

    @Test
    public void resolvesTransformersWithSameLengthAndDifferentWeight() throws ResolverException
    {
        Converter xmlToInputStream = new MockConverterBuilder().named("xmlToInputStream").from(XML_DATA_TYPE).to(INPUT_STREAM_DATA_TYPE).weighting(1).build();
        Converter xmlToString = new MockConverterBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).weighting(1).build();
        Converter inputStreamToJson = new MockConverterBuilder().named("inputStreamToJson").from(INPUT_STREAM_DATA_TYPE).to(JSON_DATA_TYPE).weighting(2).build();
        Converter stringToJson = new MockConverterBuilder().named("stringToJson").from(STRING_DATA_TYPE).to(JSON_DATA_TYPE).weighting(1).build();

        graphResolver.transformerChange(xmlToInputStream, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(xmlToString, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(inputStreamToJson, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(stringToJson, TransformerResolver.RegistryAction.ADDED);
View Full Code Here

    }

    @Test
    public void resolvesTransformerWithSameLengthAndSameWeight() throws ResolverException
    {
        Converter xmlToInputStream = new MockConverterBuilder().named("xmlToInputStream").from(XML_DATA_TYPE).to(INPUT_STREAM_DATA_TYPE).weighting(1).build();
        Converter xmlToString = new MockConverterBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).weighting(1).build();
        Converter inputStreamToJson = new MockConverterBuilder().named("inputStreamToJson").from(INPUT_STREAM_DATA_TYPE).to(JSON_DATA_TYPE).weighting(1).build();
        Converter stringToJson = new MockConverterBuilder().named("stringToJson").from(STRING_DATA_TYPE).to(JSON_DATA_TYPE).weighting(1).build();

        graphResolver.transformerChange(xmlToInputStream, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(xmlToString, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(inputStreamToJson, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(stringToJson, TransformerResolver.RegistryAction.ADDED);
View Full Code Here

    }

    @Test(expected = ResolverException.class)
    public void cannotResolveTransformerWithSameLengthAndSameWeightAndSameName() throws ResolverException
    {
        Converter xmlToInputStream1 = new MockConverterBuilder().named("xmlToInputStream").from(XML_DATA_TYPE).to(INPUT_STREAM_DATA_TYPE).weighting(1).build();
        Converter xmlToInputStream2 = new MockConverterBuilder().named("xmlToInputStream").from(XML_DATA_TYPE).to(INPUT_STREAM_DATA_TYPE).weighting(1).build();

        graphResolver.transformerChange(xmlToInputStream1, TransformerResolver.RegistryAction.ADDED);
        graphResolver.transformerChange(xmlToInputStream2, TransformerResolver.RegistryAction.ADDED);

        graphResolver.resolve(XML_DATA_TYPE, INPUT_STREAM_DATA_TYPE);
View Full Code Here

    }

    @Test
    public void filtersEqualLength() throws ResolverException
    {
        Converter xmlToString = new MockConverterBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).build();
        Converter xmlToJson = new MockConverterBuilder().named("xmlToJson").from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();

        List<Converter> availableConverters = new ArrayList<Converter>();
        availableConverters.add(xmlToString);
        availableConverters.add(xmlToJson);
View Full Code Here

    }

    @Test
    public void filtersDifferentLengthWithBetterTrasnformerFist() throws ResolverException
    {
        Converter xmlToString = new MockConverterBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).build();
        Converter stringToJson = new MockConverterBuilder().named("stringToJson").from(STRING_DATA_TYPE).to(JSON_DATA_TYPE).build();

        List<Converter> availableConverters = new ArrayList<Converter>();
        availableConverters.add(xmlToString);
        CompositeConverter compositeConverter = new CompositeConverter(xmlToString, stringToJson);
        availableConverters.add(compositeConverter);
View Full Code Here

    }

    @Test
    public void filtersDifferentLengthWithBetterTransformerLast() throws ResolverException
    {
        Converter xmlToString = new MockConverterBuilder().named("xmlToString").from(XML_DATA_TYPE).to(STRING_DATA_TYPE).build();
        Converter stringToJson = new MockConverterBuilder().named("stringToJson").from(STRING_DATA_TYPE).to(JSON_DATA_TYPE).build();

        List<Converter> availableConverters = new ArrayList<Converter>();
        CompositeConverter compositeConverter = new CompositeConverter(xmlToString, stringToJson);
        availableConverters.add(compositeConverter);
        availableConverters.add(xmlToString);
View Full Code Here

    }

    @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());
View Full Code Here

    }

    @Test
    public void ignoresConverterAddedTwice()
    {
        Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).build();

        TransformationGraph graph = new TransformationGraph();
        graph.addConverter(xmlToJson);
        graph.addConverter(xmlToJson);
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.