當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。