allow getTrips with limit directly from Query instance
backported from commit 406fe076f1763f3757cfdd4bceb3568676679b03
This commit is contained in:
parent
0ee348ee0d
commit
8748dd883b
@ -1,6 +1,12 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## unreleased
|
||||
|
||||
### Fixed
|
||||
* Querying trips with limit directly from `Query` instance (#19)
|
||||
|
||||
|
||||
## 1.3.2 - 2022-08-30
|
||||
|
||||
### Improvements
|
||||
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>de.stklcode.pubtrans</groupId>
|
||||
<artifactId>juraclient</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>1.3.3-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user