use of org.wikivoyage.listings.entity.Listing 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.entity.Listing 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.entity.Listing 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.entity.Listing in project wikivoyage-listings by baturin.
the class NavigationXMLOutputFormat method write.
@Override
public void write(Iterable<Listing> pois, String outputFilename, String dumpDate) throws WriteOutputException {
try {
LinkedList<Listing> filteredPois = new LinkedList<>();
for (Listing poi : pois) {
if (!poi.isPositionalDataEmpty()) {
// POIs with no positional data are useless for navigation - do not add them
// to reduce size of output file
filteredPois.add(poi);
}
}
Listing[] filteredPoisArr = filteredPois.toArray(new Listing[filteredPois.size()]);
XMLSimpleNode rootNode = createXml(filteredPoisArr, dumpDate);
rootNode.writeToFile(outputFilename);
} catch (XMLSimpleNodeException e) {
throw new WriteOutputException();
}
}
use of org.wikivoyage.listings.entity.Listing in project wikivoyage-listings by baturin.
the class OsmAndGPX method createXml.
@Override
public XMLSimpleNode createXml(Listing[] pois, String dumpDate) throws XMLSimpleNodeException {
XMLSimpleNode gpxNode = new XMLSimpleNode("gpx", dumpDate).attrib("version", "1.1").attrib("creator", "wikivoyage-pois-converter").attrib("xmlns", "http://www.topografix.com/GPX/1/1").attribNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
for (Listing poi : pois) {
String name = poi.getTitle() + " (" + poi.getArticle() + ", " + poi.getType() + ")";
new XMLSimpleNode(gpxNode, "wpt").attrib("lat", poi.getLatitude()).attrib("lon", poi.getLongitude()).textChild("name", name);
}
return gpxNode;
}
Aggregations