allow getTrips with limit directly from Query instance
This commit is contained in:
parent
7cb5aefb5b
commit
406fe076f1
@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
|
|||||||
### Security
|
### Security
|
||||||
* Updated dependencies
|
* Updated dependencies
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* Querying trips with limit directly from `Query` instance (#18)
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
* Tested with JDK 19
|
* Tested with JDK 19
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public class UraClient implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of trips with limit.
|
* 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.
|
* @param limit Maximum number of results.
|
||||||
* @return List of trips.
|
* @return List of trips.
|
||||||
@ -342,7 +342,7 @@ public class UraClient implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* List available stopIDs.
|
* List available stopIDs.
|
||||||
* 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 query The query.
|
* @param query The query.
|
||||||
* @return The list.
|
* @return The list.
|
||||||
@ -642,6 +642,18 @@ public class UraClient implements Serializable {
|
|||||||
return UraClient.this.getTrips(this);
|
return UraClient.this.getTrips(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get trips for set filters with limit.
|
||||||
|
*
|
||||||
|
* @param limit Maximum number of results.
|
||||||
|
* @return List of matching trips.
|
||||||
|
* @throws UraClientException Error with API communication.
|
||||||
|
* @since 2.0.4
|
||||||
|
*/
|
||||||
|
public List<Trip> getTrips(final Integer limit) throws UraClientException {
|
||||||
|
return UraClient.this.getTrips(this, limit);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get trips for set filters.
|
* Get trips for set filters.
|
||||||
*
|
*
|
||||||
|
@ -183,6 +183,12 @@ public class UraClientTest {
|
|||||||
assertThat(trips.get(8).getVisitID(), is(30));
|
assertThat(trips.get(8).getVisitID(), is(30));
|
||||||
assertThat(trips.get(9).getStop().getId(), is("100002"));
|
assertThat(trips.get(9).getStop().getId(), is("100002"));
|
||||||
|
|
||||||
|
// With limit.
|
||||||
|
trips = new UraClient(wireMock.baseUrl()).getTrips(5);
|
||||||
|
assertThat(trips, hasSize(5));
|
||||||
|
trips = new UraClient(wireMock.baseUrl()).getTrips(11);
|
||||||
|
assertThat(trips, hasSize(10));
|
||||||
|
|
||||||
// Repeat test for API V2.
|
// Repeat test for API V2.
|
||||||
mockHttpToFile(2, "instant_V2_trips_all.txt");
|
mockHttpToFile(2, "instant_V2_trips_all.txt");
|
||||||
|
|
||||||
@ -242,6 +248,12 @@ public class UraClientTest {
|
|||||||
assertThat(trips.get(2).getLineName(), is("25"));
|
assertThat(trips.get(2).getLineName(), is("25"));
|
||||||
assertThat(trips.get(3).getStop().getIndicator(), is("H.15"));
|
assertThat(trips.get(3).getStop().getIndicator(), is("H.15"));
|
||||||
|
|
||||||
|
// With limit.
|
||||||
|
trips = new UraClient(wireMock.baseUrl())
|
||||||
|
.forStops("100000")
|
||||||
|
.getTrips(7);
|
||||||
|
assertThat(trips, hasSize(7));
|
||||||
|
|
||||||
// Get trips for stop name "Uniklinik" and verify some values.
|
// Get trips for stop name "Uniklinik" and verify some values.
|
||||||
mockHttpToFile(1, "instant_V1_trips_stop_name.txt");
|
mockHttpToFile(1, "instant_V1_trips_stop_name.txt");
|
||||||
trips = new UraClient(wireMock.baseUrl())
|
trips = new UraClient(wireMock.baseUrl())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user