当前位置: 首页>>代码示例>>Java>>正文


Java MockProcessContext.setProperty方法代码示例

本文整理汇总了Java中org.apache.nifi.util.MockProcessContext.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java MockProcessContext.setProperty方法的具体用法?Java MockProcessContext.setProperty怎么用?Java MockProcessContext.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.nifi.util.MockProcessContext的用法示例。


在下文中一共展示了MockProcessContext.setProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateAtlasUrls

import org.apache.nifi.util.MockProcessContext; //导入方法依赖的package包/类
@Test
public void validateAtlasUrls() throws Exception {
    final AtlasNiFiFlowLineage reportingTask = new AtlasNiFiFlowLineage();
    final MockProcessContext processContext = new MockProcessContext(reportingTask);
    final MockValidationContext validationContext = new MockValidationContext(processContext);

    processContext.setProperty(ATLAS_USER, "admin");
    processContext.setProperty(ATLAS_PASSWORD, "admin");

    BiConsumer<Collection<ValidationResult>, Consumer<ValidationResult>> assertResults = (rs, a) -> {
        assertTrue(rs.iterator().hasNext());
        for (ValidationResult r : rs) {
            logger.info("{}", r);
            final String subject = r.getSubject();
            if (ATLAS_URLS.getDisplayName().equals(subject)) {
                a.accept(r);
            }
        }
    };

    // Default setting.
    assertResults.accept(reportingTask.validate(validationContext),
            r -> assertTrue("Atlas URLs is required", !r.isValid()));


    // Invalid URL.
    processContext.setProperty(ATLAS_URLS, "invalid");
    assertResults.accept(reportingTask.validate(validationContext),
            r -> assertTrue("Atlas URLs is invalid", !r.isValid()));

    // Valid URL
    processContext.setProperty(ATLAS_URLS, "http://atlas.example.com:21000");
    assertTrue(processContext.isValid());

    // Valid URL with Expression
    processContext.setProperty(ATLAS_URLS, "http://atlas.example.com:${literal(21000)}");
    assertTrue(processContext.isValid());

    // Valid URLs
    processContext.setProperty(ATLAS_URLS, "http://atlas1.example.com:21000, http://atlas2.example.com:21000");
    assertTrue(processContext.isValid());

    // Invalid and Valid URLs
    processContext.setProperty(ATLAS_URLS, "invalid, http://atlas2.example.com:21000");
    assertResults.accept(reportingTask.validate(validationContext),
            r -> assertTrue("Atlas URLs is invalid", !r.isValid()));
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:48,代码来源:TestAtlasNiFiFlowLineage.java


注:本文中的org.apache.nifi.util.MockProcessContext.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。