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