Package org.mule.transformer.builder

Examples of org.mule.transformer.builder.MockConverterBuilder


    }

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

        TransformationGraph graph = new TransformationGraph();
        graph.addConverter(xmlToJson);

        assertEquals(3, graph.vertexSet().size());
View Full Code Here


    }

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

        TransformationGraph graph = new TransformationGraph();
        graph.addConverter(xmlToJson);
        graph.removeConverter(xmlToJson);
View Full Code Here

    }

    @Test
    public void ignoresRemovingConverterThatWasNeverAdded()
    {
        Converter xmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).weighting(1).build();
        Converter betterXmlToJson = new MockConverterBuilder().from(XML_DATA_TYPE).to(JSON_DATA_TYPE).weighting(2).build();

        TransformationGraph graph = new TransformationGraph();
        graph.addConverter(xmlToJson);
        graph.removeConverter(betterXmlToJson);
View Full Code Here

    }

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

        TransformationGraph graph = new TransformationGraph();
        graph.addConverter(xmlToJson);
        graph.removeConverter(xmlToJson);
View Full Code Here

    }

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

        TransformationGraph graph = new TransformationGraph();
        graph.addConverter(xmlToJson);
        graph.addConverter(betterXmlToJson);
View Full Code Here

    }

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

        TransformationGraph graph = new TransformationGraph();
        graph.addConverter(xmlToJson);
        graph.addConverter(betterXmlToJson);
        graph.removeConverter(xmlToJson);
View Full Code Here

    @Test
    public void failsOnConverterWhenSourceAndReturnTypeDoesNotMatchAndThereIsNoImplicitConversion() throws MuleException
    {
        // Converter(B->C), payload A: FAIL
        Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();

        DefaultMuleMessage message = new DefaultMuleMessage(new A(), muleContext);

        try
        {
View Full Code Here

    @Test
    public void appliesImplicitConversionOnConverterWhenSourceAndReturnTypeDoesNotMatch() throws MuleException
    {
        // Converter(C->D), payload B: uses implicit conversion B->C
        Transformer converter1 = new MockConverterBuilder().from(dataTypeC).to(dataTypeD).returning(new D()).build();
        Transformer converter2 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).returning(new C()).build();

        when(conversionResolver.resolve(Mockito.any(DataType.class), Mockito.anyList())).thenReturn(converter2);

        DefaultMuleMessage message = new DefaultMuleMessage(new B(), muleContext);
View Full Code Here

    @Test
    public void appliesConverter() throws MuleException
    {
        // Converter(B->C), payload B: OK
        Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).returning(new C()).build();

        DefaultMuleMessage message = new DefaultMuleMessage(new B(), muleContext);
        message.applyTransformers(null, converter1);

        assertTrue(message.getPayload() instanceof C);
View Full Code Here

    @Test
    public void skipsConverterThatDoesNotMatchWhenOriginalPayloadMatchesExpectedOutputType() throws MuleException
    {
        // Converter(B->C), payload C: OK - skips transformer but C is the expected output type -> OK
        Transformer converter1 = new MockConverterBuilder().from(dataTypeB).to(dataTypeC).build();

        DefaultMuleMessage message = new DefaultMuleMessage(new C(), muleContext);
        message.applyTransformers(null, converter1);

        assertTrue(message.getPayload() instanceof C);
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.