allow getTrips with limit directly from Query instance
backported from commit 406fe076f1
This commit is contained in:
@@ -192,7 +192,7 @@ public class UraClient implements Serializable {
|
||||
|
||||
/**
|
||||
* Get list of trips.
|
||||
* If forStops() and/or forLines() has been called, those will be used as filter.
|
||||
* If {@link #forStops(String...)} and/or {@link #forLines(String...)} has been called, those will be used as filter.
|
||||
*
|
||||
* @return List of trips.
|
||||
*/
|
||||
@@ -202,7 +202,7 @@ public class UraClient implements Serializable {
|
||||
|
||||
/**
|
||||
* Get list of trips with limit.
|
||||
* If forStops() and/or forLines() has been called, those will be used as filter.
|
||||
* If {@link #forStops(String...)} and/or {@link #forLines(String...)} has been called, those will be used as filter.
|
||||
*
|
||||
* @param limit Maximum number of results.
|
||||
* @return List of trips.
|
||||
@@ -566,6 +566,17 @@ public class UraClient implements Serializable {
|
||||
return UraClient.this.getTrips(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get trips for set filters.
|
||||
*
|
||||
* @param limit Maximum number of results.
|
||||
* @return List of matching trips.
|
||||
* @since 1.3.3
|
||||
*/
|
||||
public List<Trip> getTrips(final Integer limit) {
|
||||
return UraClient.this.getTrips(this, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get trips for set filters.
|
||||
*
|
||||
|
@@ -189,6 +189,12 @@ class UraClientTest {
|
||||
assertThat(trips.get(8).getVisitID(), is(30));
|
||||
assertThat(trips.get(9).getStop().getId(), is("100002"));
|
||||
|
||||
// With limit.
|
||||
trips = new UraClient(httpMock.baseUrl()).getTrips(5);
|
||||
assertThat(trips, hasSize(5));
|
||||
trips = new UraClient(httpMock.baseUrl()).getTrips(11);
|
||||
assertThat(trips, hasSize(10));
|
||||
|
||||
// Repeat test for API V2.
|
||||
mockHttpToFile(2, "instant_V2_trips_all.txt");
|
||||
|
||||
@@ -239,6 +245,12 @@ class UraClientTest {
|
||||
assertThat(trips.get(2).getLineName(), is("25"));
|
||||
assertThat(trips.get(3).getStop().getIndicator(), is("H.15"));
|
||||
|
||||
// With limit.
|
||||
trips = new UraClient(httpMock.baseUrl())
|
||||
.forStops("100000")
|
||||
.getTrips(7);
|
||||
assertThat(trips, hasSize(7));
|
||||
|
||||
// Get trips for stop name "Uniklinik" and verify some values.
|
||||
mockHttpToFile(1, "instant_V1_trips_stop_name.txt");
|
||||
trips = new UraClient(httpMock.baseUrl())
|
||||
|
Reference in New Issue
Block a user