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);
}
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));
}
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));
}
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));
}
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));
}
Aggregations