Search in sources :

Example 1 with AttributeValidationReport

use of ddf.catalog.validation.report.AttributeValidationReport in project ddf by codice.

the class ISO3CountryCodeValidator method validate.

/**
     * {@inheritDoc}
     * <p>
     * Validates only the values of {@code attribute} that are {@link String}s.
     */
@Override
public Optional<AttributeValidationReport> validate(Attribute attribute) {
    Preconditions.checkArgument(attribute != null, "The attribute cannot be null.");
    AttributeValidationReport report = buildReport(attribute);
    return report.getAttributeValidationViolations().isEmpty() ? Optional.empty() : Optional.of(report);
}
Also used : AttributeValidationReport(ddf.catalog.validation.report.AttributeValidationReport)

Example 2 with AttributeValidationReport

use of ddf.catalog.validation.report.AttributeValidationReport in project ddf by codice.

the class EnumerationValidatorTest method testSuggestedValues.

@Test
public void testSuggestedValues() {
    final Optional<AttributeValidationReport> reportOptional = getReport(false, new AttributeImpl("test", "something"));
    assertThat(reportOptional.get().getSuggestedValues(), containsInAnyOrder(ENUMERATED_VALUES));
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) AttributeValidationReport(ddf.catalog.validation.report.AttributeValidationReport) Test(org.junit.Test)

Example 3 with AttributeValidationReport

use of ddf.catalog.validation.report.AttributeValidationReport in project ddf by codice.

the class FutureDateValidatorTest method validateWithErrors.

private void validateWithErrors(final Instant instant, final int expectedErrors) {
    final Optional<AttributeValidationReport> reportOptional = VALIDATOR.validate(new AttributeImpl("test", Date.from(instant)));
    assertThat(reportOptional.get().getAttributeValidationViolations(), hasSize(expectedErrors));
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) AttributeValidationReport(ddf.catalog.validation.report.AttributeValidationReport)

Example 4 with AttributeValidationReport

use of ddf.catalog.validation.report.AttributeValidationReport in project ddf by codice.

the class ISO3CountryCodeValidatorTest method validateNoErrors.

private void validateNoErrors(final Attribute attribute, boolean ignoreCase) {
    ISO3CountryCodeValidator validator = new ISO3CountryCodeValidator(ignoreCase);
    final Optional<AttributeValidationReport> reportOptional = validator.validate(attribute);
    assertThat(reportOptional.isPresent(), is(false));
}
Also used : ISO3CountryCodeValidator(ddf.catalog.validation.impl.validator.ISO3CountryCodeValidator) AttributeValidationReport(ddf.catalog.validation.report.AttributeValidationReport)

Example 5 with AttributeValidationReport

use of ddf.catalog.validation.report.AttributeValidationReport in project ddf by codice.

the class ISO3CountryCodeValidatorTest method validateWithErrors.

private void validateWithErrors(final Attribute attribute, final int expectedErrors, boolean ignoreCase) {
    ISO3CountryCodeValidator validator = new ISO3CountryCodeValidator(ignoreCase);
    final Optional<AttributeValidationReport> reportOptional = validator.validate(attribute);
    assertThat(reportOptional.get().getAttributeValidationViolations(), hasSize(expectedErrors));
}
Also used : ISO3CountryCodeValidator(ddf.catalog.validation.impl.validator.ISO3CountryCodeValidator) AttributeValidationReport(ddf.catalog.validation.report.AttributeValidationReport)

Aggregations

AttributeValidationReport (ddf.catalog.validation.report.AttributeValidationReport)12 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)8 AttributeValidator (ddf.catalog.validation.AttributeValidator)2 ISO3CountryCodeValidator (ddf.catalog.validation.impl.validator.ISO3CountryCodeValidator)2 ValidationViolation (ddf.catalog.validation.violation.ValidationViolation)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Preconditions (com.google.common.base.Preconditions)1 Attribute (ddf.catalog.data.Attribute)1 Metacard (ddf.catalog.data.Metacard)1 FederationException (ddf.catalog.federation.FederationException)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 AttributeValidatorRegistry (ddf.catalog.validation.AttributeValidatorRegistry)1 ReportingMetacardValidator (ddf.catalog.validation.ReportingMetacardValidator)1 AttributeValidationReportImpl (ddf.catalog.validation.impl.report.AttributeValidationReportImpl)1 ValidationViolationImpl (ddf.catalog.validation.impl.violation.ValidationViolationImpl)1 MetacardValidationReport (ddf.catalog.validation.report.MetacardValidationReport)1 ArrayList (java.util.ArrayList)1