• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Chainr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.bazaarvoice.jolt.Chainr的典型用法代码示例。如果您正苦于以下问题:Java Chainr类的具体用法?Java Chainr怎么用?Java Chainr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Chainr类属于com.bazaarvoice.jolt包,在下文中一共展示了Chainr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: itBlowsUpForMissingProviderStockTransform

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test( expectedExceptions = SpecException.class )
public void itBlowsUpForMissingProviderStockTransform() throws IOException
{
    String testPath = "/json/chainr/guice_spec.json";
    Map<String, Object> testUnit = JsonUtils.classpathToMap( testPath );

    Object spec = testUnit.get( "spec" );

    Module parentModule = new AbstractModule() {
        @Override
        protected void configure() {
        }

        @Provides
        public GuiceSpecDrivenTransform.GuiceConfig getConfigD() {
            return new GuiceSpecDrivenTransform.GuiceConfig( "dd" );
        }
    };

    Chainr.fromSpec( spec, new GuiceChainrInstantiator( parentModule ) );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:22,代码来源:GuicedChainrTest.java


示例2: itBlowsUpForMissingProviderSpecTransform

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test( expectedExceptions = SpecException.class )
public void itBlowsUpForMissingProviderSpecTransform() throws IOException
{
    String testPath = "/json/chainr/guice_spec.json";
    Map<String, Object> testUnit = JsonUtils.classpathToMap( testPath );

    Object spec = testUnit.get( "spec" );

    Module parentModule = new AbstractModule() {
        @Override
        protected void configure() {
        }

        @Provides
        public GuiceTransform.GuiceConfig getConfigC() {
            return new GuiceTransform.GuiceConfig( "c", "cc" );
        }
    };

    Chainr.fromSpec( spec, new GuiceChainrInstantiator( parentModule ) );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:22,代码来源:GuicedChainrTest.java


示例3: loadJoltTransformClass

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
private Class<? extends JoltTransform> loadJoltTransformClass(ClassLoader classLoader) {

        try {
            Class opClass = classLoader.loadClass( operationClassName );

            if ( Chainr.class.isAssignableFrom( opClass ) ) {
                throw new SpecException( "Attempt to nest Chainr inside itself" + getErrorMessageIndexSuffix() );
            }

            if ( ! JoltTransform.class.isAssignableFrom( opClass ) )
            {
                throw new SpecException( "JOLT Chainr class:" + operationClassName + " does not implement the JoltTransform interface" + getErrorMessageIndexSuffix() );
            }

            @SuppressWarnings( "unchecked" ) // We know it is some type of Transform due to the check above
            Class<? extends JoltTransform> transformClass = (Class<? extends JoltTransform>) opClass;

            return transformClass;

        } catch ( ClassNotFoundException e ) {
            throw new SpecException( "JOLT Chainr could not find transform class:" + operationClassName + getErrorMessageIndexSuffix(), e );
        }
    }
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:24,代码来源:ChainrEntry.java


示例4: convertJmhJsonData

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
/**
 * Load the JSON template data and convert it.
 */
private static void convertJmhJsonData(InputStream specIn, InputStream jmhIn, OutputStream out) throws IOException {
  List<?> chainrConfig = JsonUtils.jsonToList(specIn);
  Chainr chainr = Chainr.fromSpec(chainrConfig);
  List<Object> input = JsonUtils.jsonToList(jmhIn);
  Object jsonOutput = chainr.transform(input);
  out.write(JsonUtils.toJsonString(jsonOutput).getBytes(StandardCharsets.UTF_8));
}
 
开发者ID:google,项目名称:conscrypt,代码行数:11,代码来源:Main.java


示例5: getTransform

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
private synchronized Transform getTransform() throws Exception {
    if (transform == null) {
        if (log.isDebugEnabled()) {
            String path = getResourceUri();
            log.debug("Jolt content read from resource {} with resourceUri: {} for endpoint {}", new Object[]{getResourceUri(), path, getEndpointUri()});
        }

        // Sortr does not require a spec
        if (this.transformDsl == JoltTransformType.Sortr) {
            this.transform = new Sortr();
        } else {
            // getResourceAsInputStream also considers the content cache
            Object spec = JsonUtils.jsonToObject(getResourceAsInputStream());
            switch(this.transformDsl) {
            case Shiftr:
                this.transform = new Shiftr(spec);
                break;
            case Defaultr:
                this.transform = new Defaultr(spec);
                break;
            case Removr:
                this.transform = new Removr(spec);
                break;
            case Chainr:
            default:
                this.transform = Chainr.fromSpec(spec);
                break;
            }
        }
        
    }
    return transform;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:JoltEndpoint.java


示例6: transform

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@NotNull
private InputStream transform(@NotNull InputStream content, @NotNull RequestConfiguration configuration) {
    if (StringUtil.isNotEmpty(configuration.getTransform())) {
        List chainrSpecJSON = JsonUtils.jsonToList(configuration.getTransform());
        Chainr chainr = Chainr.fromSpec(chainrSpecJSON);
        Object inputJSON = JsonUtils.jsonToObject(content);
        Object transformedOutput = chainr.transform(inputJSON);

        return new ByteArrayInputStream(JsonUtils.toJsonString(transformedOutput).getBytes(StandardCharsets.UTF_8));
    } else {
        return content;
    }
}
 
开发者ID:grundic,项目名称:teamcity-web-parameters,代码行数:14,代码来源:WebOptionsManagerImpl.java


示例7: migrate

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
public String migrate(String oldJSON, int targetVersion) {
    LOGGER.debug("Migrating to version {}: {}", targetVersion, oldJSON);

    Chainr transform = getTransformerFor(targetVersion);
    Object transformedObject = transform.transform(JsonUtils.jsonToMap(oldJSON));
    String transformedJSON = JsonUtils.toJsonString(transformedObject);

    LOGGER.debug("After migration to version {}: {}", targetVersion, transformedJSON);
    return transformedJSON;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:ConfigRepoMigrator.java


示例8: getTransformerFor

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
private Chainr getTransformerFor(int targetVersion) {
    try {
        String targetVersionFile = String.format("/config-repo/migrations/%s.json", targetVersion);
        String transformJSON = IOUtils.toString(this.getClass().getResourceAsStream(targetVersionFile), "UTF-8");
        return Chainr.fromSpec(JsonUtils.jsonToList(transformJSON));
    } catch (Exception e) {
        throw new RuntimeException("Failed to migrate to version " + targetVersion, e);
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:10,代码来源:ConfigRepoMigrator.java


示例9: successCases

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test( dataProvider = "getCases")
public void successCases( String testCaseName, Object spec, Object input, Map<String,Object> context, Object expected ) throws IOException {

    Module parentModule = new AbstractModule() {
        @Override
        protected void configure() {
        }

        @Provides
        public GuiceContextDrivenTransform.GuiceConfig getConfigC() {
            return new GuiceContextDrivenTransform.GuiceConfig( "c", "cc" );
        }

        @Provides
        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 );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:29,代码来源:GuicedChainrContextTest.java


示例10: successTestCase

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test
public void successTestCase() throws IOException {

    String testPath = "/json/chainr/guice_spec.json";
    Map<String, Object> testUnit = JsonUtils.classpathToMap( testPath );

    Object input = testUnit.get( "input" );
    Object spec = testUnit.get( "spec" );
    Object expected = testUnit.get( "expected" );

    Module parentModule = new AbstractModule() {
        @Override
        protected void configure() {
        }

        @Provides
        public GuiceTransform.GuiceConfig getConfigC() {
            return new GuiceTransform.GuiceConfig( "c", "cc" );
        }

        @Provides
        public GuiceSpecDrivenTransform.GuiceConfig getConfigD() {
            return new GuiceSpecDrivenTransform.GuiceConfig( "dd" );
        }
    };

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

    Assert.assertFalse( unit.hasContextualTransforms() );
    Assert.assertEquals( unit.getContextualTransforms().size(), 0 );

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

    JoltTestUtil.runDiffy( "failed case " + testPath, expected, actual );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:36,代码来源:GuicedChainrTest.java


示例11: itBlowsUpForBadGuiceTransform

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test( expectedExceptions = SpecException.class )
public void itBlowsUpForBadGuiceTransform() {
    Chainr.fromSpec( ImmutableList.of( ImmutableMap.of( "operator", "com.bazaarvoice.jolt.chainr.transforms.GuiceTransformMissingInjectAnnotation" ) ),
            new GuiceChainrInstantiator( new AbstractModule() {
                @Override
                protected void configure() {
                }

                @Provides
                public GuiceTransformMissingInjectAnnotation.BadGuiceConfig getConfigC() {
                    return new GuiceTransformMissingInjectAnnotation.BadGuiceConfig( "b:", "bad" );
                }
            } ) );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:15,代码来源:GuicedChainrTest.java


示例12: build

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
public Chainr build() {
    ChainrSpec chainrSpec = new ChainrSpec( chainrSpecObj, classLoader );
    List<JoltTransform> transforms = new ArrayList<>( chainrSpec.getChainrEntries().size() );
    for ( ChainrEntry entry : chainrSpec.getChainrEntries() ) {

        JoltTransform transform = chainrInstantiator.hydrateTransform( entry );
        transforms.add( transform );
    }

    return new Chainr( transforms );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:12,代码来源:ChainrBuilder.java


示例13: testPassing

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test(dataProvider = "passingTestCases" )
public void testPassing(Object input, Object spec) {
    Chainr unit = Chainr.fromSpec( spec );
    TransformTestResult actual = (TransformTestResult) unit.transform( input, null );

    Assert.assertEquals( input, actual.input );
    Assert.assertNotNull( actual.spec );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:9,代码来源:ChainrInitializationTest.java


示例14: failsOnStupidTransform

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test( expectedExceptions = SpecException.class )
public void failsOnStupidTransform() {
    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 );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:10,代码来源:ChainrInitializationTest.java


示例15: failsOnOverEagerTransform

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test( expectedExceptions = SpecException.class )
public void failsOnOverEagerTransform() {
    List<JoltTransform> badSpec = Lists.newArrayList();

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

    new Chainr( badSpec );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:10,代码来源:ChainrInitializationTest.java


示例16: staticChainrMethod

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test(dataProvider = "badFormatSpecs", expectedExceptions = SpecException.class )
public void staticChainrMethod(Object chainrSpec) {
    Chainr.fromSpec( chainrSpec ); // should fail when parsing spec
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:5,代码来源:ChainrSpecFormatTest.java


示例17: testBadTransforms

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test(dataProvider = "badTransforms", expectedExceptions = TransformException.class )
public void testBadTransforms(Object chainrSpec) {
    Chainr unit = Chainr.fromSpec( chainrSpec );
    unit.transform( new HashMap(), null );// should fail here
    Assert.fail( "Should not have gotten here" );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:7,代码来源:ChainrInitializationTest.java


示例18: failsOnNullListOfJoltTransforms

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test( expectedExceptions = IllegalArgumentException.class )
public void failsOnNullListOfJoltTransforms() {
    new Chainr( null );
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:5,代码来源:ChainrInitializationTest.java


示例19: testFails

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@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());
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:6,代码来源:ChainrIncrementTest.java


示例20: staticChainrMethod

import com.bazaarvoice.jolt.Chainr; //导入依赖的package包/类
@Test(dataProvider = "badFormatSpecs", expectedExceptions = SpecException.class )
public void staticChainrMethod( Object chainrSpec ) {
    Chainr.fromSpec( chainrSpec ); // should fail when parsing spec
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:5,代码来源:ChainrSpecLoadingTest.java



注:本文中的com.bazaarvoice.jolt.Chainr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Alias类代码示例发布时间:2022-05-23
下一篇:
Java EntityWither类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap