Compare commits

..

No commits in common. "1.x" and "v1.3.2" have entirely different histories.
1.x ... v1.3.2

7 changed files with 20 additions and 92 deletions

View File

@ -4,7 +4,7 @@ name: java8
steps:
- name: test
image: maven:3-eclipse-temurin-8
image: maven:3-openjdk-8
commands:
- mvn -B clean test
@ -15,7 +15,7 @@ name: java11
steps:
- name: test
image: maven:3-eclipse-temurin-11
image: maven:3-openjdk-11
commands:
- mvn -B clean test
@ -26,6 +26,6 @@ name: java17
steps:
- name: test
image: maven:3-eclipse-temurin-17
image: maven:3-openjdk-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
if: matrix.analysis && github.event_name == 'push'
run: >
mvn -B sonar:sonar
-Dsonar.host.url=https://sonarcloud.io

View File

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

15
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>de.stklcode.pubtrans</groupId>
<artifactId>juraclient</artifactId>
<version>1.3.3</version>
<version>1.3.2</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -49,13 +49,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.0</version>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
@ -67,7 +66,7 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.35.0</version>
<version>2.33.2</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -96,13 +95,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.2.2</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 {@link #forStops(String...)} and/or {@link #forLines(String...)} has been called, those will be used as filter.
* If forStops() and/or forLines() 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 {@link #forStops(String...)} and/or {@link #forLines(String...)} has been called, those will be used as filter.
* If forStops() and/or forLines() has been called, those will be used as filter.
*
* @param limit Maximum number of results.
* @return List of trips.
@ -346,18 +346,6 @@ 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.
*
@ -578,17 +566,6 @@ 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.
*
@ -623,16 +600,5 @@ 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,12 +189,6 @@ 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");
@ -245,12 +239,6 @@ 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())
@ -337,13 +325,12 @@ 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 = uraClient.getMessages();
List<Message> messages = new UraClient(httpMock.baseUrl())
.getMessages();
assertThat(messages, hasSize(2));
assertThat(messages.get(0).getStop().getId(), is("100707"));
assertThat(messages.get(0).getUuid(), is("016e1231d4e30014_100707"));
@ -353,35 +340,23 @@ 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 = uraClient.forStops("100707").getMessages();
List<Message> messages = new UraClient(httpMock.baseUrl(), "/interfaces/ura/instant_V2", "/interfaces/ura/stream")
.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));
}