• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ValidationResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: validate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
public ValidationResult validate(String subject, String input, ValidationContext context) {
    String libDirPath = context.getProperty(CLIENT_LIB_DIR_PATH).getValue();
    StringBuilder invalidationMessageBuilder = new StringBuilder();
    if (libDirPath != null) {
        File file = new File(libDirPath);
        if (!file.isDirectory()) {
            invalidationMessageBuilder.append("'MQ Client Libraries path' must point to a directory. Was '"
                    + file.getAbsolutePath() + "'.");
        }
    } else {
        invalidationMessageBuilder.append("'MQ Client Libraries path' must be provided. \n");
    }
    String invalidationMessage = invalidationMessageBuilder.toString();
    ValidationResult vResult;
    if (invalidationMessage.length() == 0) {
        vResult = new ValidationResult.Builder().subject(subject).input(input)
                .explanation("Client lib path is valid and points to a directory").valid(true).build();
    } else {
        vResult = new ValidationResult.Builder().subject(subject).input(input)
                .explanation("Client lib path is invalid. " + invalidationMessage)
                .valid(false).build();
    }
    return vResult;
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:26,代码来源:JMSConnectionFactoryProviderDefinition.java


示例2: customValidate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
    final Collection<ValidationResult> results = new ArrayList<>();

    parseAtlasUrls(validationContext.getProperty(ATLAS_URLS), input -> {
        final ValidationResult.Builder builder = new ValidationResult.Builder().subject(ATLAS_URLS.getDisplayName()).input(input);
        try {
            new URL(input);
            results.add(builder.explanation("Valid URI").valid(true).build());
        } catch (Exception e) {
            results.add(builder.explanation("Contains invalid URI: " + e).valid(false).build());
        }
    });

    clusterResolverLoader.forEach(resolver -> results.addAll(resolver.validate(validationContext)));

    return results;
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:19,代码来源:AtlasNiFiFlowLineage.java


示例3: validate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
public Collection<ValidationResult> validate(ValidationContext validationContext) {
    final List<ValidationResult> validationResults = new ArrayList<>();
    consumeConfigurations(validationContext.getAllProperties(),
            (clusterNamePatterns, patterns) -> {},
            (entry, e) -> {
                final ValidationResult result = new ValidationResult.Builder()
                        .subject(entry.getKey())
                        .input(entry.getValue())
                        .explanation(e.getMessage())
                        .valid(false)
                        .build();
                validationResults.add(result);
            });
    return validationResults;
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:17,代码来源:RegexClusterResolver.java


示例4: testInvalidClusterName

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Test
public void testInvalidClusterName() {
    final Map<String, String> properties = new HashMap<>();
    properties.put(RegexClusterResolver.PATTERN_PROPERTY_PREFIX, ".*\\.example.com");
    setupMock(properties);
    final RegexClusterResolver resolver = new RegexClusterResolver();

    final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
    Assert.assertEquals(1, validationResults.size());
    final ValidationResult validationResult = validationResults.iterator().next();
    Assert.assertEquals(RegexClusterResolver.PATTERN_PROPERTY_PREFIX, validationResult.getSubject());

    try {
        resolver.configure(context);
        Assert.fail("Configure method should fail, too");
    } catch (IllegalArgumentException e) {
    }
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:19,代码来源:TestRegexClusterResolver.java


示例5: testEmptyPattern

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Test
public void testEmptyPattern() {
    final Map<String, String> properties = new HashMap<>();
    final String propertyName = RegexClusterResolver.PATTERN_PROPERTY_PREFIX + "Cluster1";
    properties.put(propertyName, "");
    setupMock(properties);
    final RegexClusterResolver resolver = new RegexClusterResolver();

    final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
    Assert.assertEquals(1, validationResults.size());
    final ValidationResult validationResult = validationResults.iterator().next();
    Assert.assertEquals(propertyName, validationResult.getSubject());

    try {
        resolver.configure(context);
        Assert.fail("Configure method should fail, too");
    } catch (IllegalArgumentException e) {
    }
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:20,代码来源:TestRegexClusterResolver.java


示例6: testMultiplePatterns

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Test
public void testMultiplePatterns() {
    final Map<String, String> properties = new HashMap<>();
    final String propertyName = RegexClusterResolver.PATTERN_PROPERTY_PREFIX + "Cluster1";
    // Hostname or local ip address, delimited with a whitespace
    properties.put(propertyName, "^.*\\.example.com$\n^192.168.1.[\\d]+$");
    setupMock(properties);
    final RegexClusterResolver resolver = new RegexClusterResolver();

    final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
    Assert.assertEquals(0, validationResults.size());

    resolver.configure(context);

    Assert.assertEquals("Cluster1", resolver.fromHostname("host1.example.com"));
    Assert.assertEquals("Cluster1", resolver.fromHostname("192.168.1.10"));
    Assert.assertEquals("Cluster1", resolver.fromHostname("192.168.1.22"));
    Assert.assertNull(resolver.fromHostname("192.168.2.30"));
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:20,代码来源:TestRegexClusterResolver.java


示例7: testMultipleClusters

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Test
public void testMultipleClusters() {
    final Map<String, String> properties = new HashMap<>();
    final String c1PropertyName = RegexClusterResolver.PATTERN_PROPERTY_PREFIX + "Cluster1";
    final String c2PropertyName = RegexClusterResolver.PATTERN_PROPERTY_PREFIX + "Cluster2";
    // Hostname or local ip address
    properties.put(c1PropertyName, "^.*\\.c1\\.example.com$ ^192.168.1.[\\d]+$");
    properties.put(c2PropertyName, "^.*\\.c2\\.example.com$ ^192.168.2.[\\d]+$");
    setupMock(properties);
    final RegexClusterResolver resolver = new RegexClusterResolver();

    final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
    Assert.assertEquals(0, validationResults.size());

    resolver.configure(context);

    Assert.assertEquals("Cluster1", resolver.fromHostname("host1.c1.example.com"));
    Assert.assertEquals("Cluster1", resolver.fromHostname("192.168.1.10"));
    Assert.assertEquals("Cluster1", resolver.fromHostname("192.168.1.22"));
    Assert.assertEquals("Cluster2", resolver.fromHostname("host2.c2.example.com"));
    Assert.assertEquals("Cluster2", resolver.fromHostname("192.168.2.10"));
    Assert.assertEquals("Cluster2", resolver.fromHostname("192.168.2.22"));
    Assert.assertNull(resolver.fromHostname("192.168.3.30"));
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:25,代码来源:TestRegexClusterResolver.java


示例8: customValidate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(final ValidationContext context) {
    final Collection<ValidationResult> results = new ArrayList<>();

    PropertyValue usernameProperty = context.getProperty(USERNAME);
    PropertyValue passwordProperty = context.getProperty(PASSWORD);
    PropertyValue authDatabaseProperty = context.getProperty(AUTH_DATABASE);

    boolean valid = true;
    if (usernameProperty.isSet() || passwordProperty.isSet() || authDatabaseProperty.isSet()) {
        valid = usernameProperty.isSet() && passwordProperty.isSet() && authDatabaseProperty.isSet();
    }

    results.add(new ValidationResult.Builder()
            .explanation("Using authentication requires Username, Password, and the Authentication Database")
            .valid(valid)
            .subject("Mongo Authentication")
            .build());

    return results;
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:22,代码来源:StandardMongoClientService.java


示例9: addValidationErrors

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
private void addValidationErrors(ConfiguredComponent connectable) {
    ValidationResult validationResult = new ValidationResult.Builder()
            .input("input")
            .subject("subject")
            .explanation("is not valid")
            .build();

    ValidationResult validationResult2 = new ValidationResult.Builder()
            .input("input2")
            .subject("subject2")
            .explanation("is not valid too")
            .build();

    List<ValidationResult> validationResultList = new ArrayList<>();
    validationResultList.add(validationResult);
    validationResultList.add(validationResult2);
    when(connectable.getValidationErrors()).thenReturn(validationResultList);
}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:19,代码来源:StatusConfigReporterTest.java


示例10: customValidate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
    boolean zkQuorumProvided = validationContext.getProperty(ZOOKEEPER_QUORUM).isSet();
    boolean instanceNamerovided = validationContext.getProperty(INSTANCE_NAME).isSet();
    boolean userProvided = validationContext.getProperty(USER).isSet();
    boolean passwordProvided = validationContext.getProperty(PASSWORD).isSet();

    final List<ValidationResult> problems = new ArrayList<>();

    if (!zkQuorumProvided && (!instanceNamerovided || !userProvided || !passwordProvided)) {
        problems.add(new ValidationResult.Builder()
                .valid(false)
                .subject(this.getClass().getSimpleName())
                .explanation("ZooKeeper Quorum, Instance Name, Accumulo User, and Accumulo Password are required " +
                        "to connect")
                .build());
    }
    return problems;
}
 
开发者ID:pinkdevelops,项目名称:nifi-accumulo-service,代码行数:20,代码来源:Accumulo_1_7_0_ConnectorService.java


示例11: validate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
public ValidationResult validate(String subject, String input, ValidationContext context) {
    try {
        JSONUtils.INSTANCE.load(input, new TypeReference<Map<String, String>>() {
        });
    } catch (IOException e) {
        return new ValidationResult.Builder()
                .subject(subject)
                .input(value)
                .valid(false)
                .explanation("Not a valid JSON map value: " + e.getMessage())
                .build();
    }
    return new ValidationResult.Builder()
            .valid(true)
            .input(value)
            .subject(subject)
            .build();
}
 
开发者ID:mmiklavc,项目名称:scalable-ocr,代码行数:20,代码来源:JsonValidator.java


示例12: customValidate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(
		final ValidationContext validationContext) {
	final List<ValidationResult> results = new ArrayList<>();
	final String endpointName = validationContext.getProperty(ENDPOINT)
			.getValue();

	if (ENDPOINT_FILTER.getValue().equals(endpointName)) {
		if (!validationContext.getProperty(TERMS).isSet()
				&& !validationContext.getProperty(FOLLOWING).isSet()
				&& !validationContext.getProperty(LOCATIONS).isSet()) {
			results.add(new ValidationResult.Builder()
					.input("")
					.subject(FOLLOWING.getName())
					.valid(false)
					.explanation(
							"When using the 'Filter Endpoint', at least one of '"
									+ TERMS.getName() + "' or '"
									+ FOLLOWING.getName() + "'" + "' or '"
									+ LOCATIONS.getName() + " must be set")
					.build());
		}
	}

	return results;
}
 
开发者ID:simonellistonball,项目名称:nifi-GetTwitterWithProxy,代码行数:27,代码来源:GetTwitterWithProxy.java


示例13: testValidations

import org.apache.nifi.components.ValidationResult; //导入依赖的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


示例14: customValidate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
    final List<ValidationResult> results = new ArrayList<>(1);

    ObjectMapper mapper = new ObjectMapper();

    JsonNode rootNode = null;
    try {
        rootNode = mapper.readValue(new File(validationContext.getProperty(GENERATOR_RESOURCE).getValue()), JsonNode.class);

        generator = new RecordGenerator(rootNode);

    } catch (IOException ioe) {
        results.add(new ValidationResult.Builder().subject("Generator Resource").valid(false).explanation("Couldn't read specified resource").build());
    }

    return results;
}
 
开发者ID:dstreev,项目名称:nifi-processor-examples,代码行数:19,代码来源:GenerateRecordProcessor.java


示例15: validate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
public Collection<ValidationResult> validate(ValidationContext validationContext) {
    Collection<ValidationResult> results = new ArrayList<>();
    for (ClusterResolver resolver : resolvers) {
        results.addAll(resolver.validate(validationContext));
    }
    return results;
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:9,代码来源:ClusterResolvers.java


示例16: testEmptySettings

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Test
public void testEmptySettings() {
    setupMock(Collections.EMPTY_MAP);
    final RegexClusterResolver resolver = new RegexClusterResolver();

    // It should be valid
    final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
    Assert.assertEquals(0, validationResults.size());
    resolver.configure(context);

    Assert.assertNull(resolver.fromHostname("example.com"));
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:13,代码来源:TestRegexClusterResolver.java


示例17: testSinglePattern

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Test
public void testSinglePattern() {
    final Map<String, String> properties = new HashMap<>();
    final String propertyName = RegexClusterResolver.PATTERN_PROPERTY_PREFIX + "Cluster1";
    properties.put(propertyName, "^.*\\.example.com$");
    setupMock(properties);
    final RegexClusterResolver resolver = new RegexClusterResolver();

    final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
    Assert.assertEquals(0, validationResults.size());

    resolver.configure(context);

    Assert.assertEquals("Cluster1", resolver.fromHostname("host1.example.com"));
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:16,代码来源:TestRegexClusterResolver.java


示例18: validate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
        public ValidationResult validate(final String subject, final String value, final ValidationContext context) {
            String reason = null;
            try {
                Object root = JSON.parse(value);
                if (!(root instanceof BasicDBList)) {
                    reason = "not a valid JsonArray";
                }
            } catch (Exception e) {
//                LOGGER.debug("not a valid JSON list", e);
                reason = "unable to parse JSON";
            }
            return new ValidationResult.Builder().subject(subject).input(value).explanation(reason).valid(reason == null).build();
        }
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:15,代码来源:MongoProps.java


示例19: customValidate

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) {
    List<ValidationResult> results = new ArrayList<>();

    if (validationContext.getProperty(INSERT_COMMAND_SOURCE).getValue().equals("attribute")) {
        results.add(StandardValidators.NON_BLANK_VALIDATOR.validate(
                INSERT_COMMAND_ATTRIBUTE.getName(),
                validationContext.getProperty(INSERT_COMMAND_ATTRIBUTE).getValue(),
                validationContext));
    }

    return results;
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:14,代码来源:StoreInMongo.java


示例20: parseReportingTaskStatusRequest

import org.apache.nifi.components.ValidationResult; //导入依赖的package包/类
static ReportingTaskStatus parseReportingTaskStatusRequest(String id, ReportingTaskNode reportingTaskNode, String statusTypes, FlowController flowController, Logger logger) {
    ReportingTaskStatus reportingTaskStatus = new ReportingTaskStatus();
    reportingTaskStatus.setName(id);

    String[] statusSplits = statusTypes.split(",");
    List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletins(
            new BulletinQuery.Builder()
                    .sourceIdMatches(id)
                    .build());
    for (String statusType : statusSplits) {
        switch (statusType.toLowerCase().trim()) {
            case "health":
                ReportingTaskHealth reportingTaskHealth = new ReportingTaskHealth();

                reportingTaskHealth.setScheduledState(reportingTaskNode.getScheduledState().name());
                reportingTaskHealth.setActiveThreads(reportingTaskNode.getActiveThreadCount());
                reportingTaskHealth.setHasBulletins(!bulletinList.isEmpty());

                Collection<ValidationResult> validationResults = reportingTaskNode.getValidationErrors();
                reportingTaskHealth.setValidationErrorList(transformValidationResults(validationResults));

                reportingTaskStatus.setReportingTaskHealth(reportingTaskHealth);
                break;
            case "bulletins":
                reportingTaskStatus.setBulletinList(transformBulletins(bulletinList));
                break;
        }
    }
    return reportingTaskStatus;
}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:31,代码来源:StatusRequestParser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerResponse类代码示例发布时间:2022-05-21
下一篇:
Java RandomAccessibleInterval类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap