mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 23:18:48 +00:00
Navitia: Create abstract test class.
This commit is contained in:
parent
9f2b3b57e1
commit
71d88fcd18
2 changed files with 290 additions and 188 deletions
|
@ -0,0 +1,264 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014-2015 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.schildbach.pte.live;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.schildbach.pte.NetworkProvider;
|
||||||
|
import de.schildbach.pte.NetworkProvider.Accessibility;
|
||||||
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
|
import de.schildbach.pte.dto.LineDestination;
|
||||||
|
import de.schildbach.pte.dto.Location;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
|
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||||
|
import de.schildbach.pte.dto.Product;
|
||||||
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
|
import de.schildbach.pte.dto.StationDepartures;
|
||||||
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Antonio El Khoury
|
||||||
|
*/
|
||||||
|
public abstract class AbstractNavitiaProviderLiveTest extends AbstractProviderLiveTest
|
||||||
|
{
|
||||||
|
public AbstractNavitiaProviderLiveTest(final NetworkProvider provider)
|
||||||
|
{
|
||||||
|
super(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void nearbyStationsAddress(final int lat, final int lon) throws IOException
|
||||||
|
{
|
||||||
|
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.ADDRESS, lat, lon),
|
||||||
|
700, 10);
|
||||||
|
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void nearbyStationsStation(final String stationId) throws IOException
|
||||||
|
{
|
||||||
|
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.STATION, stationId),
|
||||||
|
700, 10);
|
||||||
|
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void nearbyStationsPoi(final String poiId) throws IOException
|
||||||
|
{
|
||||||
|
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.POI, poiId), 700, 10);
|
||||||
|
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void nearbyStationsAny(final int lat, final int lon) throws IOException
|
||||||
|
{
|
||||||
|
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.ANY, lat, lon), 700, 10);
|
||||||
|
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void nearbyStationsInvalidStation(final String stationId) throws IOException
|
||||||
|
{
|
||||||
|
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.STATION, stationId),
|
||||||
|
700, 10);
|
||||||
|
assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryDeparturesEquivsFalse(final String stationId) throws IOException
|
||||||
|
{
|
||||||
|
final int maxDepartures = 5;
|
||||||
|
final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, false);
|
||||||
|
assertEquals(QueryDeparturesResult.Status.OK, result.status);
|
||||||
|
assertEquals(1, result.stationDepartures.size());
|
||||||
|
assertTrue(result.stationDepartures.get(0).departures.size() <= maxDepartures);
|
||||||
|
final List<LineDestination> lines = result.stationDepartures.get(0).lines;
|
||||||
|
assertNotNull(lines);
|
||||||
|
assertTrue(lines.size() >= 1);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryDeparturesStopArea(final String stationId) throws IOException
|
||||||
|
{
|
||||||
|
final int maxDepartures = 5;
|
||||||
|
final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, true);
|
||||||
|
assertEquals(QueryDeparturesResult.Status.OK, result.status);
|
||||||
|
assertTrue(result.stationDepartures.size() > 1);
|
||||||
|
int nbDepartures = 0;
|
||||||
|
int nbLines = 0;
|
||||||
|
for (final StationDepartures stationDepartures : result.stationDepartures)
|
||||||
|
{
|
||||||
|
nbDepartures += stationDepartures.departures.size();
|
||||||
|
final List<LineDestination> lines = stationDepartures.lines;
|
||||||
|
if (lines != null)
|
||||||
|
nbLines += lines.size();
|
||||||
|
}
|
||||||
|
assertTrue(nbDepartures <= maxDepartures);
|
||||||
|
assertTrue(nbLines >= 2);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryDeparturesEquivsTrue(final String stationId) throws IOException
|
||||||
|
{
|
||||||
|
final int maxDepartures = 5;
|
||||||
|
final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, true);
|
||||||
|
assertEquals(QueryDeparturesResult.Status.OK, result.status);
|
||||||
|
assertTrue(result.stationDepartures.size() > 1);
|
||||||
|
int nbDepartures = 0;
|
||||||
|
int nbLines = 0;
|
||||||
|
for (StationDepartures stationDepartures : result.stationDepartures)
|
||||||
|
{
|
||||||
|
nbDepartures += stationDepartures.departures.size();
|
||||||
|
final List<LineDestination> lines = stationDepartures.lines;
|
||||||
|
assertNotNull(lines);
|
||||||
|
nbLines += lines.size();
|
||||||
|
}
|
||||||
|
assertTrue(nbDepartures <= maxDepartures);
|
||||||
|
assertTrue(nbLines >= 2);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryDeparturesInvalidStation(final String stationId) throws IOException
|
||||||
|
{
|
||||||
|
final QueryDeparturesResult result = queryDepartures(stationId, false);
|
||||||
|
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void suggestLocationsFromName(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult result = suggestLocations(constraint);
|
||||||
|
assertTrue(result.getLocations().size() > 0);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void suggestLocationsFromAddress(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult result = suggestLocations(constraint);
|
||||||
|
assertTrue(result.getLocations().size() > 0);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void suggestLocationsNoLocation(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult result = suggestLocations(constraint);
|
||||||
|
assertEquals(result.getLocations().size(), 0);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryTrip(final CharSequence from, final CharSequence to) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult fromResult = suggestLocations(from);
|
||||||
|
assertTrue(fromResult.getLocations().size() > 0);
|
||||||
|
final SuggestLocationsResult toResult = suggestLocations(to);
|
||||||
|
assertTrue(toResult.getLocations().size() > 0);
|
||||||
|
|
||||||
|
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
||||||
|
Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||||
|
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryTripNoSolution(final CharSequence from, final CharSequence to) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult fromResult = suggestLocations(from);
|
||||||
|
assertTrue(fromResult.getLocations().size() > 0);
|
||||||
|
final SuggestLocationsResult toResult = suggestLocations(to);
|
||||||
|
assertTrue(toResult.getLocations().size() > 0);
|
||||||
|
|
||||||
|
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
||||||
|
EnumSet.noneOf(Product.class), WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||||
|
assertEquals(QueryTripsResult.Status.NO_TRIPS, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryTripUnknownFrom(final CharSequence to) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult toResult = suggestLocations(to);
|
||||||
|
assertTrue(toResult.getLocations().size() > 0);
|
||||||
|
|
||||||
|
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "stop_area:RTP:SA:999999"), null, toResult.getLocations()
|
||||||
|
.get(0), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||||
|
assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryTripUnknownTo(final CharSequence from) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult fromResult = suggestLocations(from);
|
||||||
|
assertTrue(fromResult.getLocations().size() > 0);
|
||||||
|
|
||||||
|
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, new Location(LocationType.STATION,
|
||||||
|
"stop_area:RTP:SA:999999"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||||
|
assertEquals(QueryTripsResult.Status.UNKNOWN_TO, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryTripSlowWalk(final CharSequence from, final CharSequence to) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult fromResult = suggestLocations(from);
|
||||||
|
assertTrue(fromResult.getLocations().size() > 0);
|
||||||
|
final SuggestLocationsResult toResult = suggestLocations(to);
|
||||||
|
assertTrue(toResult.getLocations().size() > 0);
|
||||||
|
|
||||||
|
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
||||||
|
Product.ALL, WalkSpeed.SLOW, Accessibility.NEUTRAL);
|
||||||
|
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryTripFastWalk(final CharSequence from, final CharSequence to) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult fromResult = suggestLocations(from);
|
||||||
|
assertTrue(fromResult.getLocations().size() > 0);
|
||||||
|
final SuggestLocationsResult toResult = suggestLocations(to);
|
||||||
|
assertTrue(toResult.getLocations().size() > 0);
|
||||||
|
|
||||||
|
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
||||||
|
Product.ALL, WalkSpeed.FAST, Accessibility.NEUTRAL);
|
||||||
|
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void queryMoreTrips(final CharSequence from, final CharSequence to) throws IOException
|
||||||
|
{
|
||||||
|
final SuggestLocationsResult fromResult = suggestLocations(from);
|
||||||
|
assertTrue(fromResult.getLocations().size() > 0);
|
||||||
|
final SuggestLocationsResult toResult = suggestLocations(to);
|
||||||
|
assertTrue(toResult.getLocations().size() > 0);
|
||||||
|
|
||||||
|
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
||||||
|
Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||||
|
final QueryTripsContext context = result.context;
|
||||||
|
|
||||||
|
final QueryTripsResult nextResult = queryMoreTrips(context, true);
|
||||||
|
assertEquals(QueryTripsResult.Status.OK, nextResult.status);
|
||||||
|
print(nextResult);
|
||||||
|
|
||||||
|
final QueryTripsResult prevResult = queryMoreTrips(context, false);
|
||||||
|
assertEquals(QueryTripsResult.Status.OK, prevResult.status);
|
||||||
|
print(prevResult);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,36 +17,17 @@
|
||||||
|
|
||||||
package de.schildbach.pte.live;
|
package de.schildbach.pte.live;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.NetworkProvider.Accessibility;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
|
||||||
import de.schildbach.pte.ParisProvider;
|
import de.schildbach.pte.ParisProvider;
|
||||||
import de.schildbach.pte.dto.LineDestination;
|
|
||||||
import de.schildbach.pte.dto.Location;
|
|
||||||
import de.schildbach.pte.dto.LocationType;
|
|
||||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
|
||||||
import de.schildbach.pte.dto.Point;
|
import de.schildbach.pte.dto.Point;
|
||||||
import de.schildbach.pte.dto.Product;
|
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
|
||||||
import de.schildbach.pte.dto.StationDepartures;
|
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Antonio El Khoury
|
* @author Antonio El Khoury
|
||||||
*/
|
*/
|
||||||
public class ParisProviderLiveTest extends AbstractProviderLiveTest
|
public class ParisProviderLiveTest extends AbstractNavitiaProviderLiveTest
|
||||||
{
|
{
|
||||||
public ParisProviderLiveTest()
|
public ParisProviderLiveTest()
|
||||||
{
|
{
|
||||||
|
@ -56,278 +37,151 @@ public class ParisProviderLiveTest extends AbstractProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStationsAddress() throws Exception
|
public void nearbyStationsAddress() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.ADDRESS, 48877523,
|
nearbyStationsAddress(48877523, 2378353);
|
||||||
2378353), 700, 10);
|
|
||||||
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStationsAddress2() throws Exception
|
public void nearbyStationsAddress2() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.ADDRESS, 48785420,
|
nearbyStationsAddress(48785420, 2212050);
|
||||||
2212050), 2000, 30);
|
|
||||||
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStationsStation() throws Exception
|
public void nearbyStationsStation() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.STATION,
|
nearbyStationsStation("stop_point:RTP:SP:3926410");
|
||||||
"stop_point:RTP:SP:3926410"), 700, 10);
|
|
||||||
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStationsPoi() throws Exception
|
public void nearbyStationsPoi() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.POI, "poi:n668579722"),
|
nearbyStationsPoi("poi:n668579722");
|
||||||
700, 10);
|
|
||||||
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStationsAny() throws Exception
|
public void nearbyStationsAny() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
|
nearbyStationsAny(48877523, 2378353);
|
||||||
new Location(LocationType.ANY, 48877523, 2378353), 700, 10);
|
|
||||||
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStationsInvalidStation() throws Exception
|
public void nearbyStationsInvalidStation() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.STATION,
|
nearbyStationsInvalidStation("stop_point:RTP:SP:392");
|
||||||
"stop_point:RTP:SP:392"), 700, 10);
|
|
||||||
assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryDeparturesEquivsFalse() throws Exception
|
public void queryDeparturesEquivsFalse() throws Exception
|
||||||
{
|
{
|
||||||
final int maxDepartures = 5;
|
queryDeparturesEquivsFalse("stop_point:RTP:SP:3926410");
|
||||||
final QueryDeparturesResult result = queryDepartures("stop_point:RTP:SP:3926410", maxDepartures, false);
|
|
||||||
assertEquals(QueryDeparturesResult.Status.OK, result.status);
|
|
||||||
assertEquals(1, result.stationDepartures.size());
|
|
||||||
assertTrue(result.stationDepartures.get(0).departures.size() <= maxDepartures);
|
|
||||||
final List<LineDestination> lines = result.stationDepartures.get(0).lines;
|
|
||||||
assertNotNull(lines);
|
|
||||||
assertTrue(lines.size() >= 1);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryDeparturesStopArea() throws Exception
|
public void queryDeparturesStopArea() throws Exception
|
||||||
{
|
{
|
||||||
final int maxDepartures = 5;
|
queryDeparturesStopArea("stop_area:RTP:SA:1958");
|
||||||
final QueryDeparturesResult result = queryDepartures("stop_area:RTP:SA:1958", maxDepartures, true);
|
|
||||||
assertEquals(QueryDeparturesResult.Status.OK, result.status);
|
|
||||||
assertTrue(result.stationDepartures.size() > 1);
|
|
||||||
int nbDepartures = 0;
|
|
||||||
int nbLines = 0;
|
|
||||||
for (final StationDepartures stationDepartures : result.stationDepartures)
|
|
||||||
{
|
|
||||||
nbDepartures += stationDepartures.departures.size();
|
|
||||||
final List<LineDestination> lines = stationDepartures.lines;
|
|
||||||
if (lines != null)
|
|
||||||
nbLines += lines.size();
|
|
||||||
}
|
|
||||||
assertTrue(nbDepartures <= maxDepartures);
|
|
||||||
assertTrue(nbLines >= 2);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryDeparturesEquivsTrue() throws Exception
|
public void queryDeparturesEquivsTrue() throws Exception
|
||||||
{
|
{
|
||||||
final int maxDepartures = 5;
|
queryDeparturesEquivsTrue("stop_point:RTP:SP:3926410");
|
||||||
final QueryDeparturesResult result = queryDepartures("stop_point:RTP:SP:3926410", maxDepartures, true);
|
|
||||||
assertEquals(QueryDeparturesResult.Status.OK, result.status);
|
|
||||||
assertTrue(result.stationDepartures.size() > 1);
|
|
||||||
int nbDepartures = 0;
|
|
||||||
int nbLines = 0;
|
|
||||||
for (StationDepartures stationDepartures : result.stationDepartures)
|
|
||||||
{
|
|
||||||
nbDepartures += stationDepartures.departures.size();
|
|
||||||
final List<LineDestination> lines = stationDepartures.lines;
|
|
||||||
assertNotNull(lines);
|
|
||||||
nbLines += lines.size();
|
|
||||||
}
|
|
||||||
assertTrue(nbDepartures <= maxDepartures);
|
|
||||||
assertTrue(nbLines >= 2);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryDeparturesInvalidStation() throws Exception
|
public void queryDeparturesInvalidStation() throws Exception
|
||||||
{
|
{
|
||||||
final QueryDeparturesResult result = queryDepartures("stop_point:RTP:SP:999999", false);
|
queryDeparturesInvalidStation("stop_point:RTP:SP:999999");
|
||||||
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void suggestLocations() throws Exception
|
public void suggestLocations() throws Exception
|
||||||
{
|
{
|
||||||
final SuggestLocationsResult result = suggestLocations("bellevi");
|
suggestLocationsFromName("bellevi");
|
||||||
assertTrue(result.getLocations().size() > 0);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void suggestLocationsFromAddress() throws Exception
|
public void suggestLocationsFromAddress() throws Exception
|
||||||
{
|
{
|
||||||
final SuggestLocationsResult result = suggestLocations("13 rue man");
|
suggestLocationsFromAddress("13 rue man");
|
||||||
assertTrue(result.getLocations().size() > 0);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void suggestLocationsNoLocation() throws Exception
|
public void suggestLocationsNoLocation() throws Exception
|
||||||
{
|
{
|
||||||
final SuggestLocationsResult result = suggestLocations("bellevilleadasdjkaskd");
|
suggestLocationsNoLocation("bellevilleadasdjkaskd");
|
||||||
assertEquals(result.getLocations().size(), 0);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripAddresses() throws Exception
|
public void queryTripAddresses() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, 48877095, 2378431), null, new Location(LocationType.ADDRESS,
|
queryTrip("5 rue Manin Paris", "10 rue Elanger Paris");
|
||||||
48847168, 2261272), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripAddressStation() throws Exception
|
public void queryTripAddressStation() throws Exception
|
||||||
{
|
{
|
||||||
final SuggestLocationsResult fromResult = suggestLocations("155 bd hopital paris");
|
queryTrip("155 bd hopital paris", "Gare St-Lazare");
|
||||||
assertTrue(fromResult.getLocations().size() > 0);
|
|
||||||
final SuggestLocationsResult toResult = suggestLocations("Gare St-Lazare");
|
|
||||||
assertTrue(toResult.getLocations().size() > 0);
|
|
||||||
|
|
||||||
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
|
||||||
Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripStations() throws Exception
|
public void queryTripStations() throws Exception
|
||||||
{
|
{
|
||||||
final SuggestLocationsResult fromResult = suggestLocations("Campo Formio");
|
queryTrip("Campo Formio", "Gare St-Lazare");
|
||||||
assertTrue(fromResult.getLocations().size() > 0);
|
|
||||||
final SuggestLocationsResult toResult = suggestLocations("Gare St-Lazare");
|
|
||||||
assertTrue(toResult.getLocations().size() > 0);
|
|
||||||
|
|
||||||
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
|
||||||
Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripStations2() throws Exception
|
public void queryTripStations2() throws Exception
|
||||||
{
|
{
|
||||||
final SuggestLocationsResult fromResult = suggestLocations("Tour Eiffel");
|
queryTrip("Tour Eiffel", "Orsay Ville");
|
||||||
assertTrue(fromResult.getLocations().size() > 0);
|
|
||||||
final SuggestLocationsResult toResult = suggestLocations("Orsay Ville");
|
|
||||||
assertTrue(toResult.getLocations().size() > 0);
|
|
||||||
|
|
||||||
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
|
||||||
Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripStations3() throws Exception
|
public void queryTripStations3() throws Exception
|
||||||
{
|
{
|
||||||
final SuggestLocationsResult fromResult = suggestLocations("Tour Eiffel");
|
queryTrip("Tour Eiffel", "Campo Formio");
|
||||||
assertTrue(fromResult.getLocations().size() > 0);
|
|
||||||
final SuggestLocationsResult toResult = suggestLocations("Campo Formio");
|
|
||||||
assertTrue(toResult.getLocations().size() > 0);
|
|
||||||
|
|
||||||
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, toResult.getLocations().get(0), new Date(), true,
|
|
||||||
Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripStationsRapidTransit() throws Exception
|
public void queryTripStationsRapidTransit() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "stop_area:RTP:SA:1866"), null, new Location(
|
queryTrip("Luxembourg Paris", "Antony Antony");
|
||||||
LocationType.STATION, "stop_area:RTP:SA:2045"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripNoSolution() throws Exception
|
public void queryTripNoSolution() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "stop_point:RTP:SP:3926410"), null, new Location(
|
queryTripNoSolution("secretan buttes chaumont paris", "Antony Antony");
|
||||||
LocationType.STATION, "stop_point:RTP:SP:3926410"), new Date(), true, EnumSet.noneOf(Product.class), WalkSpeed.NORMAL,
|
|
||||||
Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.NO_TRIPS, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripUnknownFrom() throws Exception
|
public void queryTripUnknownFrom() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "stop_area:RTP:SA:999999"), null, new Location(
|
queryTripUnknownFrom("secretan buttes chaumont paris");
|
||||||
LocationType.STATION, "stop_area:RTP:SA:1666"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripUnknownTo() throws Exception
|
public void queryTripUnknownTo() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "stop_point:RTP:SP:3926410"), null, new Location(
|
queryTripUnknownTo("secretan buttes chaumont paris");
|
||||||
LocationType.STATION, "stop_area:RTP:SA:999999"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.UNKNOWN_TO, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripSlowWalk() throws Exception
|
public void queryTripSlowWalk() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, 48877095, 2378431), null, new Location(LocationType.ADDRESS,
|
queryTripSlowWalk("5 rue manin paris", "10 rue marcel dassault velizy");
|
||||||
48847168, 2261272), new Date(), true, Product.ALL, WalkSpeed.SLOW, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryTripFastWalk() throws Exception
|
public void queryTripFastWalk() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, 48877095, 2378431), null, new Location(LocationType.ADDRESS,
|
queryTripFastWalk("5 rue manin paris", "10 rue marcel dassault velizy");
|
||||||
48847168, 2261272), new Date(), true, Product.ALL, WalkSpeed.FAST, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryMoreTrips() throws Exception
|
public void queryMoreTrips() throws Exception
|
||||||
{
|
{
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, 48877095, 2378431), null, new Location(LocationType.ADDRESS,
|
queryMoreTrips("5 rue manin paris", "10 rue marcel dassault velizy");
|
||||||
48847168, 2261272), Calendar.getInstance().getTime(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
final QueryTripsContext context = result.context;
|
|
||||||
|
|
||||||
final QueryTripsResult nextResult = queryMoreTrips(context, true);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, nextResult.status);
|
|
||||||
print(nextResult);
|
|
||||||
|
|
||||||
final QueryTripsResult prevResult = queryMoreTrips(context, false);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, prevResult.status);
|
|
||||||
print(prevResult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -336,20 +190,4 @@ public class ParisProviderLiveTest extends AbstractProviderLiveTest
|
||||||
final Point[] polygon = provider.getArea();
|
final Point[] polygon = provider.getArea();
|
||||||
assertTrue(polygon.length > 0);
|
assertTrue(polygon.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void directionsSession() throws Exception
|
|
||||||
{
|
|
||||||
final SuggestLocationsResult suggestedDepartures = suggestLocations("13 rue man");
|
|
||||||
assertTrue(suggestedDepartures.getLocations().size() > 0);
|
|
||||||
final Location departure = suggestedDepartures.getLocations().get(0);
|
|
||||||
|
|
||||||
final SuggestLocationsResult suggestedArrivals = suggestLocations("10 marcel dassault veli");
|
|
||||||
assertTrue(suggestedArrivals.getLocations().size() > 0);
|
|
||||||
final Location arrival = suggestedDepartures.getLocations().get(0);
|
|
||||||
|
|
||||||
final QueryTripsResult result = queryTrips(departure, null, arrival, new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
|
||||||
print(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue