use of org.wikivoyage.listings.validators.WikidataValidator in project wikivoyage-listings by baturin.
the class TestWikivoyagePOI method wikidata.
@Test
public void wikidata() {
// Valid
Listing p1 = TestWikivoyagePOI.createWithWikidata("Q42");
// Invalid
Listing p2 = TestWikivoyagePOI.createWithWikidata("Q42\"");
Listing p3 = TestWikivoyagePOI.createWithWikidata("Q4 2");
Listing p4 = TestWikivoyagePOI.createWithWikidata("QID42");
Listing p5 = TestWikivoyagePOI.createWithWikidata("q42");
// Prepare validation iterator
Iterator<Listing> validationIterator = new WikidataValidator().validate(Arrays.asList(p1, p2, p3, p4, p5)).iterator();
// Check results
assertTrue(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
}
use of org.wikivoyage.listings.validators.WikidataValidator in project wikivoyage-listings by baturin.
the class Main method validate.
private static Iterable<Listing> validate(Iterable<Listing> listingIterable) {
Iterable<Listing> validatedIterable = listingIterable;
Validator[] validators = { new LatitudeValidator(), new LongitudeValidator(), new WebsiteURLValidator(), new EmailValidator(), new WikidataValidator() };
for (Validator validator : validators) {
validatedIterable = validator.validate(validatedIterable);
}
return validatedIterable;
}
Aggregations