Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
d571675a31 | |||
f0205d1cc7 | |||
9ff4555ce8 | |||
bd94a98a30 | |||
1698622fc9 | |||
b9656b386a |
52
CHANGELOG.md
52
CHANGELOG.md
@ -1,20 +1,42 @@
|
||||
## 1.1.3 [2018-11-13]
|
||||
* [security] Updates Jackson dependency 2.9.4 to 2.9.7 (CVE-2018-7489)
|
||||
* [improvement] Client and model classes implement `Serializable`
|
||||
* [dependeny] Dependency updates
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 1.1.2 [2018-03-24]
|
||||
* [improvement] Added automatic module name for JPMS compatibility
|
||||
## 1.1.4 - 2018-11-19
|
||||
### Fixed
|
||||
* Fixed issue with direction ID as `String` instead if `Integer` (#2)
|
||||
* Fixed issue with vehicle ID being `null` (#3)
|
||||
* Fixed issue with spaces in search parametes (#4)
|
||||
|
||||
## 1.1.1 [2018-02-20]
|
||||
* [improvement] On connection or parsing errors, the `IOException` is no longer ignored, but encapsulated in `RuntimeException` (no StackTraces printed)
|
||||
* [internal] Code cleanup and minor improvements
|
||||
* [dependeny] Minor dependency updates
|
||||
|
||||
## 1.1.0 [2017-01-07]
|
||||
* [feature] Filter stops by coordinates and radius
|
||||
* [feature] Filter trips by destination and and towards fields
|
||||
* [test] Test coverage 100% (line); tested against ASEAG and TFL APIs
|
||||
## 1.1.3 - 2018-11-13
|
||||
### Security
|
||||
* Updates Jackson dependency 2.9.4 to 2.9.7 (CVE-2018-7489)
|
||||
|
||||
## 1.0.0 [2017-01-02]
|
||||
### Changed
|
||||
* Client and model classes implement `Serializable`
|
||||
* Dependency updates
|
||||
|
||||
|
||||
## 1.1.2 - 2018-03-24
|
||||
### Changed
|
||||
* Added automatic module name for JPMS compatibility
|
||||
|
||||
|
||||
## 1.1.1 - 2018-02-20
|
||||
### Changed
|
||||
* On connection or parsing errors, the `IOException` is no longer ignored, but encapsulated in `RuntimeException` (no StackTraces printed)
|
||||
* Code cleanup and minor improvements
|
||||
* Minor dependency updates
|
||||
|
||||
|
||||
## 1.1.0 - 2017-01-07
|
||||
### Added
|
||||
* Filter stops by coordinates and radius
|
||||
* Filter trips by destination and and towards fields
|
||||
|
||||
### Misc
|
||||
* Test coverage 100% (line); tested against ASEAG and TFL APIs
|
||||
|
||||
|
||||
## 1.0.0 - 2017-01-02
|
||||
* Initial release
|
||||
|
118
CONTRIBUTING.md
Normal file
118
CONTRIBUTING.md
Normal file
@ -0,0 +1,118 @@
|
||||
# How to contribute
|
||||
|
||||
As for all great Open Source projects, contributions in form of bug reports and code are welcome and important to keep the project alive.
|
||||
|
||||
In general, this project follows the [GitHub Flow](https://guides.github.com/introduction/flow/).
|
||||
Fork the project, commit your changes to your branch, open a pull request and it will probably be merged.
|
||||
However, to ensure maintainability and quality of the code, there are some guidelines you might be more or less familiar with.
|
||||
For that purpose, this document describes the important points.
|
||||
|
||||
|
||||
## Opening an Issue
|
||||
|
||||
If you experience any issues with the plugin or the code, don't hesitate to file an issue.
|
||||
|
||||
### Bug Reports
|
||||
|
||||
Think you found a bug?
|
||||
Please clearly state what happens and describe your environment to help tracking down the issue.
|
||||
|
||||
* Which version of the project are you running?
|
||||
* Which version of Java?
|
||||
* Which API do you try to query?
|
||||
|
||||
### Feature Requests
|
||||
|
||||
Missing a feature or like to have certain functionality enhanced?
|
||||
No problem, please open an issue and describe what and why you think this change is required.
|
||||
|
||||
|
||||
## Pull Requests
|
||||
|
||||
If you want to contribute your code to solve an issue or implement a desired feature yourself, you might open a pull request.
|
||||
If the changes introduce new functionality or affect major parts of existing code, please consider opening an issue for discussion first.
|
||||
|
||||
For adding new functionality a new test case the corresponding JUnit test would be nice (no hard criterion though).
|
||||
|
||||
### Branches
|
||||
|
||||
The `master` branch represents the current state of development.
|
||||
Please ensure your initial code is up to date with it at the time you start development.
|
||||
The `master` should also be target for most pull requests.
|
||||
|
||||
In addition, this project features a `develop` branch, which holds bleeding edge developments, not necessarily considered stable or even compatible.
|
||||
Do not expect this code to run smoothly, but you might have a look into the history to see if some work on an issue has already been started there.
|
||||
|
||||
For fixes and features, there might be additional branches, likely prefixed by `feature/` `fix/` followed by an issue number (if applicable) and/or a title.
|
||||
Feel free to adapt these naming scheme to your forks.
|
||||
|
||||
### Merge Requirements
|
||||
|
||||
To be merged into the master branch, your code has to pass the automated continuous integration tests, to ensure compatibility.
|
||||
In Addition your code has to be approved by a project member.
|
||||
|
||||
#### What if my code fails the tests?
|
||||
|
||||
Don't worry, you can submit your PR anyway.
|
||||
The reviewing process might help you to solve remaining issues.
|
||||
|
||||
### Commit messages
|
||||
|
||||
Please use speaking titles and messages for your commits, to ensure a transparent history.
|
||||
If your patch fixes an issue, reference the ID in the first line.
|
||||
If you feel like you have to _briefly_ explain your changes, do it (for long explanations and discussion, consider opening an issue or describe in the PR).
|
||||
|
||||
**Example commit:**
|
||||
```text
|
||||
Fix nasty bug from #1337
|
||||
|
||||
This example commit fixes the issue that some people write non-speaking commit messages like 'done magic'.
|
||||
A short description is helpful sometimes.
|
||||
```
|
||||
|
||||
You might sign your work, although that's no must.
|
||||
|
||||
|
||||
### When will it be merged?
|
||||
|
||||
Short answer: When it makes sense.
|
||||
|
||||
Bugfixes should be merged in time - assuming they pass the above criteria.
|
||||
New features might be assigned to a certain milestone and as a result of this be scheduled according to the planned release cycle.
|
||||
|
||||
|
||||
## Versioning
|
||||
|
||||
This projects tries to adapt the [Semantic Versioning](https://semver.org).
|
||||
In short, bug fixes without do not affect any compatibility will raise the third number only, new features will be reflected in the second number and any change breaking compatibility with the public API require raising the first number.
|
||||
|
||||
If you have to make a decision for which version to go please keep this in mind.
|
||||
However for most non-member commits this is mostly informative, as the decision will be made by the project team later.
|
||||
|
||||
|
||||
## Build Environment
|
||||
|
||||
All you need to start off - besides your favorite IDE of course - is Java and Maven.
|
||||
The project requires Java 8 or higher, both OpenJDK and Oracle JDK are supported.
|
||||
All build steps are executed by calling e.g. `mvn clean package` in the project's root directory,
|
||||
|
||||
|
||||
## Unit Tests
|
||||
|
||||
The Java code is tested by a set of JUnit tests.
|
||||
All test files are located in the `src/test` directory.
|
||||
Files ending with `Test.java` will be automatically included into the test suite.
|
||||
|
||||
|
||||
## Continuous Integration
|
||||
|
||||
Automated tests are run using [Travis CI](https://travis-ci.org/stklcode/juraclient) for every commit including pull requests.
|
||||
|
||||
There is also a code quality analysis pushing results to [SonarCloud](https://sonarcloud.io/dashboard?id=de.stklcode.pubtrans%3Ajuraclient).
|
||||
Keep in mind that the ruleset is not yet perfect, so not every minor issue has to be fixed immediately.
|
||||
|
||||
|
||||
## Still Open Questions?
|
||||
|
||||
If anything is still left unanswered and you're unsure if you got it right, don't hesitate to contact a team member.
|
||||
In any case you might submit your request/issue anyway, we won't refuse good code only for formal reasons.
|
@ -55,7 +55,7 @@ List<Trip> trips = ura.forStopByName("Piccadilly Circus")
|
||||
<dependency>
|
||||
<groupId>de.stklcode.pubtrans</groupId>
|
||||
<artifactId>juraclient</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
6
pom.xml
6
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.stklcode.pubtrans</groupId>
|
||||
<artifactId>juraclient</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -72,13 +72,13 @@
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<version>1.9.3</version>
|
||||
<version>1.9.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy-agent</artifactId>
|
||||
<version>1.9.3</version>
|
||||
<version>1.9.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -22,9 +22,12 @@ import de.stklcode.pubtrans.ura.model.Trip;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
/**
|
||||
* Client for URA based public transport API.
|
||||
* <p>
|
||||
@ -283,28 +286,28 @@ public class UraClient implements Serializable {
|
||||
String urlStr = baseURL + instantURL + "?ReturnList=" + String.join(",", returnList);
|
||||
|
||||
if (query.stopIDs != null && query.stopIDs.length > 0) {
|
||||
urlStr += "&" + PAR_STOP_ID + "=" + String.join(",", query.stopIDs);
|
||||
urlStr += "&" + PAR_STOP_ID + "=" + URLEncoder.encode(String.join(",", query.stopIDs), UTF_8.name());
|
||||
}
|
||||
if (query.stopNames != null && query.stopNames.length > 0) {
|
||||
urlStr += "&" + PAR_STOP_NAME + "=" + String.join(",", query.stopNames);
|
||||
urlStr += "&" + PAR_STOP_NAME + "=" + URLEncoder.encode(String.join(",", query.stopNames), UTF_8.name());
|
||||
}
|
||||
if (query.lineIDs != null && query.lineIDs.length > 0) {
|
||||
urlStr += "&" + PAR_LINE_ID + "=" + String.join(",", query.lineIDs);
|
||||
urlStr += "&" + PAR_LINE_ID + "=" + URLEncoder.encode(String.join(",", query.lineIDs), UTF_8.name());
|
||||
}
|
||||
if (query.lineNames != null && query.lineNames.length > 0) {
|
||||
urlStr += "&" + PAR_LINE_NAME + "=" + String.join(",", query.lineNames);
|
||||
urlStr += "&" + PAR_LINE_NAME + "=" + URLEncoder.encode(String.join(",", query.lineNames), UTF_8.name());
|
||||
}
|
||||
if (query.direction != null) {
|
||||
urlStr += "&" + PAR_DIR_ID + "=" + query.direction;
|
||||
}
|
||||
if (query.destinationNames != null) {
|
||||
urlStr += "&" + PAR_DEST_NAME + "=" + String.join(",", query.destinationNames);
|
||||
urlStr += "&" + PAR_DEST_NAME + "=" + URLEncoder.encode(String.join(",", query.destinationNames), UTF_8.name());
|
||||
}
|
||||
if (query.towards != null) {
|
||||
urlStr += "&" + PAR_TOWARDS + "=" + String.join(",", query.towards);
|
||||
urlStr += "&" + PAR_TOWARDS + "=" + URLEncoder.encode(String.join(",", query.towards), UTF_8.name());
|
||||
}
|
||||
if (query.circle != null) {
|
||||
urlStr += "&" + PAR_CIRCLE + "=" + String.join(",", query.circle);
|
||||
urlStr += "&" + PAR_CIRCLE + "=" + URLEncoder.encode(query.circle, UTF_8.name());
|
||||
}
|
||||
|
||||
return request(urlStr);
|
||||
|
@ -176,13 +176,15 @@ public final class Trip implements Model {
|
||||
throw Model.typeErrorString(LINE_NAME, raw.get(LINE_NAME).getClass());
|
||||
}
|
||||
|
||||
if (raw.get(DIRECTION_ID) instanceof Integer) {
|
||||
directionID = (Integer) raw.get(DIRECTION_ID);
|
||||
if (raw.get(DIRECTION_ID) instanceof String // Also accept Strings (#2)
|
||||
|| raw.get(DIRECTION_ID) instanceof Integer
|
||||
|| raw.get(DIRECTION_ID) instanceof Long) {
|
||||
directionID = Integer.valueOf(raw.get(DIRECTION_ID).toString());
|
||||
if (directionID < 0 || directionID > 2) {
|
||||
throw new IOException("Direction out of range. Expected 1 or 2, found " + directionID);
|
||||
}
|
||||
} else {
|
||||
throw Model.typeError(DIRECTION_ID, raw.get(DIRECTION_ID).getClass(), "Integer");
|
||||
throw Model.typeError(DIRECTION_ID, raw.get(DIRECTION_ID).getClass(), "String/Long/Integer");
|
||||
}
|
||||
|
||||
if (raw.get(DESTINATION_NAME) instanceof String) {
|
||||
@ -202,6 +204,8 @@ public final class Trip implements Model {
|
||||
|| raw.get(VEHICLE_ID) instanceof Integer
|
||||
|| raw.get(VEHICLE_ID) instanceof Long) {
|
||||
vehicleID = raw.get(VEHICLE_ID).toString();
|
||||
} else if (raw.get(VEHICLE_ID) == null) { // Only fail of field is not NULL (#3).
|
||||
vehicleID = null;
|
||||
} else {
|
||||
throw Model.typeError(VEHICLE_ID, raw.get(VEHICLE_ID).getClass(), "String/Integer/Long");
|
||||
}
|
||||
@ -285,7 +289,7 @@ public final class Trip implements Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The vehicle ID.
|
||||
* @return The vehicle ID or {@code null} if not present.
|
||||
*/
|
||||
public String getVehicleID() {
|
||||
return vehicleID;
|
||||
|
@ -130,6 +130,26 @@ public class TripTest {
|
||||
fail("Creation of Trip from valid list failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
raw.remove(10);
|
||||
raw.add(10, 0L); // Long values are OK.
|
||||
try {
|
||||
Trip trip = new Trip(raw);
|
||||
assertThat(trip, is(notNullValue()));
|
||||
assertThat(trip.getDirectionID(), is(0));
|
||||
} catch (IOException e) {
|
||||
fail("Creation of Trip from valid list failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
raw.remove(10);
|
||||
raw.add(10, "0"); // String values are OK.
|
||||
try {
|
||||
Trip trip = new Trip(raw);
|
||||
assertThat(trip, is(notNullValue()));
|
||||
assertThat(trip.getDirectionID(), is(0));
|
||||
} catch (IOException e) {
|
||||
fail("Creation of Trip from valid list failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
/* Test exceptions on invalid data */
|
||||
List<Object> invalid = new ArrayList<>(raw);
|
||||
invalid.remove(7);
|
||||
@ -163,7 +183,7 @@ public class TripTest {
|
||||
|
||||
invalid = new ArrayList<>(raw);
|
||||
invalid.remove(10);
|
||||
invalid.add(10, "1");
|
||||
invalid.add(10, "7"); // Strings are generally OK, but 7 is out of range (#2).
|
||||
try {
|
||||
new Trip(invalid);
|
||||
fail("Creation of Trip with invalid directionID field successfull");
|
||||
|
@ -1,11 +1,11 @@
|
||||
[4,"2.0",1483362959788]
|
||||
[1,"Uniklinik","100600","H.2",0,50.7756388,6.04425,11,"33","33",1,"Aachen Fuchserde","Aachen Fuchserde","318",92000043013001,1483362935000]
|
||||
[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,1,"5","5",1,"Driescher Hof-Brand","Driescher Hof-Brand","312",92000282009001,1483362936000]
|
||||
[1,"Uniklinik","100600","H.4",0,50.7756388,6.04425,33,"45","45",1,"Uniklinik","Uniklinik","317",92000285009001,1483363294000]
|
||||
[1,"Uniklinik","100600","H.3",0,50.7756388,6.04425,28,"10","3.B",1,"Uniklinik-Ponttor-Hbf.","Uniklinik-Ponttor-Hbf.","347",92000053015001,1483363039000]
|
||||
[1,"Uniklinik","100600","H.3",0,50.7756388,6.04425,29,"33","33",1,"Uniklinik","Uniklinik","529",92000209014001,1483363288000]
|
||||
[1,"Uniklinik","100600","H.2",0,50.7756388,6.04425,1,"73","73",1,"Aachen Bf.Rothe Erde","Aachen Bf.Rothe Erde","315",92000291016001,1483363080000]
|
||||
[1,"Uniklinik","100600","H.3",0,50.7756388,6.04425,29,"10","3.B",1,"Uniklinik-Ponttor-Hbf.","Uniklinik-Ponttor-Hbf.","347",92000053015001,1483363099000]
|
||||
[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,28,"3","3.A",1,"Uniklinik-Schanz-Hbf.","Uniklinik-Schanz-Hbf.","325",92000288012001,1483363080000]
|
||||
[1,"Uniklinik","100600","H.2",0,50.7756388,6.04425,6,"70","70",1,"Aachen Adenauerallee","Aachen Adenauerallee","588",92000225009001,1483363346000]
|
||||
[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,1,"3","3.A",1,"Schanz-Hbf.-Ponttor","Schanz-Hbf.-Ponttor","325",92000288013001,1483363380000]
|
||||
[1,"Uniklinik","100600","H.2",0,50.7756388,6.04425,11,"33","33","1","Aachen Fuchserde","Aachen Fuchserde","318",92000043013001,1483362935000]
|
||||
[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,1,"5","5","1","Driescher Hof-Brand","Driescher Hof-Brand","312",92000282009001,1483362936000]
|
||||
[1,"Uniklinik","100600","H.4",0,50.7756388,6.04425,33,"45","45","1","Uniklinik","Uniklinik","317",92000285009001,1483363294000]
|
||||
[1,"Uniklinik","100600","H.3",0,50.7756388,6.04425,28,"10","3.B","1","Uniklinik-Ponttor-Hbf.","Uniklinik-Ponttor-Hbf.","347",92000053015001,1483363039000]
|
||||
[1,"Uniklinik","100600","H.3",0,50.7756388,6.04425,29,"33","33","1","Uniklinik","Uniklinik","529",92000209014001,1483363288000]
|
||||
[1,"Uniklinik","100600","H.2",0,50.7756388,6.04425,1,"73","73","1","Aachen Bf.Rothe Erde","Aachen Bf.Rothe Erde","315",92000291016001,1483363080000]
|
||||
[1,"Uniklinik","100600","H.3",0,50.7756388,6.04425,29,"10","3.B","1","Uniklinik-Ponttor-Hbf.","Uniklinik-Ponttor-Hbf.","347",92000053015001,1483363099000]
|
||||
[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,28,"3","3.A","1","Uniklinik-Schanz-Hbf.","Uniklinik-Schanz-Hbf.","325",92000288012001,1483363080000]
|
||||
[1,"Uniklinik","100600","H.2",0,50.7756388,6.04425,6,"70","70","1","Aachen Adenauerallee","Aachen Adenauerallee","588",92000225009001,1483363346000]
|
||||
[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,1,"3","3.A","1","Schanz-Hbf.-Ponttor","Schanz-Hbf.-Ponttor",null,92000288013001,1483363380000]
|
||||
|
Reference in New Issue
Block a user