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


Java MockProcessContext类代码示例

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


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

示例1: testValidations

import org.apache.nifi.util.MockProcessContext; //导入依赖的package包/类
@Test
public void testValidations() throws IOException {
    TestRunner runner = TestRunners.newTestRunner(OpenScoringProcessor.class);

    Collection<ValidationResult> results;
    ProcessContext pc;
    results = new HashSet<>();
    runner.enqueue(new byte[0]);
    runner.setProperty(OpenScoringProcessor.OPENSCORING_URL, "http://localhost:8080/openscoring");
    runner.setProperty(OpenScoringProcessor.PMML, IOUtils.toString(getClass().getResourceAsStream(PMML_FILE)));

    pc = runner.getProcessContext();
    if (pc instanceof MockProcessContext) {
        results = ((MockProcessContext) pc).validate();
    }
    Assert.assertEquals(0, results.size());
}
 
开发者ID:simonellistonball,项目名称:nifi-ml-bundle,代码行数:18,代码来源:TestOpenScoringProcessor.java

示例2: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。