Search in sources :

Example 1 with WebsiteURLValidator

use of org.wikivoyage.listings.validators.WebsiteURLValidator in project wikivoyage-listings by baturin.

the class TestWikivoyagePOI method invalidURLs.

@Test
public void invalidURLs() {
    Listing p1 = TestWikivoyagePOI.createWithURL("\"http://wikivoyage.org");
    Listing p2 = TestWikivoyagePOI.createWithURL("[http://wikivoyage.org");
    Listing p3 = TestWikivoyagePOI.createWithURL("http://wikivoyage.org]");
    Listing p4 = TestWikivoyagePOI.createWithURL("wikivoyage.org");
    Listing p5 = TestWikivoyagePOI.createWithURL("mary@wikivoyage.org");
    Listing p6 = TestWikivoyagePOI.createWithURL("ftp://wikivoyage.org]");
    // Prepare validation iterable
    Iterable<Listing> pois = new WebsiteURLValidator().validate(Arrays.asList(p1, p2, p3, p4, p5, p6));
    // Check results
    for (Listing poi : pois) {
        assertFalse(poi.isValid());
    }
}
Also used : Listing(org.wikivoyage.listings.entity.Listing) WebsiteURLValidator(org.wikivoyage.listings.validators.WebsiteURLValidator) Test(org.junit.Test)

Example 2 with WebsiteURLValidator

use of org.wikivoyage.listings.validators.WebsiteURLValidator in project wikivoyage-listings by baturin.

the class TestWikivoyagePOI method validURLs.

@Test
public void validURLs() {
    Listing p1 = TestWikivoyagePOI.createWithURL("http://wikivoyage.org");
    Listing p2 = TestWikivoyagePOI.createWithURL("https://wikivoyage.org");
    Listing p3 = TestWikivoyagePOI.createWithURL("http://wikivoyage.org/");
    Listing p4 = TestWikivoyagePOI.createWithURL("http://www.westinmalta.com");
    Listing p5 = TestWikivoyagePOI.createWithURL("http://www.nix.de");
    // Should not that be considered valid? It works in browsers
    Listing p6 = TestWikivoyagePOI.createWithURL("http://www.kitaena.co.jp/info/馬籠線.pdf");
    Listing p7 = TestWikivoyagePOI.createWithURL("http://www.ville-douai.fr/index.php/Théâtre?idpage=14004");
    Listing p8 = TestWikivoyagePOI.createWithURL("http://www.kitaena.co.jp/info/馬籠線.pdf");
    Listing p9 = TestWikivoyagePOI.createWithURL("http://www.natuurenbos.be/nl-BE/Domeinen/Vlaams-Brabant/arborétum_Heverleebos.aspx");
    Listing p10 = TestWikivoyagePOI.createWithURL("http://www.some-url.de?q=glück");
    Listing p11 = TestWikivoyagePOI.createWithURL("https://www.emirates.store/");
    // Prepare validation iterable
    Iterable<Listing> pois = new WebsiteURLValidator().validate(Arrays.asList(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11));
    // Check results
    for (Listing poi : pois) {
        assertTrue(poi.isValid());
    }
}
Also used : Listing(org.wikivoyage.listings.entity.Listing) WebsiteURLValidator(org.wikivoyage.listings.validators.WebsiteURLValidator) Test(org.junit.Test)

Example 3 with WebsiteURLValidator

use of org.wikivoyage.listings.validators.WebsiteURLValidator 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)3 WebsiteURLValidator (org.wikivoyage.listings.validators.WebsiteURLValidator)3 Test (org.junit.Test)2 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 WikidataValidator (org.wikivoyage.listings.validators.WikidataValidator)1