本文整理汇总了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());
}
示例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()));
}