Search in sources :

Example 1 with WikidataValidator

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());
}
Also used : WikidataValidator(org.wikivoyage.listings.validators.WikidataValidator) Listing(org.wikivoyage.listings.entity.Listing) Test(org.junit.Test)

Example 2 with WikidataValidator

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;
}
Also used : WikidataValidator(org.wikivoyage.listings.validators.WikidataValidator) EmailValidator(org.wikivoyage.listings.validators.EmailValidator) Listing(org.wikivoyage.listings.entity.Listing) LatitudeValidator(org.wikivoyage.listings.validators.LatitudeValidator) WebsiteURLValidator(org.wikivoyage.listings.validators.WebsiteURLValidator) LongitudeValidator(org.wikivoyage.listings.validators.LongitudeValidator) LongitudeValidator(org.wikivoyage.listings.validators.LongitudeValidator) WebsiteURLValidator(org.wikivoyage.listings.validators.WebsiteURLValidator) EmailValidator(org.wikivoyage.listings.validators.EmailValidator) LatitudeValidator(org.wikivoyage.listings.validators.LatitudeValidator) WikidataValidator(org.wikivoyage.listings.validators.WikidataValidator) Validator(org.wikivoyage.listings.validators.Validator)

Aggregations

Listing (org.wikivoyage.listings.entity.Listing)2 WikidataValidator (org.wikivoyage.listings.validators.WikidataValidator)2 Test (org.junit.Test)1 EmailValidator (org.wikivoyage.listings.validators.EmailValidator)1 LatitudeValidator (org.wikivoyage.listings.validators.LatitudeValidator)1 LongitudeValidator (org.wikivoyage.listings.validators.LongitudeValidator)1 Validator (org.wikivoyage.listings.validators.Validator)1 WebsiteURLValidator (org.wikivoyage.listings.validators.WebsiteURLValidator)1