本文整理匯總了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()));
}