This commit is contained in:
parent
a91005967c
commit
0ee348ee0d
@ -6,7 +6,7 @@ steps:
|
|||||||
- name: test
|
- name: test
|
||||||
image: maven:3-openjdk-8
|
image: maven:3-openjdk-8
|
||||||
commands:
|
commands:
|
||||||
- mvn clean test
|
- mvn -B clean test
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@ -17,7 +17,7 @@ steps:
|
|||||||
- name: test
|
- name: test
|
||||||
image: maven:3-openjdk-11
|
image: maven:3-openjdk-11
|
||||||
commands:
|
commands:
|
||||||
- mvn clean test
|
- mvn -B clean test
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@ -28,4 +28,4 @@ steps:
|
|||||||
- name: test
|
- name: test
|
||||||
image: maven:3-openjdk-17
|
image: maven:3-openjdk-17
|
||||||
commands:
|
commands:
|
||||||
- mvn clean test
|
- mvn -B clean test
|
||||||
|
@ -236,7 +236,7 @@ public class UraClient implements Serializable {
|
|||||||
String version = null;
|
String version = null;
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
while (line != null && (limit == null || trips.size() < limit)) {
|
while (line != null && (limit == null || trips.size() < limit)) {
|
||||||
List l = mapper.readValue(line, List.class);
|
List<?> l = mapper.readValue(line, List.class);
|
||||||
/* Check if result exists and has correct response type */
|
/* Check if result exists and has correct response type */
|
||||||
if (l != null && !l.isEmpty()) {
|
if (l != null && !l.isEmpty()) {
|
||||||
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
|
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
|
||||||
@ -311,7 +311,7 @@ public class UraClient implements Serializable {
|
|||||||
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
|
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
List l = mapper.readValue(line, List.class);
|
List<?> l = mapper.readValue(line, List.class);
|
||||||
/* Check if result exists and has correct response type */
|
/* Check if result exists and has correct response type */
|
||||||
if (l != null && !l.isEmpty() && l.get(0).equals(RES_TYPE_STOP)) {
|
if (l != null && !l.isEmpty() && l.get(0).equals(RES_TYPE_STOP)) {
|
||||||
stops.add(new Stop(l));
|
stops.add(new Stop(l));
|
||||||
@ -361,7 +361,7 @@ public class UraClient implements Serializable {
|
|||||||
String version = null;
|
String version = null;
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
while (line != null && (limit == null || messages.size() < limit)) {
|
while (line != null && (limit == null || messages.size() < limit)) {
|
||||||
List l = mapper.readValue(line, List.class);
|
List<?> l = mapper.readValue(line, List.class);
|
||||||
/* Check if result exists and has correct response type */
|
/* Check if result exists and has correct response type */
|
||||||
if (l != null && !l.isEmpty()) {
|
if (l != null && !l.isEmpty()) {
|
||||||
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
|
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
|
||||||
|
@ -87,7 +87,7 @@ public class Message implements Model {
|
|||||||
* @param raw List of attributes from JSON line
|
* @param raw List of attributes from JSON line
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Message(final List raw) throws IOException {
|
public Message(final List<?> raw) throws IOException {
|
||||||
this(raw, null);
|
this(raw, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ public class Message implements Model {
|
|||||||
* @param version API version
|
* @param version API version
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Message(final List raw, final String version) throws IOException {
|
public Message(final List<?> raw, final String version) throws IOException {
|
||||||
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
||||||
throw new IOException("Invalid number of fields");
|
throw new IOException("Invalid number of fields");
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ interface Model extends Serializable {
|
|||||||
* @param actual Actual class.
|
* @param actual Actual class.
|
||||||
* @return The Exception.
|
* @return The Exception.
|
||||||
*/
|
*/
|
||||||
static IOException typeErrorString(int field, Class actual) {
|
static IOException typeErrorString(int field, Class<?> actual) {
|
||||||
return typeError(field, actual, "String");
|
return typeError(field, actual, "String");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ interface Model extends Serializable {
|
|||||||
* @param expected Expected type.
|
* @param expected Expected type.
|
||||||
* @return The Exception.
|
* @return The Exception.
|
||||||
*/
|
*/
|
||||||
static IOException typeError(int field, Class actual, String expected) {
|
static IOException typeError(int field, Class<?> actual, String expected) {
|
||||||
return new IOException(String.format("Field %d not of expected type %s, found %s",
|
return new IOException(String.format("Field %d not of expected type %s, found %s",
|
||||||
field, expected, actual.getSimpleName()));
|
field, expected, actual.getSimpleName()));
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public final class Stop implements Model {
|
|||||||
* @param raw List of attributes from JSON line
|
* @param raw List of attributes from JSON line
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Stop(final List raw) throws IOException {
|
public Stop(final List<?> raw) throws IOException {
|
||||||
if (raw == null || raw.size() < F_NUM_OF_FIELDS) {
|
if (raw == null || raw.size() < F_NUM_OF_FIELDS) {
|
||||||
throw new IOException("Invalid number of fields");
|
throw new IOException("Invalid number of fields");
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public final class Trip implements Model {
|
|||||||
* @param raw List of attributes from JSON line
|
* @param raw List of attributes from JSON line
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Trip(final List raw) throws IOException {
|
public Trip(final List<?> raw) throws IOException {
|
||||||
this(raw, null);
|
this(raw, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public final class Trip implements Model {
|
|||||||
* @param version API version
|
* @param version API version
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Trip(final List raw, final String version) throws IOException {
|
public Trip(final List<?> raw, final String version) throws IOException {
|
||||||
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
||||||
throw new IOException("Invalid number of fields");
|
throw new IOException("Invalid number of fields");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class AsyncUraTripReader implements AutoCloseable {
|
|||||||
String version = null;
|
String version = null;
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
while (line != null && !this.canceled) {
|
while (line != null && !this.canceled) {
|
||||||
List l = mapper.readValue(line, List.class);
|
List<?> l = mapper.readValue(line, List.class);
|
||||||
// Check if result exists and has correct response type.
|
// Check if result exists and has correct response type.
|
||||||
if (l != null && !l.isEmpty()) {
|
if (l != null && !l.isEmpty()) {
|
||||||
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
|
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
|
||||||
|
@ -45,11 +45,11 @@ import static org.hamcrest.core.Is.is;
|
|||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
*/
|
*/
|
||||||
public class UraClientTest {
|
class UraClientTest {
|
||||||
private static WireMockServer httpMock;
|
private static WireMockServer httpMock;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() {
|
static void setUp() {
|
||||||
// Initialize HTTP mock.
|
// Initialize HTTP mock.
|
||||||
httpMock = new WireMockServer(WireMockConfiguration.options().dynamicPort());
|
httpMock = new WireMockServer(WireMockConfiguration.options().dynamicPort());
|
||||||
httpMock.start();
|
httpMock.start();
|
||||||
@ -57,13 +57,13 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
public static void tearDown() {
|
static void tearDown() {
|
||||||
httpMock.stop();
|
httpMock.stop();
|
||||||
httpMock = null;
|
httpMock = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getStopsTest() {
|
void getStopsTest() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(2, "instant_V2_stops.txt");
|
mockHttpToFile(2, "instant_V2_stops.txt");
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getStopsForLineTest() {
|
void getStopsForLineTest() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(2, "instant_V2_stops_line.txt");
|
mockHttpToFile(2, "instant_V2_stops_line.txt");
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getStopsForPositionTest() {
|
void getStopsForPositionTest() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_stops_circle.txt");
|
mockHttpToFile(1, "instant_V1_stops_circle.txt");
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTripsForDestinationNamesTest() {
|
void getTripsForDestinationNamesTest() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_trips_destination.txt");
|
mockHttpToFile(1, "instant_V1_trips_destination.txt");
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTripsTowardsTest() {
|
void getTripsTowardsTest() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_trips_towards.txt");
|
mockHttpToFile(1, "instant_V1_trips_towards.txt");
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTripsTest() {
|
void getTripsTest() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_trips_all.txt");
|
mockHttpToFile(1, "instant_V1_trips_all.txt");
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTripsForStopTest() {
|
void getTripsForStopTest() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_trips_stop.txt");
|
mockHttpToFile(1, "instant_V1_trips_stop.txt");
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTripsForLine() {
|
void getTripsForLine() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_trips_line.txt");
|
mockHttpToFile(1, "instant_V1_trips_line.txt");
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTripsForStopAndLine() {
|
void getTripsForStopAndLine() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_trips_stop_line.txt");
|
mockHttpToFile(1, "instant_V1_trips_stop_line.txt");
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ public class UraClientTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMessages() {
|
void getMessages() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(1, "instant_V1_messages.txt");
|
mockHttpToFile(1, "instant_V1_messages.txt");
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ public class UraClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMessagesForStop() {
|
void getMessagesForStop() {
|
||||||
// Mock the HTTP call.
|
// Mock the HTTP call.
|
||||||
mockHttpToFile(2, "instant_V2_messages_stop.txt");
|
mockHttpToFile(2, "instant_V2_messages_stop.txt");
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class AsyncUraTripReaderTest {
|
|||||||
* @throws IOException Error reading or writing mocked data.
|
* @throws IOException Error reading or writing mocked data.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void streamClosedTest() throws InterruptedException, IOException {
|
void streamClosedTest() throws InterruptedException, IOException {
|
||||||
// Callback counter for some unhandy async mockery.
|
// Callback counter for some unhandy async mockery.
|
||||||
final AtomicInteger counter = new AtomicInteger(0);
|
final AtomicInteger counter = new AtomicInteger(0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user