From 68989ec45176fa824bd260443eb14075d403e96f Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Wed, 16 Jul 2014 10:41:50 +0200 Subject: [PATCH] Sort suggested locations by hit quality. --- .../schildbach/pte/AbstractEfaProvider.java | 94 +++++-------------- .../schildbach/pte/AbstractHafasProvider.java | 25 +++-- .../schildbach/pte/AbstractTsiProvider.java | 7 +- .../pte/dto/SuggestLocationsResult.java | 23 ++++- .../schildbach/pte/dto/SuggestedLocation.java | 79 ++++++++++++++++ .../pte/live/AbstractProviderLiveTest.java | 6 +- .../pte/live/BahnProviderLiveTest.java | 6 +- .../pte/live/BayernProviderLiveTest.java | 6 +- .../pte/live/BsvagProviderLiveTest.java | 2 +- .../pte/live/BvgProviderLiveTest.java | 4 +- .../pte/live/MvgProviderLiveTest.java | 8 +- .../pte/live/MvvProviderLiveTest.java | 8 +- .../pte/live/NvbwProviderLiveTest.java | 6 +- .../pte/live/OebbProviderLiveTest.java | 2 +- .../pte/live/RtProviderLiveTest.java | 2 +- .../pte/live/StvProviderLiveTest.java | 10 +- .../pte/live/SvvProviderLiveTest.java | 8 +- .../pte/live/VagfrProviderLiveTest.java | 2 +- .../pte/live/VbbProviderLiveTest.java | 4 +- .../pte/live/VbnProviderLiveTest.java | 2 +- .../pte/live/VorProviderLiveTest.java | 4 +- .../pte/live/VrrProviderLiveTest.java | 10 +- .../pte/live/VvoProviderLiveTest.java | 2 +- .../pte/live/WienProviderLiveTest.java | 4 +- 24 files changed, 187 insertions(+), 137 deletions(-) create mode 100644 enabler/src/de/schildbach/pte/dto/SuggestedLocation.java diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 119329ba..3804f87b 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -19,14 +19,12 @@ package de.schildbach.pte; import java.io.IOException; import java.io.InputStream; -import java.io.Serializable; import java.nio.charset.Charset; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; -import java.util.Collections; import java.util.Currency; import java.util.Date; import java.util.GregorianCalendar; @@ -65,6 +63,7 @@ import de.schildbach.pte.dto.ResultHeader; import de.schildbach.pte.dto.StationDepartures; import de.schildbach.pte.dto.Stop; import de.schildbach.pte.dto.SuggestLocationsResult; +import de.schildbach.pte.dto.SuggestedLocation; import de.schildbach.pte.dto.Trip; import de.schildbach.pte.exception.InvalidDataException; import de.schildbach.pte.exception.ParserException; @@ -252,7 +251,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider try { - final List locations = new ArrayList(); + final List locations = new ArrayList(); final JSONObject head = new JSONObject(page.toString()); final JSONObject stopFinder = head.optJSONObject("stopFinder"); @@ -267,7 +266,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider if (points != null) { final JSONObject stop = points.getJSONObject("point"); - final Location location = parseJsonStop(stop); + final SuggestedLocation location = parseJsonStop(stop); locations.add(location); return new SuggestLocationsResult(header, locations); } @@ -280,7 +279,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider for (int i = 0; i < nStops; i++) { final JSONObject stop = stops.optJSONObject(i); - final Location location = parseJsonStop(stop); + final SuggestedLocation location = parseJsonStop(stop); locations.add(location); } @@ -292,12 +291,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider } } - private Location parseJsonStop(final JSONObject stop) throws JSONException + private SuggestedLocation parseJsonStop(final JSONObject stop) throws JSONException { String type = stop.getString("type"); if ("any".equals(type)) type = stop.getString("anyType"); final String name = normalizeLocationName(stop.getString("object")); + final int quality = stop.getInt("quality"); final JSONObject ref = stop.getJSONObject("ref"); String place = ref.getString("place"); if (place != null && place.length() == 0) @@ -317,16 +317,19 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider lon = 0; } + final Location location; if ("stop".equals(type)) - return new Location(LocationType.STATION, stop.getString("stateless"), lat, lon, place, name); + location = new Location(LocationType.STATION, stop.getString("stateless"), lat, lon, place, name); else if ("poi".equals(type)) - return new Location(LocationType.POI, null, lat, lon, place, name); + location = new Location(LocationType.POI, null, lat, lon, place, name); else if ("crossing".equals(type)) - return new Location(LocationType.ADDRESS, null, lat, lon, place, name); + location = new Location(LocationType.ADDRESS, null, lat, lon, place, name); else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type) || "buildingname".equals(type)) - return new Location(LocationType.ADDRESS, null, lat, lon, place, normalizeLocationName(stop.getString("name"))); + location = new Location(LocationType.ADDRESS, null, lat, lon, place, normalizeLocationName(stop.getString("name"))); else throw new JSONException("unknown type: " + type); + + return new SuggestedLocation(location, quality); } private StringBuilder stopfinderRequestParameters(final Location constraint, final String outputFormat) @@ -374,7 +377,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider pp.setInput(is, null); final ResultHeader header = enterItdRequest(pp); - final List locations = new ArrayList(); + final List locations = new ArrayList(); XmlPullUtil.enter(pp, "itdStopFinderRequest"); @@ -396,7 +399,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider if ("identified".equals(nameState) || "list".equals(nameState)) { while (XmlPullUtil.test(pp, "odvNameElem")) - locations.add(processOdvNameElem(pp, null)); + { + final int matchQuality = XmlPullUtil.intAttr(pp, "matchQuality"); + final Location location = processOdvNameElem(pp, null); + locations.add(new SuggestedLocation(location, matchQuality)); + } } else if ("notidentified".equals(nameState)) { @@ -426,57 +433,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider } } - private class LocationAndQuality implements Serializable, Comparable - { - public final Location location; - public final int quality; - - public LocationAndQuality(final Location location, final int quality) - { - this.location = location; - this.quality = quality; - } - - public int compareTo(final LocationAndQuality other) - { - // prefer quality - if (this.quality > other.quality) - return -1; - else if (this.quality < other.quality) - return 1; - - // prefer stations - final int compareLocationType = this.location.type.compareTo(other.location.type); - if (compareLocationType != 0) - return compareLocationType; - - return 0; - } - - @Override - public boolean equals(final Object o) - { - if (o == this) - return true; - if (!(o instanceof LocationAndQuality)) - return false; - final LocationAndQuality other = (LocationAndQuality) o; - return location.equals(other.location); - } - - @Override - public int hashCode() - { - return location.hashCode(); - } - - @Override - public String toString() - { - return quality + ":" + location; - } - } - protected SuggestLocationsResult mobileStopfinderRequest(final Location constraint) throws IOException { final StringBuilder parameters = stopfinderRequestParameters(constraint, "XML"); @@ -500,7 +456,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider pp.setInput(is, null); final ResultHeader header = enterEfa(pp); - final List locations = new ArrayList(); + final List locations = new ArrayList(); XmlPullUtil.require(pp, "sf"); if (!pp.isEmptyElementTag()) @@ -548,7 +504,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider final Location location = new Location(type, type == LocationType.STATION ? id : null, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name); - final LocationAndQuality locationAndQuality = new LocationAndQuality(location, quality); + final SuggestedLocation locationAndQuality = new SuggestedLocation(location, quality); locations.add(locationAndQuality); } @@ -559,13 +515,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider XmlPullUtil.next(pp); } - Collections.sort(locations); - - final List results = new ArrayList(locations.size()); - for (final LocationAndQuality location : locations) - results.add(location.location); - - return new SuggestLocationsResult(header, results); + return new SuggestLocationsResult(header, locations); } catch (final XmlPullParserException x) { diff --git a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java index eeef1a57..1dba6e30 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java @@ -64,6 +64,7 @@ import de.schildbach.pte.dto.ResultHeader; import de.schildbach.pte.dto.StationDepartures; import de.schildbach.pte.dto.Stop; import de.schildbach.pte.dto.SuggestLocationsResult; +import de.schildbach.pte.dto.SuggestedLocation; import de.schildbach.pte.dto.Trip; import de.schildbach.pte.exception.ParserException; import de.schildbach.pte.exception.SessionExpiredException; @@ -342,7 +343,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (mJson.matches()) { final String json = mJson.group(1); - final List locations = new ArrayList(); + final List locations = new ArrayList(); try { @@ -358,6 +359,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider final String value = suggestion.getString("value"); final int lat = suggestion.optInt("ycoord"); final int lon = suggestion.optInt("xcoord"); + final int weight = suggestion.getInt("weight"); String localId = null; final Matcher m = P_AJAX_GET_STOPS_ID.matcher(suggestion.getString("id")); if (m.matches()) @@ -366,16 +368,19 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (type == 1) // station { final String[] placeAndName = splitPlaceAndName(value); - locations.add(new Location(LocationType.STATION, localId, lat, lon, placeAndName[0], placeAndName[1])); + final Location location = new Location(LocationType.STATION, localId, lat, lon, placeAndName[0], placeAndName[1]); + locations.add(new SuggestedLocation(location, weight)); } else if (type == 2) // address { final String[] placeAndName = splitPlaceAndName(value); - locations.add(new Location(LocationType.ADDRESS, null, lat, lon, placeAndName[0], placeAndName[1])); + final Location location = new Location(LocationType.ADDRESS, null, lat, lon, placeAndName[0], placeAndName[1]); + locations.add(new SuggestedLocation(location, weight)); } else if (type == 4) // poi { - locations.add(new Location(LocationType.POI, localId, lat, lon, null, value)); + final Location location = new Location(LocationType.POI, localId, lat, lon, null, value); + locations.add(new SuggestedLocation(location, weight)); } else if (type == 71) // strange (VBN) { @@ -747,7 +752,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (!from.isIdentified()) { - final List locations = suggestLocations(from.name).locations; + final List locations = suggestLocations(from.name).getLocations(); if (locations.isEmpty()) return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO if (locations.size() > 1) @@ -757,7 +762,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (via != null && !via.isIdentified()) { - final List locations = suggestLocations(via.name).locations; + final List locations = suggestLocations(via.name).getLocations(); if (locations.isEmpty()) return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO if (locations.size() > 1) @@ -767,7 +772,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (!to.isIdentified()) { - final List locations = suggestLocations(to.name).locations; + final List locations = suggestLocations(to.name).getLocations(); if (locations.isEmpty()) return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO if (locations.size() > 1) @@ -1366,7 +1371,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (!from.isIdentified()) { - final List locations = suggestLocations(from.name).locations; + final List locations = suggestLocations(from.name).getLocations(); if (locations.isEmpty()) return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO if (locations.size() > 1) @@ -1376,7 +1381,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (via != null && !via.isIdentified()) { - final List locations = suggestLocations(via.name).locations; + final List locations = suggestLocations(via.name).getLocations(); if (locations.isEmpty()) return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO if (locations.size() > 1) @@ -1386,7 +1391,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (!to.isIdentified()) { - final List locations = suggestLocations(to.name).locations; + final List locations = suggestLocations(to.name).getLocations(); if (locations.isEmpty()) return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO if (locations.size() > 1) diff --git a/enabler/src/de/schildbach/pte/AbstractTsiProvider.java b/enabler/src/de/schildbach/pte/AbstractTsiProvider.java index 29ed0ca7..da691e4c 100644 --- a/enabler/src/de/schildbach/pte/AbstractTsiProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractTsiProvider.java @@ -49,6 +49,7 @@ import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.ResultHeader; import de.schildbach.pte.dto.Stop; import de.schildbach.pte.dto.SuggestLocationsResult; +import de.schildbach.pte.dto.SuggestedLocation; import de.schildbach.pte.dto.Trip; import de.schildbach.pte.exception.ParserException; import de.schildbach.pte.util.ParserUtils; @@ -198,7 +199,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider final CharSequence page = ParserUtils.scrape(uri.toString(), null, UTF_8, null, 3); try { - final List locations = new ArrayList(); + final List locations = new ArrayList(); final JSONObject head = new JSONObject(page.toString()); int status = head.getInt("StatusCode"); @@ -214,7 +215,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider if (location.isIdentified()) // make sure the location is really identified // some addresses may not contain coordinates, we ignore them - locations.add(location); + locations.add(new SuggestedLocation(location)); } return new SuggestLocationsResult(HEADER, locations); @@ -267,7 +268,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider if (location.isIdentified()) return Collections.singletonList(location); - final List locations = suggestLocations(location.uniqueShortName()).locations; + final List locations = suggestLocations(location.uniqueShortName()).getLocations(); if (locations == null) return new ArrayList(0); diff --git a/enabler/src/de/schildbach/pte/dto/SuggestLocationsResult.java b/enabler/src/de/schildbach/pte/dto/SuggestLocationsResult.java index df2684e2..ce160f51 100644 --- a/enabler/src/de/schildbach/pte/dto/SuggestLocationsResult.java +++ b/enabler/src/de/schildbach/pte/dto/SuggestLocationsResult.java @@ -18,6 +18,8 @@ package de.schildbach.pte.dto; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -32,20 +34,20 @@ public final class SuggestLocationsResult implements Serializable public final ResultHeader header; public final Status status; - public final List locations; + private final List suggestedLocations; - public SuggestLocationsResult(final ResultHeader header, final List locations) + public SuggestLocationsResult(final ResultHeader header, final List suggestedLocations) { this.header = header; this.status = Status.OK; - this.locations = locations; + this.suggestedLocations = suggestedLocations; } public SuggestLocationsResult(final ResultHeader header, final Status status) { this.header = header; this.status = status; - this.locations = null; + this.suggestedLocations = null; } @Override @@ -53,8 +55,19 @@ public final class SuggestLocationsResult implements Serializable { final StringBuilder builder = new StringBuilder(getClass().getName()); builder.append("[").append(this.status); - builder.append(" ").append(locations); + builder.append(" ").append(suggestedLocations); builder.append("]"); return builder.toString(); } + + public List getLocations() + { + Collections.sort(suggestedLocations); + + final List locations = new ArrayList(suggestedLocations.size()); + for (final SuggestedLocation location : suggestedLocations) + locations.add(location.location); + + return locations; + } } diff --git a/enabler/src/de/schildbach/pte/dto/SuggestedLocation.java b/enabler/src/de/schildbach/pte/dto/SuggestedLocation.java new file mode 100644 index 00000000..b622dc73 --- /dev/null +++ b/enabler/src/de/schildbach/pte/dto/SuggestedLocation.java @@ -0,0 +1,79 @@ +/* + * Copyright 2013-2014 the original author or authors. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.schildbach.pte.dto; + +import java.io.Serializable; + +/** + * @author Andreas Schildbach + */ +public final class SuggestedLocation implements Serializable, Comparable +{ + public final Location location; + public final int priority; + + public SuggestedLocation(final Location location, final int priority) + { + this.location = location; + this.priority = priority; + } + + public SuggestedLocation(final Location location) + { + this(location, 0); + } + + public int compareTo(final SuggestedLocation other) + { + // prefer quality + if (this.priority > other.priority) + return -1; + else if (this.priority < other.priority) + return 1; + + // prefer stations + final int compareLocationType = this.location.type.compareTo(other.location.type); + if (compareLocationType != 0) + return compareLocationType; + + return 0; + } + + @Override + public boolean equals(final Object o) + { + if (o == this) + return true; + if (!(o instanceof SuggestedLocation)) + return false; + final SuggestedLocation other = (SuggestedLocation) o; + return location.equals(other.location); + } + + @Override + public int hashCode() + { + return location.hashCode(); + } + + @Override + public String toString() + { + return priority + ":" + location; + } +} diff --git a/enabler/test/de/schildbach/pte/live/AbstractProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/AbstractProviderLiveTest.java index 57d31cfa..83c28e1c 100644 --- a/enabler/test/de/schildbach/pte/live/AbstractProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/AbstractProviderLiveTest.java @@ -20,6 +20,7 @@ package de.schildbach.pte.live; import java.io.IOException; import java.util.Collection; import java.util.Date; +import java.util.List; import de.schildbach.pte.NetworkProvider; import de.schildbach.pte.NetworkProvider.Accessibility; @@ -61,8 +62,9 @@ public abstract class AbstractProviderLiveTest protected final void print(final SuggestLocationsResult result) { - System.out.print(result.locations.size() + " "); - for (final Location location : result.locations) + final List locations = result.getLocations(); + System.out.print(locations.size() + " "); + for (final Location location : locations) System.out.print(location + " "); System.out.println(); } diff --git a/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java index a152e8a3..17e66d99 100644 --- a/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java @@ -75,17 +75,17 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest print(result); - assertEquals("Güntzelstr. (U), Berlin", result.locations.get(0).name); + assertEquals("Güntzelstr. (U), Berlin", result.getLocations().get(0).name); } @Test public void suggestLocationsIncomplete() throws Exception { - final SuggestLocationsResult result = provider.suggestLocations("Landungsbr"); + final SuggestLocationsResult result = provider.suggestLocations("Dammt"); print(result); - assertEquals("Hamburg Landungsbrücken", result.locations.get(0).name); + assertEquals("Hamburg Dammtor", result.getLocations().get(0).name); } @Test diff --git a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java index f9e9a271..b8a69e15 100644 --- a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java @@ -101,13 +101,13 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest public void suggestLocationsLocal() throws Exception { final SuggestLocationsResult regensburgResult = provider.suggestLocations("Regensburg"); - assertEquals("80001083", regensburgResult.locations.iterator().next().id); + assertEquals("80001083", regensburgResult.getLocations().iterator().next().id); final SuggestLocationsResult munichResult = provider.suggestLocations("München"); - assertEquals("80000689", munichResult.locations.iterator().next().id); + assertEquals("80000689", munichResult.getLocations().iterator().next().id); final SuggestLocationsResult nurembergResult = provider.suggestLocations("Nürnberg"); - assertEquals("80001020", nurembergResult.locations.iterator().next().id); + assertEquals("80001020", nurembergResult.getLocations().iterator().next().id); } @Test diff --git a/enabler/test/de/schildbach/pte/live/BsvagProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BsvagProviderLiveTest.java index 8157fd6d..00358cdb 100644 --- a/enabler/test/de/schildbach/pte/live/BsvagProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BsvagProviderLiveTest.java @@ -92,7 +92,7 @@ public class BsvagProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult braunschweigResult = provider.suggestLocations("Braunschweig Rhönweg"); print(braunschweigResult); - assertThat(braunschweigResult.locations, hasItem(new Location(LocationType.STATION, "26000351"))); + assertThat(braunschweigResult.getLocations(), hasItem(new Location(LocationType.STATION, "26000351"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java index 5b1fd3b0..af5c3048 100644 --- a/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java @@ -97,7 +97,7 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest print(result); - Assert.assertEquals("Güntzelstr. (U)", result.locations.get(0).name); + Assert.assertEquals("Güntzelstr. (U)", result.getLocations().get(0).name); } @Test @@ -107,7 +107,7 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest print(result); - Assert.assertEquals("Sophienstr. 24", result.locations.get(0).name); + Assert.assertEquals("Sophienstr. 24", result.getLocations().get(0).name); } @Test diff --git a/enabler/test/de/schildbach/pte/live/MvgProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MvgProviderLiveTest.java index 60ee4e9a..b606f18e 100644 --- a/enabler/test/de/schildbach/pte/live/MvgProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/MvgProviderLiveTest.java @@ -92,19 +92,19 @@ public class MvgProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult luedenscheidResult = provider.suggestLocations("Lüdenscheid Freibad"); print(luedenscheidResult); - assertThat(luedenscheidResult.locations, hasItem(new Location(LocationType.STATION, "24200153"))); + assertThat(luedenscheidResult.getLocations(), hasItem(new Location(LocationType.STATION, "24200153"))); final SuggestLocationsResult iserlohnResult = provider.suggestLocations("Iserlohn Rathaus"); print(iserlohnResult); - assertThat(iserlohnResult.locations, hasItem(new Location(LocationType.STATION, "24200764"))); + assertThat(iserlohnResult.getLocations(), hasItem(new Location(LocationType.STATION, "24200764"))); final SuggestLocationsResult plettenbergResult = provider.suggestLocations("Plettenberg Friedhof"); print(plettenbergResult); - assertThat(plettenbergResult.locations, hasItem(new Location(LocationType.STATION, "24202864"))); + assertThat(plettenbergResult.getLocations(), hasItem(new Location(LocationType.STATION, "24202864"))); final SuggestLocationsResult mendenResult = provider.suggestLocations("Menden Am Gillfeld"); print(mendenResult); - assertThat(mendenResult.locations, hasItem(new Location(LocationType.STATION, "24202193"))); + assertThat(mendenResult.getLocations(), hasItem(new Location(LocationType.STATION, "24202193"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java index f34d6fb6..6aff7b9b 100644 --- a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java @@ -99,16 +99,16 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest public void suggestLocationsLocal() throws Exception { final SuggestLocationsResult fraunhoferStrResult = provider.suggestLocations("fraunhofer"); - assertThat(fraunhoferStrResult.locations, hasItem(new Location(LocationType.STATION, "1000150"))); + assertThat(fraunhoferStrResult.getLocations(), hasItem(new Location(LocationType.STATION, "1000150"))); final SuggestLocationsResult hirschgartenResult = provider.suggestLocations("Hirschgarten"); - assertEquals("München", hirschgartenResult.locations.get(0).place); + assertEquals("München", hirschgartenResult.getLocations().get(0).place); final SuggestLocationsResult ostbahnhofResult = provider.suggestLocations("Ostbahnhof"); - assertEquals("München", ostbahnhofResult.locations.get(0).place); + assertEquals("München", ostbahnhofResult.getLocations().get(0).place); final SuggestLocationsResult marienplatzResult = provider.suggestLocations("Marienplatz"); - assertEquals("München", marienplatzResult.locations.get(0).place); + assertEquals("München", marienplatzResult.getLocations().get(0).place); } @Test diff --git a/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java index c0d8d69d..e50b4967 100644 --- a/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java @@ -92,15 +92,15 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult freiburgResult = provider.suggestLocations("Freiburg Hauptbahnhof"); print(freiburgResult); - assertThat(freiburgResult.locations, hasItem(new Location(LocationType.STATION, "6906508"))); + assertThat(freiburgResult.getLocations(), hasItem(new Location(LocationType.STATION, "6906508"))); final SuggestLocationsResult baselResult = provider.suggestLocations("Basel"); print(baselResult); - assertThat(baselResult.locations, hasItem(new Location(LocationType.STATION, "51000007"))); + assertThat(baselResult.getLocations(), hasItem(new Location(LocationType.STATION, "51000007"))); final SuggestLocationsResult constanceResult = provider.suggestLocations("Konstanz"); print(constanceResult); - assertThat(constanceResult.locations, hasItem(new Location(LocationType.STATION, "8706554"))); + assertThat(constanceResult.getLocations(), hasItem(new Location(LocationType.STATION, "8706554"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/OebbProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/OebbProviderLiveTest.java index 06e308f0..7c3d0315 100644 --- a/enabler/test/de/schildbach/pte/live/OebbProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/OebbProviderLiveTest.java @@ -87,7 +87,7 @@ public class OebbProviderLiveTest extends AbstractProviderLiveTest final SuggestLocationsResult result = provider.suggestLocations("Wien"); print(result); - assertTrue(result.locations.size() > 0); + assertTrue(result.getLocations().size() > 0); } @Test diff --git a/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java index fb435644..97d601c6 100644 --- a/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java @@ -96,7 +96,7 @@ public class RtProviderLiveTest extends AbstractProviderLiveTest public void suggestLocationsEncoding() throws Exception { final SuggestLocationsResult result = provider.suggestLocations("Dorfstrasse 1, Schäftland"); - assertEquals("Schöftland, Dorfstrasse", result.locations.get(0).name); + assertEquals("Schöftland, Dorfstrasse", result.getLocations().get(0).name); print(result); } diff --git a/enabler/test/de/schildbach/pte/live/StvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/StvProviderLiveTest.java index 307bc735..7f52be5a 100644 --- a/enabler/test/de/schildbach/pte/live/StvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/StvProviderLiveTest.java @@ -92,23 +92,23 @@ public class StvProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult grazResult = provider.suggestLocations("Graz Brauhaus"); print(grazResult); - assertThat(grazResult.locations, hasItem(new Location(LocationType.STATION, "63203044"))); + assertThat(grazResult.getLocations(), hasItem(new Location(LocationType.STATION, "63203044"))); final SuggestLocationsResult leobenResult = provider.suggestLocations("Leoben Blockhäuser"); print(leobenResult); - assertThat(leobenResult.locations, hasItem(new Location(LocationType.STATION, "63206224"))); + assertThat(leobenResult.getLocations(), hasItem(new Location(LocationType.STATION, "63206224"))); final SuggestLocationsResult bruckResult = provider.suggestLocations("Bruck Hauptplatz"); print(bruckResult); - assertThat(bruckResult.locations, hasItem(new Location(LocationType.STATION, "63202063"))); + assertThat(bruckResult.getLocations(), hasItem(new Location(LocationType.STATION, "63202063"))); final SuggestLocationsResult kindbergResult = provider.suggestLocations("Kindberg Friedhof"); print(kindbergResult); - assertThat(kindbergResult.locations, hasItem(new Location(LocationType.STATION, "63208877"))); + assertThat(kindbergResult.getLocations(), hasItem(new Location(LocationType.STATION, "63208877"))); final SuggestLocationsResult mariborResult = provider.suggestLocations("Maribor Dravograjska Sokolska"); print(mariborResult); - assertThat(mariborResult.locations, hasItem(new Location(LocationType.STATION, "63300136"))); + assertThat(mariborResult.getLocations(), hasItem(new Location(LocationType.STATION, "63300136"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java index 568a94f9..f7548036 100644 --- a/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java @@ -84,19 +84,19 @@ public class SvvProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult salzburgResult = provider.suggestLocations("Salzburg Süd"); print(salzburgResult); - assertThat(salzburgResult.locations, hasItem(new Location(LocationType.STATION, "60650458"))); + assertThat(salzburgResult.getLocations(), hasItem(new Location(LocationType.STATION, "60650458"))); final SuggestLocationsResult strasswalchenResult = provider.suggestLocations("Straßwalchen West"); print(strasswalchenResult); - assertThat(strasswalchenResult.locations, hasItem(new Location(LocationType.STATION, "60656483"))); + assertThat(strasswalchenResult.getLocations(), hasItem(new Location(LocationType.STATION, "60656483"))); final SuggestLocationsResult schwarzachResult = provider.suggestLocations("Schwarzach Abtsdorf"); print(schwarzachResult); - assertThat(schwarzachResult.locations, hasItem(new Location(LocationType.STATION, "60656614"))); + assertThat(schwarzachResult.getLocations(), hasItem(new Location(LocationType.STATION, "60656614"))); final SuggestLocationsResult trimmelkamResult = provider.suggestLocations("Trimmelkam"); print(trimmelkamResult); - assertThat(trimmelkamResult.locations, hasItem(new Location(LocationType.STATION, "60640776"))); + assertThat(trimmelkamResult.getLocations(), hasItem(new Location(LocationType.STATION, "60640776"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/VagfrProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VagfrProviderLiveTest.java index 6db7fc2b..028f63ed 100644 --- a/enabler/test/de/schildbach/pte/live/VagfrProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VagfrProviderLiveTest.java @@ -84,7 +84,7 @@ public class VagfrProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult freiburgResult = provider.suggestLocations("Betzenhauser Torplatz"); print(freiburgResult); - assertThat(freiburgResult.locations, hasItem(new Location(LocationType.STATION, "6930503"))); + assertThat(freiburgResult.getLocations(), hasItem(new Location(LocationType.STATION, "6930503"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java index a41a01bf..8037c3a7 100644 --- a/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java @@ -93,7 +93,7 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest print(result); - Assert.assertEquals("Güntzelstr. (U)", result.locations.get(0).name); + Assert.assertEquals("Güntzelstr. (U)", result.getLocations().get(0).name); } @Test @@ -103,7 +103,7 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest print(result); - Assert.assertEquals("Sophienstr. 24", result.locations.get(0).name); + Assert.assertEquals("Sophienstr. 24", result.getLocations().get(0).name); } @Test diff --git a/enabler/test/de/schildbach/pte/live/VbnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VbnProviderLiveTest.java index 764c5004..8128c5e7 100644 --- a/enabler/test/de/schildbach/pte/live/VbnProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VbnProviderLiveTest.java @@ -91,7 +91,7 @@ public class VbnProviderLiveTest extends AbstractProviderLiveTest print(result); - assertEquals("Göttingen", result.locations.get(0).place); + assertEquals("Göttingen", result.getLocations().get(0).place); } @Test diff --git a/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java index 2161974a..bdb3a1b1 100644 --- a/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java @@ -92,11 +92,11 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult huetteldorfResult = provider.suggestLocations("Hütteldorf"); print(huetteldorfResult); - assertThat(huetteldorfResult.locations, hasItem(new Location(LocationType.STATION, "60200560"))); + assertThat(huetteldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "60200560"))); final SuggestLocationsResult wienerNeustadtResult = provider.suggestLocations("Wiener Neustadt Nord"); print(wienerNeustadtResult); - assertThat(wienerNeustadtResult.locations, hasItem(new Location(LocationType.STATION, "60205223"))); + assertThat(wienerNeustadtResult.getLocations(), hasItem(new Location(LocationType.STATION, "60205223"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java index a6125fed..99cc7869 100644 --- a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java @@ -116,23 +116,23 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult cologneResult = provider.suggestLocations("Köln Ebertplatz"); print(cologneResult); - assertThat(cologneResult.locations, hasItem(new Location(LocationType.STATION, "22000035"))); + assertThat(cologneResult.getLocations(), hasItem(new Location(LocationType.STATION, "22000035"))); final SuggestLocationsResult dortmundResult = provider.suggestLocations("Dortmund Zugstraße"); print(dortmundResult); - assertThat(dortmundResult.locations, hasItem(new Location(LocationType.STATION, "20000524"))); + assertThat(dortmundResult.getLocations(), hasItem(new Location(LocationType.STATION, "20000524"))); final SuggestLocationsResult duesseldorfResult = provider.suggestLocations("Düsseldorf Sternstraße"); print(duesseldorfResult); - assertThat(duesseldorfResult.locations, hasItem(new Location(LocationType.STATION, "20018017"))); + assertThat(duesseldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "20018017"))); final SuggestLocationsResult muensterResult = provider.suggestLocations("Münster Vennheideweg"); print(muensterResult); - assertThat(muensterResult.locations, hasItem(new Location(LocationType.STATION, "24047291"))); + assertThat(muensterResult.getLocations(), hasItem(new Location(LocationType.STATION, "24047291"))); final SuggestLocationsResult aachenResult = provider.suggestLocations("Aachen Elisenbrunnen"); print(aachenResult); - assertThat(aachenResult.locations, hasItem(new Location(LocationType.STATION, "21001029"))); + assertThat(aachenResult.getLocations(), hasItem(new Location(LocationType.STATION, "21001029"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java index 2d54c6df..ad7afc7a 100644 --- a/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java @@ -92,7 +92,7 @@ public class VvoProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult dresdenResult = provider.suggestLocations("Dresden Postplatz"); print(dresdenResult); - assertThat(dresdenResult.locations, hasItem(new Location(LocationType.STATION, "33000037"))); + assertThat(dresdenResult.getLocations(), hasItem(new Location(LocationType.STATION, "33000037"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java index 8fdb74ca..c090b58a 100644 --- a/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java @@ -92,11 +92,11 @@ public class WienProviderLiveTest extends AbstractProviderLiveTest { final SuggestLocationsResult huetteldorfResult = provider.suggestLocations("Wien Hütteldorf"); print(huetteldorfResult); - assertThat(huetteldorfResult.locations, hasItem(new Location(LocationType.STATION, "60200560"))); + assertThat(huetteldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "60200560"))); final SuggestLocationsResult wienerNeustadtResult = provider.suggestLocations("Wiener Neustadt Nord"); print(wienerNeustadtResult); - assertThat(wienerNeustadtResult.locations, hasItem(new Location(LocationType.STATION, "60205223"))); + assertThat(wienerNeustadtResult.getLocations(), hasItem(new Location(LocationType.STATION, "60205223"))); } @Test