Code style

Various code style improvements:
lines trimmed to 120 characters,
complete JavaDoc for public methods,
braces on multiline if-else,
fixed numbers defined as constants
This commit is contained in:
Stefan Kalscheuer 2017-08-04 10:06:44 +02:00
parent ee1d8bd2c8
commit 1f4bd9f411
5 changed files with 435 additions and 164 deletions

View File

@ -70,18 +70,18 @@ public class UraClient {
/** /**
* Constructor with base URL and default API paths. * Constructor with base URL and default API paths.
* *
* @param baseURL the base URL (with protocol, without trailing slash) * @param baseURL The base URL (with protocol, without trailing slash).
*/ */
public UraClient(String baseURL) { public UraClient(String baseURL) {
this(baseURL, DEFAULT_INSTANT_URL, DEFAULT_STREAM_URL); this(baseURL, DEFAULT_INSTANT_URL, DEFAULT_STREAM_URL);
} }
/** /**
* Constructor with base URL and custom API paths * Constructor with base URL and custom API paths.
* *
* @param baseURL the base URL (including protocol) * @param baseURL The base URL (including protocol).
* @param instantURL the path for instant requests * @param instantURL The path for instant requests.
* @param streamURL the path for stream requests * @param streamURL The path for stream requests.
*/ */
public UraClient(String baseURL, String instantURL, String streamURL) { public UraClient(String baseURL, String instantURL, String streamURL) {
this.baseURL = baseURL; this.baseURL = baseURL;
@ -113,8 +113,8 @@ public class UraClient {
/** /**
* Builder pattern to request given line IDs. * Builder pattern to request given line IDs.
* *
* @param lines line IDs * @param lines Line IDs.
* @return the request * @return The request.
*/ */
public Query forLines(final String... lines) { public Query forLines(final String... lines) {
return new Query().forLines(lines); return new Query().forLines(lines);
@ -123,8 +123,8 @@ public class UraClient {
/** /**
* Builder pattern to request given line names. * Builder pattern to request given line names.
* *
* @param lineNames line names * @param lineNames Line names.
* @return the request * @return The request.
*/ */
public Query forLinesByName(final String... lineNames) { public Query forLinesByName(final String... lineNames) {
return new Query().forLinesByName(lineNames); return new Query().forLinesByName(lineNames);
@ -133,8 +133,8 @@ public class UraClient {
/** /**
* Builder pattern to request given direction. * Builder pattern to request given direction.
* *
* @param direction the direction ID * @param direction The direction ID.
* @return the request * @return The request.
*/ */
public Query forDirection(final Integer direction) { public Query forDirection(final Integer direction) {
return new Query().forDirection(direction); return new Query().forDirection(direction);
@ -143,8 +143,8 @@ public class UraClient {
/** /**
* Builder pattern to request given destination names. * Builder pattern to request given destination names.
* *
* @param destinationNames destination names * @param destinationNames Destination names.
* @return the request * @return The request.
* @since 1.1.0 * @since 1.1.0
*/ */
public Query forDestinationNames(final String... destinationNames) { public Query forDestinationNames(final String... destinationNames) {
@ -154,8 +154,8 @@ public class UraClient {
/** /**
* Builder pattern to request given direction defined by stop point name. * Builder pattern to request given direction defined by stop point name.
* *
* @param towards towards stop point names * @param towards Towards stop point names.
* @return the request * @return The request.
* @since 1.1.0 * @since 1.1.0
*/ */
public Query towards(final String... towards) { public Query towards(final String... towards) {
@ -165,10 +165,10 @@ public class UraClient {
/** /**
* Builder pattern to request given destination names. * Builder pattern to request given destination names.
* *
* @param latitude Latitude (WGS84) * @param latitude Latitude (WGS84).
* @param longitude Longitude (WGS84) * @param longitude Longitude (WGS84).
* @param radius Search radius (meters) * @param radius Search radius (meters).
* @return the request * @return The request.
* @since 1.1.0 * @since 1.1.0
*/ */
public Query forPosition(final Double latitude, final Double longitude, final Integer radius) { public Query forPosition(final Double latitude, final Double longitude, final Integer radius) {
@ -179,7 +179,7 @@ public class UraClient {
* Get list of trips. * Get list of trips.
* If forStops() and/or forLines() 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 * @return List of trips.
*/ */
public List<Trip> getTrips() { public List<Trip> getTrips() {
return getTrips(new Query(), null); return getTrips(new Query(), null);
@ -189,8 +189,8 @@ public class UraClient {
* Get list of trips with limit. * Get list of trips with limit.
* If forStops() and/or forLines() 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 * @param limit Maximum number of results.
* @return list of trips * @return List of trips.
*/ */
public List<Trip> getTrips(final Integer limit) { public List<Trip> getTrips(final Integer limit) {
return getTrips(new Query(), limit); return getTrips(new Query(), limit);
@ -200,8 +200,8 @@ public class UraClient {
* Get list of trips. * Get list of trips.
* If forStops() and/or forLines() has been called, those will be used as filter. * If forStops() and/or forLines() has been called, those will be used as filter.
* *
* @param query the query * @param query The query.
* @return list of trips * @return List of trips.
*/ */
public List<Trip> getTrips(Query query) { public List<Trip> getTrips(Query query) {
return getTrips(query, null); return getTrips(query, null);
@ -210,26 +210,28 @@ public class UraClient {
/** /**
* Get list of trips for given stopIDs and lineIDs with result limit. * Get list of trips for given stopIDs and lineIDs with result limit.
* *
* @param query the query * @param query The query.
* @param limit maximum number of results * @param limit Maximum number of results.
* @return list of trips * @return List of trips.
*/ */
public List<Trip> getTrips(final Query query, final Integer limit) { public List<Trip> getTrips(final Query query, final Integer limit) {
List<Trip> trips = new ArrayList<>(); List<Trip> trips = new ArrayList<>();
try (InputStream is = requestInstant(REQUEST_TRIP, query); try (InputStream is = requestInstant(REQUEST_TRIP, query);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) { BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String version = null; String version = null;
String line; String line = br.readLine();
while ((line = br.readLine()) != 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.size() > 0) { if (l != null && l.size() > 0) {
if (l.get(0).equals(RES_TYPE_URA_VERSION)) if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
version = l.get(1).toString(); version = l.get(1).toString();
else if (l.get(0).equals(RES_TYPE_PREDICTION)) } else if (l.get(0).equals(RES_TYPE_PREDICTION)) {
trips.add(new Trip(l, version)); trips.add(new Trip(l, version));
} }
} }
line = br.readLine();
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -239,7 +241,7 @@ public class UraClient {
/** /**
* Get list of stops without filters. * Get list of stops without filters.
* *
* @return the list * @return Lhe list.
*/ */
public List<Stop> getStops() { public List<Stop> getStops() {
return getStops(new Query()); return getStops(new Query());
@ -249,8 +251,8 @@ public class UraClient {
* List available stopIDs. * List available stopIDs.
* If forStops() and/or forLines() has been called, those will be used as filter. * If forStops() and/or forLines() has been called, those will be used as filter.
* *
* @param query the query * @param query The query.
* @return the list * @return The list.
*/ */
public List<Stop> getStops(Query query) { public List<Stop> getStops(Query query) {
List<Stop> stops = new ArrayList<>(); List<Stop> stops = new ArrayList<>();
@ -261,9 +263,10 @@ public class UraClient {
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.size() > 0 && l.get(0).equals(RES_TYPE_STOP)) if (l != null && l.size() > 0 && l.get(0).equals(RES_TYPE_STOP)) {
stops.add(new Stop(l)); stops.add(new Stop(l));
} }
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -273,30 +276,41 @@ public class UraClient {
/** /**
* Issue request to instant endpoint and return input stream. * Issue request to instant endpoint and return input stream.
* *
* @param returnList fields to fetch * @param returnList Fields to fetch.
* @param query the query * @param query The query.
* @return Input stream of the URL * @return Input stream of the URL
* @throws IOException on errors * @throws IOException on errors
*/ */
private InputStream requestInstant(String[] returnList, Query query) throws IOException { private InputStream requestInstant(String[] returnList, Query query) throws IOException {
String urlStr = baseURL + instantURL + "?ReturnList=" + String.join(",", returnList); String urlStr = baseURL + instantURL + "?ReturnList=" + String.join(",", returnList);
if (query.stopIDs != null && query.stopIDs.length > 0)
if (query.stopIDs != null && query.stopIDs.length > 0) {
urlStr += "&" + PAR_STOP_ID + "=" + String.join(",", query.stopIDs); urlStr += "&" + PAR_STOP_ID + "=" + String.join(",", query.stopIDs);
if (query.stopNames != null && query.stopNames.length > 0) }
if (query.stopNames != null && query.stopNames.length > 0) {
urlStr += "&" + PAR_STOP_NAME + "=" + String.join(",", query.stopNames); urlStr += "&" + PAR_STOP_NAME + "=" + String.join(",", query.stopNames);
if (query.lineIDs != null && query.lineIDs.length > 0) }
if (query.lineIDs != null && query.lineIDs.length > 0) {
urlStr += "&" + PAR_LINE_ID + "=" + String.join(",", query.lineIDs); urlStr += "&" + PAR_LINE_ID + "=" + String.join(",", query.lineIDs);
if (query.lineNames != null && query.lineNames.length > 0) }
if (query.lineNames != null && query.lineNames.length > 0) {
urlStr += "&" + PAR_LINE_NAME + "=" + String.join(",", query.lineNames); urlStr += "&" + PAR_LINE_NAME + "=" + String.join(",", query.lineNames);
if (query.direction != null) }
if (query.direction != null) {
urlStr += "&" + PAR_DIR_ID + "=" + query.direction; urlStr += "&" + PAR_DIR_ID + "=" + query.direction;
if (query.destinationNames != null) }
if (query.destinationNames != null) {
urlStr += "&" + PAR_DEST_NAME + "=" + String.join(",", query.destinationNames); urlStr += "&" + PAR_DEST_NAME + "=" + String.join(",", query.destinationNames);
if (query.towards != null) }
if (query.towards != null) {
urlStr += "&" + PAR_TOWARDS + "=" + String.join(",", query.towards); urlStr += "&" + PAR_TOWARDS + "=" + String.join(",", query.towards);
if (query.circle != null) }
if (query.circle != null) {
urlStr += "&" + PAR_CIRCLE + "=" + String.join(",", query.circle); urlStr += "&" + PAR_CIRCLE + "=" + String.join(",", query.circle);
}
URL url = new URL(urlStr); URL url = new URL(urlStr);
return url.openStream(); return url.openStream();
} }
@ -316,8 +330,8 @@ public class UraClient {
/** /**
* Builder pattern to request given line IDs. * Builder pattern to request given line IDs.
* *
* @param lineIDs line IDs * @param lineIDs Line IDs.
* @return the query * @return The query.
*/ */
public Query forLines(final String... lineIDs) { public Query forLines(final String... lineIDs) {
this.lineIDs = lineIDs; this.lineIDs = lineIDs;
@ -327,8 +341,8 @@ public class UraClient {
/** /**
* Builder pattern to request given line names. * Builder pattern to request given line names.
* *
* @param lineNames line names * @param lineNames Line names.
* @return the query * @return The query.
*/ */
public Query forLinesByName(final String... lineNames) { public Query forLinesByName(final String... lineNames) {
this.lineNames = lineNames; this.lineNames = lineNames;
@ -338,8 +352,8 @@ public class UraClient {
/** /**
* Builder pattern to request given stop IDs. * Builder pattern to request given stop IDs.
* *
* @param stopIDs stop IDs * @param stopIDs Stop IDs.
* @return the query * @return The query.
*/ */
public Query forStops(final String... stopIDs) { public Query forStops(final String... stopIDs) {
this.stopIDs = stopIDs; this.stopIDs = stopIDs;
@ -349,8 +363,8 @@ public class UraClient {
/** /**
* Builder pattern to request given stop names. * Builder pattern to request given stop names.
* *
* @param stopNames line names * @param stopNames Line names.
* @return the query * @return The query.
*/ */
public Query forStopsByName(final String... stopNames) { public Query forStopsByName(final String... stopNames) {
this.stopNames = stopNames; this.stopNames = stopNames;
@ -360,8 +374,8 @@ public class UraClient {
/** /**
* Builder pattern to request given direction. * Builder pattern to request given direction.
* *
* @param direction the direction * @param direction The direction.
* @return the query * @return The query.
*/ */
public Query forDirection(final Integer direction) { public Query forDirection(final Integer direction) {
this.direction = direction; this.direction = direction;
@ -369,10 +383,10 @@ public class UraClient {
} }
/** /**
* Builder pattern to request given destination names * Builder pattern to request given destination names.
* *
* @param destinationNames names of destinations * @param destinationNames Names of destinations.
* @return the query * @return The query.
* @since 1.1.0 * @since 1.1.0
*/ */
public Query forDestinationNames(final String... destinationNames) { public Query forDestinationNames(final String... destinationNames) {
@ -383,8 +397,8 @@ public class UraClient {
/** /**
* Builder pattern to request given direction defined by stop point name. * Builder pattern to request given direction defined by stop point name.
* *
* @param towards towards stop point names * @param towards Towards stop point names.
* @return the request * @return The request.
* @since 1.1.0 * @since 1.1.0
*/ */
public Query towards(final String... towards) { public Query towards(final String... towards) {
@ -395,10 +409,10 @@ public class UraClient {
/** /**
* Builder pattern to request given position and radius. * Builder pattern to request given position and radius.
* *
* @param latitude Latitude (WGS84) * @param latitude Latitude (WGS84).
* @param longitude Longitude (WGS84) * @param longitude Longitude (WGS84).
* @param radius Search radius (meters) * @param radius Search radius (meters).
* @return the query * @return The query.
* @since 1.1.0 * @since 1.1.0
*/ */
public Query forPosition(final Double latitude, final Double longitude, final Integer radius) { public Query forPosition(final Double latitude, final Double longitude, final Integer radius) {
@ -409,7 +423,7 @@ public class UraClient {
/** /**
* Get stops for set filters. * Get stops for set filters.
* *
* @return List of matching trips * @return List of matching trips.
*/ */
public List<Stop> getStops() { public List<Stop> getStops() {
return UraClient.this.getStops(this); return UraClient.this.getStops(this);
@ -418,7 +432,7 @@ public class UraClient {
/** /**
* Get trips for set filters. * Get trips for set filters.
* *
* @return List of matching trips * @return List of matching trips.
*/ */
public List<Trip> getTrips() { public List<Trip> getTrips() {
return UraClient.this.getTrips(this); return UraClient.this.getTrips(this);

View File

@ -25,6 +25,14 @@ import java.util.List;
* @author Stefan Kalscheuer * @author Stefan Kalscheuer
*/ */
public class Stop { public class Stop {
private static final int STOP_NAME = 1;
private static final int STOP_ID = 2;
private static final int INDICATOR = 3;
private static final int STATE = 4;
private static final int LATITUDE = 5;
private static final int LONGITUDE = 6;
private static final int NUM_OF_FIELDS = 7;
private final String id; private final String id;
private final String name; private final String name;
private final String indicator; private final String indicator;
@ -32,6 +40,16 @@ public class Stop {
private final Double latitude; private final Double latitude;
private final Double longitude; private final Double longitude;
/**
* Construct Stop object.
*
* @param id Stop ID.
* @param name Stop name.
* @param indicator Stop indicator.
* @param state Stop state.
* @param latitude Stop geolocation latitude.
* @param longitude Stop geolocation longitude.
*/
public Stop(String id, String name, String indicator, Integer state, Double latitude, Double longitude) { public Stop(String id, String name, String indicator, Integer state, Double latitude, Double longitude) {
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -41,58 +59,100 @@ public class Stop {
this.longitude = longitude; this.longitude = longitude;
} }
/**
* Construct Stop object from raw list of attributes parsed from JSON.
*
* @param raw List of attributes from JSON line
* @throws IOException Thrown on invalid line format.
*/
public Stop(List raw) throws IOException { public Stop(List raw) throws IOException {
if (raw == null || raw.size() < 7) if (raw == null || raw.size() < NUM_OF_FIELDS) {
throw new IOException("Invalid number of fields"); throw new IOException("Invalid number of fields");
if (raw.get(1) instanceof String)
name = (String)raw.get(1);
else
throw new IOException("Field 1 not of expected type String, found " + raw.get(1).getClass().getSimpleName());
if (raw.get(2) instanceof String)
id = (String)raw.get(2);
else
throw new IOException("Field 2 not of expected type String, found " + raw.get(2).getClass().getSimpleName());
if (raw.get(3) instanceof String)
indicator = (String)raw.get(3);
else if (raw.get(3) == null)
indicator = null;
else
throw new IOException("Field 3 not of expected type String, found " + raw.get(3).getClass().getSimpleName());
if (raw.get(4) instanceof Integer)
state = (Integer)raw.get(4);
else
throw new IOException("Field 4 not of expected type Integer, found " + raw.get(4).getClass().getSimpleName());
if (raw.get(5) instanceof Double)
latitude = (Double)raw.get(5);
else
throw new IOException("Field 5 not of expected type Double, found " + raw.get(5).getClass().getSimpleName());
if (raw.get(6) instanceof Double)
longitude = (Double)raw.get(6);
else
throw new IOException("Field 6 not of expected type Double, found " + raw.get(6).getClass().getSimpleName());
} }
if (raw.get(1) instanceof String) {
name = (String) raw.get(STOP_NAME);
} else {
throw new IOException("Field " + STOP_NAME + " not of expected type String, found "
+ raw.get(STOP_NAME).getClass().getSimpleName());
}
if (raw.get(STOP_ID) instanceof String) {
id = (String) raw.get(STOP_ID);
} else {
throw new IOException("Field " + STOP_ID + " not of expected type String, found "
+ raw.get(STOP_ID).getClass().getSimpleName());
}
if (raw.get(INDICATOR) instanceof String) {
indicator = (String) raw.get(INDICATOR);
} else if (raw.get(INDICATOR) == null) {
indicator = null;
} else {
throw new IOException("Field " + INDICATOR + " not of expected type String, found "
+ raw.get(INDICATOR).getClass().getSimpleName());
}
if (raw.get(STATE) instanceof Integer) {
state = (Integer) raw.get(STATE);
} else {
throw new IOException("Field " + STATE + " not of expected type Integer, found "
+ raw.get(STATE).getClass().getSimpleName());
}
if (raw.get(LATITUDE) instanceof Double) {
latitude = (Double) raw.get(LATITUDE);
} else {
throw new IOException("Field " + LATITUDE + " not of expected type Double, found "
+ raw.get(LATITUDE).getClass().getSimpleName());
}
if (raw.get(LONGITUDE) instanceof Double) {
longitude = (Double) raw.get(LONGITUDE);
} else {
throw new IOException("Field " + LONGITUDE + " not of expected type Double, found "
+ raw.get(LONGITUDE).getClass().getSimpleName());
}
}
/**
* @return The stop ID.
*/
public String getId() { public String getId() {
return id; return id;
} }
/**
* @return The stop name.
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* @return The stop indicator.
*/
public String getIndicator() { public String getIndicator() {
return indicator; return indicator;
} }
/**
* @return The stop indicator.
*/
public Integer getState() { public Integer getState() {
return state; return state;
} }
/**
* @return The stop geoloaction latitude.
*/
public Double getLatitude() { public Double getLatitude() {
return latitude; return latitude;
} }
/**
* @return The stop geolocation longitude.
*/
public Double getLongitude() { public Double getLongitude() {
return longitude; return longitude;
} }

View File

@ -25,6 +25,17 @@ import java.util.List;
* @author Stefan Kalscheuer * @author Stefan Kalscheuer
*/ */
public class Trip { public class Trip {
private static final int VISIT_ID = 7;
private static final int LINE_ID = 8;
private static final int LINE_NAME = 9;
private static final int DIRECTION_ID = 10;
private static final int DESTINATION_NAME = 11;
private static final int DESTINATION_TEXT = 12;
private static final int VEHICLE_ID = 13;
private static final int TRIP_ID = 14;
private static final int ESTIMATED_TIME = 15;
private static final int NUM_OF_FIELDS = 16;
private final Stop stop; private final Stop stop;
private final String id; private final String id;
private final Integer visitID; private final Integer visitID;
@ -36,13 +47,81 @@ public class Trip {
private final Long estimatedTime; private final Long estimatedTime;
private final String vehicleID; private final String vehicleID;
public Trip(String stopID, String stopName, String stopIndicator, Integer stopState, Double stopLatitude, Double stopLongitude, /**
Integer visitID, String lineID, String lineName, Integer directionID, String destinationName, String destinationText, String vehicleID, String tripID, Long estimatedTime) { * Construct Trip object from complete set of data.
this(new Stop(stopID, stopName, stopIndicator, stopState, stopLatitude, stopLongitude), *
visitID, lineID, lineName, directionID, destinationName, destinationText, vehicleID, tripID, estimatedTime); * @param stopID Stop ID.
* @param stopName Stop name.
* @param stopIndicator Stop Indicator.
* @param stopState Stop state.
* @param stopLatitude Stop geolocation latitude.
* @param stopLongitude Stop geolocation latitude.
* @param visitID Visit ID.
* @param lineID Line ID.
* @param lineName Line name.
* @param directionID Direction ID.
* @param destinationName Destination name.
* @param destinationText Destination text.
* @param vehicleID Vehicle ID.
* @param tripID Trip ID.
* @param estimatedTime Estimated time.
*/
public Trip(String stopID,
String stopName,
String stopIndicator,
Integer stopState,
Double stopLatitude,
Double stopLongitude,
Integer visitID,
String lineID,
String lineName,
Integer directionID,
String destinationName,
String destinationText,
String vehicleID,
String tripID,
Long estimatedTime) {
this(new Stop(stopID,
stopName,
stopIndicator,
stopState,
stopLatitude,
stopLongitude),
visitID,
lineID,
lineName,
directionID,
destinationName,
destinationText,
vehicleID,
tripID,
estimatedTime);
} }
public Trip(Stop stop, Integer visitID, String lineID, String lineName, Integer directionID, String destinationName, String destinationText, String vehicleID, String tripID, Long estimatedTime) { /**
* Construct Trip object from Stop model and set of additional data.
*
* @param stop Stop model
* @param visitID Visit ID
* @param lineID Line ID
* @param lineName Line name
* @param directionID Direction ID
* @param destinationName Destination name
* @param destinationText Destination text
* @param vehicleID Vehicle ID
* @param tripID Trip ID
* @param estimatedTime Estimated time
*/
public Trip(Stop stop,
Integer visitID,
String lineID,
String lineName,
Integer directionID,
String destinationName,
String destinationText,
String vehicleID,
String tripID,
Long estimatedTime) {
this.stop = stop; this.stop = stop;
this.visitID = visitID; this.visitID = visitID;
this.lineID = lineID; this.lineID = lineID;
@ -55,94 +134,168 @@ public class Trip {
this.estimatedTime = estimatedTime; this.estimatedTime = estimatedTime;
} }
/**
* Construct Trip object from raw list of attributes parsed from JSON.
*
* @param raw List of attributes from JSON line
* @throws IOException Thrown on invalid line format.
*/
public Trip(List raw) throws IOException { public Trip(List raw) throws IOException {
this(raw, null); this(raw, null);
} }
/**
* Construct Stop object from raw list of attributes parsed from JSON with explicitly specified version.
*
* @param raw List of attributes from JSON line
* @param version API version
* @throws IOException Thrown on invalid line format.
*/
public Trip(List raw, String version) throws IOException { public Trip(List raw, String version) throws IOException {
if (raw == null || raw.size() < 16) if (raw == null || raw.size() < NUM_OF_FIELDS) {
throw new IOException("Invalid number of fields"); throw new IOException("Invalid number of fields");
}
stop = new Stop(raw); stop = new Stop(raw);
if (raw.get(7) instanceof Integer) if (raw.get(VISIT_ID) instanceof Integer) {
visitID = (Integer) raw.get(7); visitID = (Integer) raw.get(VISIT_ID);
else } else {
throw new IOException("Field 7 not of expected type Integer, found " + raw.get(7).getClass().getSimpleName()); throw new IOException("Field " + VISIT_ID + " not of expected type Integer, found "
if (raw.get(8) instanceof String) + raw.get(VISIT_ID).getClass().getSimpleName());
lineID = (String)raw.get(8);
else
throw new IOException("Field 8 not of expected type String, found " + raw.get(8).getClass().getSimpleName());
if (raw.get(9) instanceof String)
lineName = (String)raw.get(9);
else
throw new IOException("Field 9 not of expected type String, found " + raw.get(9).getClass().getSimpleName());
if (raw.get(10) instanceof Integer) {
directionID = (Integer) raw.get(10);
if (directionID < 0 || directionID > 2)
throw new IOException("Direction out of range. Expected 1 or 2, found " + directionID);
}
else
throw new IOException("Field 10 not of expected type Integer, found " + raw.get(10).getClass().getSimpleName());
if (raw.get(11) instanceof String)
destinationName = (String)raw.get(11);
else
throw new IOException("Field 11 not of expected type String, found " + raw.get(11).getClass().getSimpleName());
if (raw.get(12) instanceof String)
destinationText = (String)raw.get(12);
else
throw new IOException("Field 12 not of expected type String, found " + raw.get(12).getClass().getSimpleName());
/* TFL and ASEAG deliver different types with the same API version, so this field is a little more tolerant */
if (raw.get(13) instanceof String || raw.get(13) instanceof Integer || raw.get(13) instanceof Long)
vehicleID = raw.get(13).toString();
else
throw new IOException("Field 13 not of expected type String/Integer/Long, found " + raw.get(13).getClass().getSimpleName());
if (raw.get(14) instanceof String || raw.get(14) instanceof Integer || raw.get(14) instanceof Long)
id = raw.get(14).toString();
else
throw new IOException("Field 14 not of expected type String/Integer/Long, found " + raw.get(14).getClass().getSimpleName());
if (raw.get(15) instanceof Long)
estimatedTime = (Long)raw.get(15);
else
throw new IOException("Field 15 not of expected type Long, found " + raw.get(15).getClass().getSimpleName());
} }
if (raw.get(LINE_ID) instanceof String) {
lineID = (String) raw.get(LINE_ID);
} else {
throw new IOException("Field " + LINE_ID + " not of expected type String, found "
+ raw.get(LINE_ID).getClass().getSimpleName());
}
if (raw.get(LINE_NAME) instanceof String) {
lineName = (String) raw.get(LINE_NAME);
} else {
throw new IOException("Field " + LINE_NAME + " not of expected type String, found "
+ raw.get(LINE_NAME).getClass().getSimpleName());
}
if (raw.get(DIRECTION_ID) instanceof Integer) {
directionID = (Integer) raw.get(DIRECTION_ID);
if (directionID < 0 || directionID > 2) {
throw new IOException("Direction out of range. Expected 1 or 2, found " + directionID);
}
} else {
throw new IOException("Field " + DIRECTION_ID + " not of expected type Integer, found "
+ raw.get(DIRECTION_ID).getClass().getSimpleName());
}
if (raw.get(DESTINATION_NAME) instanceof String) {
destinationName = (String) raw.get(DESTINATION_NAME);
} else {
throw new IOException("Field " + DESTINATION_NAME + " not of expected type String, found "
+ raw.get(DESTINATION_NAME).getClass().getSimpleName());
}
if (raw.get(DESTINATION_TEXT) instanceof String) {
destinationText = (String) raw.get(DESTINATION_TEXT);
} else {
throw new IOException("Field " + DESTINATION_TEXT + " not of expected type String, found "
+ raw.get(DESTINATION_TEXT).getClass().getSimpleName());
}
/* TFL and ASEAG deliver different types with the same API version, so this field is a little more tolerant */
if (raw.get(VEHICLE_ID) instanceof String
|| raw.get(VEHICLE_ID) instanceof Integer
|| raw.get(VEHICLE_ID) instanceof Long) {
vehicleID = raw.get(VEHICLE_ID).toString();
} else {
throw new IOException("Field " + VEHICLE_ID + " not of expected type String/Integer/Long, found "
+ raw.get(VEHICLE_ID).getClass().getSimpleName());
}
if (raw.get(TRIP_ID) instanceof String
|| raw.get(TRIP_ID) instanceof Integer
|| raw.get(TRIP_ID) instanceof Long) {
id = raw.get(TRIP_ID).toString();
} else {
throw new IOException("Field " + TRIP_ID + " not of expected type String/Integer/Long, found "
+ raw.get(TRIP_ID).getClass().getSimpleName());
}
if (raw.get(ESTIMATED_TIME) instanceof Long) {
estimatedTime = (Long) raw.get(ESTIMATED_TIME);
} else {
throw new IOException("Field " + ESTIMATED_TIME + " not of expected type Long, found "
+ raw.get(ESTIMATED_TIME).getClass().getSimpleName());
}
}
/**
* @return The (starting) stop.
*/
public Stop getStop() { public Stop getStop() {
return stop; return stop;
} }
/**
* @return The trip ID.
*/
public String getId() { public String getId() {
return id; return id;
} }
/**
* @return The visit ID.
*/
public Integer getVisitID() { public Integer getVisitID() {
return visitID; return visitID;
} }
/**
* @return The line ID.
*/
public String getLineID() { public String getLineID() {
return lineID; return lineID;
} }
/**
* @return The line name.
*/
public String getLineName() { public String getLineName() {
return lineName; return lineName;
} }
/**
* @return The direction ID.
*/
public Integer getDirectionID() { public Integer getDirectionID() {
return directionID; return directionID;
} }
/**
* @return The destination name.
*/
public String getDestinationName() { public String getDestinationName() {
return destinationName; return destinationName;
} }
/**
* @return The destination text.
*/
public String getDestinationText() { public String getDestinationText() {
return destinationText; return destinationText;
} }
/**
* @return The estimated departure time.
*/
public Long getEstimatedTime() { public Long getEstimatedTime() {
return estimatedTime; return estimatedTime;
} }
/**
* @return The vehicle ID.
*/
public String getVehicleID() { public String getVehicleID() {
return vehicleID; return vehicleID;
} }

View File

@ -50,7 +50,8 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V2_stops.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V2_stops.txt"));
/* List stops and verify some values */ /* List stops and verify some values */
List<Stop> stops = new UraClient("mocked").getStops(); List<Stop> stops = new UraClient("mocked").getStops();
@ -78,7 +79,8 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V2_stops_line.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V2_stops_line.txt"));
/* List stops and verify some values */ /* List stops and verify some values */
List<Stop> stops = new UraClient("mocked").forLines("33").getStops(); List<Stop> stops = new UraClient("mocked").forLines("33").getStops();
@ -96,10 +98,13 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_stops_circle.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_stops_circle.txt"));
/* List stops and verify some values */ /* List stops and verify some values */
List<Stop> stops = new UraClient("mocked").forPosition(51.51009, -0.1345734, 200).getStops(); List<Stop> stops = new UraClient("mocked")
.forPosition(51.51009, -0.1345734, 200)
.getStops();
assertThat(stops, hasSize(13)); assertThat(stops, hasSize(13));
assertThat(stops.get(0).getId(), is("156")); assertThat(stops.get(0).getId(), is("156"));
assertThat(stops.get(1).getName(), is("Piccadilly Circus")); assertThat(stops.get(1).getName(), is("Piccadilly Circus"));
@ -108,8 +113,12 @@ public class UraClientTest {
assertThat(stops.get(4).getLongitude(), is(-0.134172)); assertThat(stops.get(4).getLongitude(), is(-0.134172));
assertThat(stops.get(5).getIndicator(), is(nullValue())); assertThat(stops.get(5).getIndicator(), is(nullValue()));
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_stops_circle_name.txt")); PowerMockito.when(mockURL.openStream())
stops = new UraClient("mocked").forStopsByName("Piccadilly Circus").forPosition(51.51009, -0.1345734, 200).getStops(); .thenReturn(getClass().getResourceAsStream("instant_V1_stops_circle_name.txt"));
stops = new UraClient("mocked")
.forStopsByName("Piccadilly Circus")
.forPosition(51.51009, -0.1345734, 200)
.getStops();
assertThat(stops, hasSize(7)); assertThat(stops, hasSize(7));
assertThat(stops.stream().filter(t -> !t.getName().equals("Piccadilly Circus")).findAny(), is(Optional.empty())); assertThat(stops.stream().filter(t -> !t.getName().equals("Piccadilly Circus")).findAny(), is(Optional.empty()));
} }
@ -119,18 +128,26 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_destination.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_destination.txt"));
/* List stops and verify some values */ /* List stops and verify some values */
List<Trip> trips = new UraClient("mocked").forDestinationNames("Piccadilly Circus").getTrips(); List<Trip> trips = new UraClient("mocked").forDestinationNames("Piccadilly Circus").getTrips();
assertThat(trips, hasSize(9)); assertThat(trips, hasSize(9));
assertThat(trips.stream().filter(t -> !t.getDestinationName().equals("Piccadilly Cir")).findAny(), is(Optional.empty())); assertThat(trips.stream().filter(t -> !t.getDestinationName().equals("Piccadilly Cir")).findAny(),
is(Optional.empty()));
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_destination.txt")); PowerMockito.when(mockURL.openStream())
trips = new UraClient("mocked").forStops("156").forDestinationNames("Marble Arch").getTrips(); .thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_destination.txt"));
trips = new UraClient("mocked")
.forStops("156")
.forDestinationNames("Marble Arch")
.getTrips();
assertThat(trips, hasSize(5)); assertThat(trips, hasSize(5));
assertThat(trips.stream().filter(t -> !t.getStop().getId().equals("156")).findAny(), is(Optional.empty())); assertThat(trips.stream().filter(t -> !t.getStop().getId().equals("156")).findAny(),
assertThat(trips.stream().filter(t -> !t.getDestinationName().equals("Marble Arch")).findAny(), is(Optional.empty())); is(Optional.empty()));
assertThat(trips.stream().filter(t -> !t.getDestinationName().equals("Marble Arch")).findAny(),
is(Optional.empty()));
} }
@Test @Test
@ -138,13 +155,15 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_towards.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_towards.txt"));
/* List stops and verify some values */ /* List stops and verify some values */
List<Trip> trips = new UraClient("mocked").towards("Marble Arch").getTrips(); List<Trip> trips = new UraClient("mocked").towards("Marble Arch").getTrips();
assertThat(trips, hasSize(10)); assertThat(trips, hasSize(10));
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_towards.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_towards.txt"));
trips = new UraClient("mocked").forStops("156").towards("Marble Arch").getTrips(); trips = new UraClient("mocked").forStops("156").towards("Marble Arch").getTrips();
assertThat(trips, hasSize(17)); assertThat(trips, hasSize(17));
assertThat(trips.stream().filter(t -> !t.getStop().getId().equals("156")).findAny(), is(Optional.empty())); assertThat(trips.stream().filter(t -> !t.getStop().getId().equals("156")).findAny(), is(Optional.empty()));
@ -155,7 +174,8 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_all.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_all.txt"));
/* Get trips without filters and verify some values */ /* Get trips without filters and verify some values */
List<Trip> trips = new UraClient("mocked").getTrips(); List<Trip> trips = new UraClient("mocked").getTrips();
@ -172,7 +192,8 @@ public class UraClientTest {
assertThat(trips.get(9).getStop().getId(), is("100002")); assertThat(trips.get(9).getStop().getId(), is("100002"));
/* Repeat test for API V2 */ /* Repeat test for API V2 */
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V2_trips_all.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V2_trips_all.txt"));
/* Get trips without filters and verify some values */ /* Get trips without filters and verify some values */
trips = new UraClient("mocked").getTrips(); trips = new UraClient("mocked").getTrips();
assertThat(trips, hasSize(10)); assertThat(trips, hasSize(10));
@ -188,7 +209,8 @@ public class UraClientTest {
assertThat(trips.get(9).getStop().getId(), is("100002")); assertThat(trips.get(9).getStop().getId(), is("100002"));
/* Get limited number of trips */ /* Get limited number of trips */
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_all.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_all.txt"));
trips = new UraClient("mocked").getTrips(5); trips = new UraClient("mocked").getTrips(5);
assertThat(trips, hasSize(5)); assertThat(trips, hasSize(5));
@ -209,7 +231,8 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop.txt"));
/* Get trips for stop ID 100000 (Aachen Bushof) and verify some values */ /* Get trips for stop ID 100000 (Aachen Bushof) and verify some values */
List<Trip> trips = new UraClient("mocked") List<Trip> trips = new UraClient("mocked")
@ -223,12 +246,14 @@ public class UraClientTest {
assertThat(trips.get(3).getStop().getIndicator(), is("H.15")); assertThat(trips.get(3).getStop().getIndicator(), is("H.15"));
/* Get trips for stop name "Uniklinik" and verify some values */ /* Get trips for stop name "Uniklinik" and verify some values */
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_name.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_name.txt"));
trips = new UraClient("mocked") trips = new UraClient("mocked")
.forStopsByName("Uniklinik") .forStopsByName("Uniklinik")
.getTrips(); .getTrips();
assertThat(trips, hasSize(10)); assertThat(trips, hasSize(10));
assertThat(trips.stream().filter(t -> !t.getStop().getName().equals("Uniklinik")).findAny(), is(Optional.empty())); assertThat(trips.stream().filter(t -> !t.getStop().getName().equals("Uniklinik")).findAny(),
is(Optional.empty()));
assertThat(trips.get(0).getId(), is("92000043013001")); assertThat(trips.get(0).getId(), is("92000043013001"));
assertThat(trips.get(1).getLineID(), is("5")); assertThat(trips.get(1).getLineID(), is("5"));
assertThat(trips.get(2).getVehicleID(), is("317"));; assertThat(trips.get(2).getVehicleID(), is("317"));;
@ -240,7 +265,8 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_line.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_line.txt"));
/* Get trips for line ID 3 and verify some values */ /* Get trips for line ID 3 and verify some values */
List<Trip> trips = new UraClient("mocked") List<Trip> trips = new UraClient("mocked")
@ -254,7 +280,8 @@ public class UraClientTest {
assertThat(trips.get(3).getStop().getIndicator(), is("H.4 (Pontwall)")); assertThat(trips.get(3).getStop().getIndicator(), is("H.4 (Pontwall)"));
/* Get trips for line name "3.A" and verify some values */ /* Get trips for line name "3.A" and verify some values */
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_line_name.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_line_name.txt"));
trips = new UraClient("mocked") trips = new UraClient("mocked")
.forLinesByName("3.A") .forLinesByName("3.A")
.getTrips(); .getTrips();
@ -266,7 +293,8 @@ public class UraClientTest {
assertThat(trips.get(3).getStop().getName(), is("Aachen Gartenstraße")); assertThat(trips.get(3).getStop().getName(), is("Aachen Gartenstraße"));
/* Get trips for line 3 with direction 1 and verify some values */ /* Get trips for line 3 with direction 1 and verify some values */
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_line_direction.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_line_direction.txt"));
trips = new UraClient("mocked") trips = new UraClient("mocked")
.forLines("412") .forLines("412")
.forDirection(2) .forDirection(2)
@ -276,7 +304,8 @@ public class UraClientTest {
assertThat(trips.stream().filter(t -> !t.getDirectionID().equals(2)).findAny(), is(Optional.empty())); assertThat(trips.stream().filter(t -> !t.getDirectionID().equals(2)).findAny(), is(Optional.empty()));
/* Test lineID and direction in different order */ /* Test lineID and direction in different order */
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_line_direction.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_line_direction.txt"));
trips = new UraClient("mocked") trips = new UraClient("mocked")
.forDirection(2) .forDirection(2)
.forLines("412") .forLines("412")
@ -291,7 +320,8 @@ public class UraClientTest {
/* Mock the HTTP call */ /* Mock the HTTP call */
URL mockURL = PowerMockito.mock(URL.class); URL mockURL = PowerMockito.mock(URL.class);
PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL);
PowerMockito.when(mockURL.openStream()).thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_line.txt")); PowerMockito.when(mockURL.openStream())
.thenReturn(getClass().getResourceAsStream("instant_V1_trips_stop_line.txt"));
/* Get trips for line ID 25 and 25 at stop 100000 and verify some values */ /* Get trips for line ID 25 and 25 at stop 100000 and verify some values */
List<Trip> trips = new UraClient("mocked") List<Trip> trips = new UraClient("mocked")
@ -299,7 +329,8 @@ public class UraClientTest {
.forStops("100000") .forStops("100000")
.getTrips(); .getTrips();
assertThat(trips, hasSize(10)); assertThat(trips, hasSize(10));
assertThat(trips.stream().filter(t -> !t.getLineID().equals("25") && !t.getLineID().equals("35")).findAny(), is(Optional.empty())); assertThat(trips.stream().filter(t -> !t.getLineID().equals("25") && !t.getLineID().equals("35")).findAny(),
is(Optional.empty()));
assertThat(trips.stream().filter(t -> !t.getStop().getId().equals("100000")).findAny(), is(Optional.empty())); assertThat(trips.stream().filter(t -> !t.getStop().getId().equals("100000")).findAny(), is(Optional.empty()));
assertThat(trips.get(0).getId(), is("27000078014001")); assertThat(trips.get(0).getId(), is("27000078014001"));
assertThat(trips.get(1).getLineID(), is("25")); assertThat(trips.get(1).getLineID(), is("25"));

View File

@ -36,8 +36,21 @@ import static org.junit.Assert.fail;
public class TripTest { public class TripTest {
@Test @Test
public void basicConstructorTest() { public void basicConstructorTest() {
Trip trip = new Trip("sid", "name", "indicator", 1, 2.345, 6.789, Trip trip = new Trip("sid",
123, "lineid", "linename", 0, "destination name", "destination text", "vehicle", "id", 123456789123456789L); "name",
"indicator",
1,
2.345,
6.789,
123,
"lineid",
"linename",
0,
"destination name",
"destination text",
"vehicle",
"id",
123456789123456789L);
assertThat(trip.getStop().getId(), is("sid")); assertThat(trip.getStop().getId(), is("sid"));
assertThat(trip.getStop().getName(), is("name")); assertThat(trip.getStop().getName(), is("name"));
assertThat(trip.getStop().getIndicator(), is("indicator")); assertThat(trip.getStop().getIndicator(), is("indicator"));