Compare commits

...

7 Commits
v1.3.2 ... 1.x

Author SHA1 Message Date
251e60d66f
prepare release 1.3.3
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-21 15:46:15 +01:00
c5f13f6652
deps: bump jackson-databind from 2.13.3 to 2.14.0
All checks were successful
continuous-integration/drone/push Build is passing
Plus some minor test dependency updates.

Cherry-picked from 55271011b677b4450693d403463e86c75887e3bf
2022-11-21 15:42:24 +01:00
30b151a15d
ci: enable SonarQube analysis for pull requests
All checks were successful
continuous-integration/drone/push Build is passing
Cherry-picked from 7cb5aefb5badf2bff333928fe429498fe9c8a73e
2022-11-21 15:41:36 +01:00
27d5f1b861
add implementation details and classpath to JAR manifest
Cherry-picked from 0573ed1ade96be91a724a08ea19f85e63aca8105
2022-11-21 15:41:06 +01:00
5152c4e667
docs: correct forStops() calls in README
All checks were successful
continuous-integration/drone/push Build is passing
backported from 591476cc6011210c01624214d7f57e099a48ea66
2022-11-21 15:32:05 +01:00
4b69343d39
allow getMessages with limit directly from Query instance
backported from commit 7684b2e089cd99ede6d294d3f69aa38e39a82074
2022-11-21 15:32:04 +01:00
8748dd883b
allow getTrips with limit directly from Query instance
backported from commit 406fe076f1763f3757cfdd4bceb3568676679b03
2022-11-21 15:31:54 +01:00
7 changed files with 92 additions and 20 deletions

View File

@ -4,7 +4,7 @@ name: java8
steps:
- name: test
image: maven:3-openjdk-8
image: maven:3-eclipse-temurin-8
commands:
- mvn -B clean test
@ -15,7 +15,7 @@ name: java11
steps:
- name: test
image: maven:3-openjdk-11
image: maven:3-eclipse-temurin-11
commands:
- mvn -B clean test
@ -26,6 +26,6 @@ name: java17
steps:
- name: test
image: maven:3-openjdk-17
image: maven:3-eclipse-temurin-17
commands:
- mvn -B clean test

View File

@ -22,7 +22,7 @@ jobs:
- name: Test
run: mvn -B -P coverage clean verify
- name: Analysis
if: matrix.analysis && github.event_name == 'push'
if: matrix.analysis
run: >
mvn -B sonar:sonar
-Dsonar.host.url=https://sonarcloud.io

View File

@ -1,6 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.
## 1.3.3 - 2022-11-21
### Security
* Updated Jackson dependency to 2.14.0
### Fixed
* Querying trips and messages with limit directly from `Query` instance (#19)
## 1.3.2 - 2022-08-30
### Improvements

View File

@ -39,13 +39,13 @@ List<Stop> stops = ura.forPosition(51.51009, -0.1345734, 200)
```java
// Get next 10 trips for given stops and lines in a single direction (all filters optional)
List<Trip> trips = ura.forStop("100000")
List<Trip> trips = ura.forStops("100000")
.forLines("25", "35")
.forDirection(1)
.getTrips(10);
// Get trips from given stop towards your destination
List<Trip> trips = ura.forStopByName("Piccadilly Circus")
List<Trip> trips = ura.forStopsByName("Piccadilly Circus")
.towards("Marble Arch")
.getTrips();
```
@ -54,7 +54,7 @@ List<Trip> trips = ura.forStopByName("Piccadilly Circus")
```java
// Get next 10 trips for given stops and lines in a single direction (all filters optional)
List<Message> msgs = ura.forStop("100000")
List<Message> msgs = ura.forStops("100000")
.getMessages();
```
@ -63,7 +63,7 @@ List<Message> msgs = ura.forStop("100000")
<dependency>
<groupId>de.stklcode.pubtrans</groupId>
<artifactId>juraclient</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
```

15
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>de.stklcode.pubtrans</groupId>
<artifactId>juraclient</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -49,12 +49,13 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
@ -66,7 +67,7 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.33.2</version>
<version>2.35.0</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -95,9 +96,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Automatic-Module-Name>de.stklcode.pubtrans.juraclient</Automatic-Module-Name>
</manifestEntries>

View File

@ -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.
@ -346,6 +346,18 @@ public class UraClient implements Serializable {
return getMessages(query, null);
}
/**
* Get list of messages with limit.
*
* @param limit Maximum number of results.
* @return List of trips.
* @since 1.3.3
*/
public List<Message> getMessages(final Integer limit) {
return getMessages(new Query(), limit);
}
/**
* Get list of messages for given stopIDs with result limit.
*
@ -566,6 +578,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.
*
@ -600,5 +623,16 @@ public class UraClient implements Serializable {
public List<Message> getMessages() {
return UraClient.this.getMessages(this);
}
/**
* Get trips for set filters with limit.
*
* @param limit Maximum number of results.
* @return List of matching messages.
* @since 1.3.3
*/
public List<Message> getMessages(final Integer limit) {
return UraClient.this.getMessages(this, limit);
}
}
}

View File

@ -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())
@ -325,12 +337,13 @@ class UraClientTest {
@Test
void getMessages() {
UraClient uraClient = new UraClient(httpMock.baseUrl());
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_messages.txt");
// Get messages without filter and verify some values.
List<Message> messages = new UraClient(httpMock.baseUrl())
.getMessages();
List<Message> messages = uraClient.getMessages();
assertThat(messages, hasSize(2));
assertThat(messages.get(0).getStop().getId(), is("100707"));
assertThat(messages.get(0).getUuid(), is("016e1231d4e30014_100707"));
@ -340,23 +353,35 @@ class UraClientTest {
assertThat(messages.get(1).getPriority(), is(0));
assertThat(messages.get(0).getText(), is("Sehr geehrte Fahrgäste, wegen Strassenbauarbeiten kann diese Haltestelle nicht von den Bussen der Linien 17, 44 und N2 angefahren werden."));
assertThat(messages.get(1).getText(), is("Sehr geehrte Fahrgäste, diese Haltestelle wird vorübergehend von den Linien 47, 147 und N3 nicht angefahren."));
// With limit.
messages = uraClient.getMessages(1);
assertThat(messages, hasSize(1));
messages = uraClient.getMessages(3);
assertThat(messages, hasSize(2));
}
@Test
void getMessagesForStop() {
UraClient uraClient = new UraClient(httpMock.baseUrl(), "/interfaces/ura/instant_V2", "/interfaces/ura/stream");
// Mock the HTTP call.
mockHttpToFile(2, "instant_V2_messages_stop.txt");
// Get trips for stop ID 100707 (Berensberger Str.) and verify some values.
List<Message> messages = new UraClient(httpMock.baseUrl(), "/interfaces/ura/instant_V2", "/interfaces/ura/stream")
.forStops("100707")
.getMessages();
List<Message> messages = uraClient.forStops("100707").getMessages();
assertThat(messages, hasSize(1));
assertThat(messages.stream().filter(t -> !t.getStop().getId().equals("100707")).findAny(), is(Optional.empty()));
assertThat(messages.get(0).getUuid(), is("016e1231d4e30014_100707"));
assertThat(messages.get(0).getType(), is(0));
assertThat(messages.get(0).getPriority(), is(3));
assertThat(messages.get(0).getText(), is("Sehr geehrte Fahrgäste, wegen Strassenbauarbeiten kann diese Haltestelle nicht von den Bussen der Linien 17, 44 und N2 angefahren werden."));
// With limit.
messages = uraClient.forStops("100707").getMessages(0);
assertThat(messages, hasSize(0));
messages = uraClient.forStops("100707").getMessages(2);
assertThat(messages, hasSize(1));
}