Package com.bazaarvoice.jolt

Examples of com.bazaarvoice.jolt.Chainr


        };
    }

    @Test(dataProvider = "badTransforms", expectedExceptions = TransformException.class )
    public void testBadTransforms(Object chainrSpec) {
        Chainr unit = Chainr.fromSpec( chainrSpec );
        unit.transform( new HashMap(), null );// should fail here
        AssertJUnit.fail( "Should not have gotten here" );
    }
View Full Code Here


        };
    }

    @Test(dataProvider = "passingTestCases" )
    public void testPassing(Object input, Object spec) {
        Chainr unit = Chainr.fromSpec( spec );
        TransformTestResult actual = null;
        actual = (TransformTestResult) unit.transform( input, null );

        AssertJUnit.assertEquals( input, actual.input );
        AssertJUnit.assertNotNull( actual.spec );
    }
View Full Code Here

        new ChainrBuilder( validSpec ).loader( null );
    }

    @Test( expectedExceptions = IllegalArgumentException.class )
    public void failsOnNullListOfJoltTransforms() {
        new Chainr( null );
    }
View Full Code Here

        List<JoltTransform> badSpec = Lists.newArrayList();

        // Stupid JoltTransform that implements the base interface, and not one of the useful ones
        badSpec.add( new JoltTransform() {} );

        new Chainr( badSpec );
    }
View Full Code Here

        List<JoltTransform> badSpec = Lists.newArrayList();

        // Stupid JoltTransform that implements both "real" interfaces
        badSpec.add( new OverEagerTransform() );

        new Chainr( badSpec );
    }
View Full Code Here

        };
    }

    @Test( dataProvider = "fromToTests")
    public void testChainrIncrementsFromTo( Object chainrSpec, int start, int end ) throws IOException {
        Chainr chainr = Chainr.fromSpec( chainrSpec );

        Object expected = JsonUtils.classpathToObject( "/json/chainr/increments/" + start + "-" + end + ".json" );

        Object actual = chainr.transform( start, end, new HashMap() );

        JoltTestUtil.runDiffy( "failed incremental From-To Chainr", expected, actual );
    }
View Full Code Here

    }

    @Test( dataProvider = "toTests")
    public void testChainrIncrementsTo( Object chainrSpec, int end  ) throws IOException {

        Chainr chainr = Chainr.fromSpec( chainrSpec );

        Object expected = JsonUtils.classpathToObject( "/json/chainr/increments/0-" + end + ".json" );

        Object actual = chainr.transform( end, new HashMap() );

        JoltTestUtil.runDiffy( "failed incremental To Chainr", expected, actual );
    }
View Full Code Here

        };
    }

    @Test( dataProvider = "failTests", expectedExceptions = TransformException.class)
    public void testFails( Object chainrSpec, int start, int end  ) throws IOException {
        Chainr chainr = Chainr.fromSpec( chainrSpec );
        chainr.transform( start, end, new HashMap());
    }
View Full Code Here

public class JoltSample {

    public static void main(String[] args) throws IOException {

        List chainrSpecJSON = JsonUtils.classpathToList( "/json/sample/spec.json" );
        Chainr chainr = Chainr.fromSpec( chainrSpecJSON );

        Object inputJSON = JsonUtils.classpathToObject( "/json/sample/input.json" );

        Object transformedOutput = chainr.transform( inputJSON );
        System.out.println( JsonUtils.toJsonString( transformedOutput ) );
    }
View Full Code Here

            public GuiceSpecAndContextDrivenTransform.GuiceConfig getConfigD() {
                return new GuiceSpecAndContextDrivenTransform.GuiceConfig( "dd" );
            }
        };

        Chainr unit = Chainr.fromSpec( spec, new GuiceChainrInstantiator( parentModule ) );

        Assert.assertTrue( unit.hasContextualTransforms() );
        Assert.assertEquals( unit.getContextualTransforms().size(), 2 );

        Object actual = unit.transform( input, context );

        JoltTestUtil.runDiffy( "failed case " + testCaseName, expected, actual );
    }
View Full Code Here

TOP

Related Classes of com.bazaarvoice.jolt.Chainr

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.