VBB: Migrate to Hafas client interface.

This commit is contained in:
Andreas Schildbach 2018-07-26 22:37:19 +02:00
parent a9ee06de7f
commit 87a327cedb
2 changed files with 29 additions and 79 deletions

View file

@ -43,18 +43,6 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
super(new VbbProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "9007102"));
print(result);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "2449475"));
assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52548505, 13388640));
@ -95,12 +83,13 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
public void suggestLocationsPOI() throws Exception {
final SuggestLocationsResult result = suggestLocations("schwules museum");
print(result);
Assert.assertThat(result.getLocations(), hasItem(new Location(LocationType.POI, "900980141")));
Assert.assertThat(result.getLocations(), hasItem(new Location(LocationType.POI,
"A=4@O=Berlin, Schwules Museum@X=13357979@Y=52504519@U=104@L=900980141@B=1@V=3.9,@p=1542286309@")));
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Sophienstr. 24");
final SuggestLocationsResult result = suggestLocations("10178 Berlin, Sophienstr. 24");
print(result);
Assert.assertEquals("Sophienstr. 24", result.getLocations().get(0).name);
}
@ -113,14 +102,12 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz"), null,
new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße"), new Date(), true, null);
final Location from = new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz");
final Location to = new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult earlierResult = queryMoreTrips(laterResult.context, false);
print(earlierResult);
}
@ -133,53 +120,36 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
"12357 Berlin-Buckow", "Distelfinkweg 35");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void shortViaTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz"),
new Location(LocationType.STATION, "900044202", "Berlin", "Bundesplatz"),
new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße"), new Date(), true, null);
final Location from = new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz");
final Location via = new Location(LocationType.STATION, "900044202", "Berlin", "Bundesplatz");
final Location to = new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße");
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(52501507, 13357026), null,
Location.coord(52513639, 13568648), new Date(), true, null);
final Location from = Location.coord(Point.fromDouble(52.5249451, 13.3696614)); // Berlin Hbf
final Location to = Location.coord(Point.fromDouble(52.5071378, 13.3318680)); // S Zoologischer Garten
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void viaTripBetweenCoordinates() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(52501507, 13357026),
Location.coord(52479868, 13324247), Location.coord(52513639, 13568648), new Date(), true, null);
final Location from = Location.coord(Point.fromDouble(52.4999599, 13.3619411)); // U Kurfürsterstr.
final Location via = Location.coord(Point.fromDouble(52.4778673, 13.3286942)); // S+U Bundesplatz
final Location to = Location.coord(Point.fromDouble(52.5126122, 13.5752134)); // S+U Wuhletal
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
@ -190,12 +160,6 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
"10437 Berlin-Prenzlauer Berg", "Göhrener Str. 5");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
@ -208,11 +172,5 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
"10178 Berlin-Mitte", "Sophienstr. 24");
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}