From 70c5998eef18beb8e14f21071ae4d63f4865567a Mon Sep 17 00:00:00 2001 From: olech2412 Date: Mon, 19 Feb 2024 21:43:02 +0100 Subject: [PATCH 1/4] implemented models first tries are lookin great write tests, and make some experiences later :D --- .../adapter/dbadapter/APIConfiguration.java | 3 + .../adapter/dbadapter/DB_Adapter_v6.java | 24 +++- .../dbadapter/model/journey/Journey.java | 31 +++++ .../dbadapter/model/journey/sub/Leg.java | 121 ++++++++++++++++++ .../dbadapter/model/journey/sub/Location.java | 26 ++++ .../dbadapter/model/journey/sub/Price.java | 21 +++ .../parameters/RequestParametersNames.java | 4 + .../adapter/dbadapter/DB_Adapter_v6Test.java | 16 +++ 8 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Location.java create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Price.java diff --git a/src/main/java/de/olech2412/adapter/dbadapter/APIConfiguration.java b/src/main/java/de/olech2412/adapter/dbadapter/APIConfiguration.java index b85988d..f1e1391 100644 --- a/src/main/java/de/olech2412/adapter/dbadapter/APIConfiguration.java +++ b/src/main/java/de/olech2412/adapter/dbadapter/APIConfiguration.java @@ -49,6 +49,9 @@ private void buildRequestList() { .build(), new Request.RequestBuilder() .setApiEndpoint(RequestPath.STATIONS) + .build(), + new Request.RequestBuilder() + .setApiEndpoint(RequestPath.JOURNEYS) .build() ); } diff --git a/src/main/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6.java b/src/main/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6.java index 09f0aef..1167869 100644 --- a/src/main/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6.java +++ b/src/main/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6.java @@ -7,6 +7,7 @@ import de.olech2412.adapter.dbadapter.gsonadapter.GeographicCoordinatesAdapter; import de.olech2412.adapter.dbadapter.gsonadapter.LocalDateTimeAdapter; import de.olech2412.adapter.dbadapter.gsonadapter.LocalDateTimeAdapterForTrip; +import de.olech2412.adapter.dbadapter.model.journey.Journey; import de.olech2412.adapter.dbadapter.model.station.Station; import de.olech2412.adapter.dbadapter.model.station.sub.GeographicCoordinates; import de.olech2412.adapter.dbadapter.model.stop.Stop; @@ -111,7 +112,6 @@ public Result getStopById(Integer id, List> parameters log.error(String.format("Error while getting stop by id %s: %s", id, result.getError().getError())); return Result.error(result.getError()); } else { - Result stopResult = Result.success(gson.fromJson(result.getData(), Stop.class)); return Result.success(gson.fromJson(result.getData(), Stop.class)); } } @@ -137,6 +137,28 @@ public Result getStationById(Integer id, List> para } } + /** + * Get a journey with the given parameters + * + * @param parameters the parameters of the journey from and to are necessary + * @return the journey or an error + * @throws IOException if the request fails + */ + public Result getJourney(List> parameters) throws IOException { + String parameter = ParameterEvaluator.convertToString(parameters); + Request request = getRequest(RequestPath.JOURNEYS); + request.setApiEndpoint(request.getApiEndpoint() + parameter); + Result result = performRequest(request); + + if (!result.isSuccess()) { + log.error(String.format("Error while getting journey: %s", result.getError().getError())); + return Result.error(result.getError()); + } else { + JsonArray jsonArray = result.getData().getAsJsonArray("journeys"); + return Result.success(gson.fromJson(jsonArray, Journey[].class)); + } + } + /** * Get the request from the api configuration * diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java new file mode 100644 index 0000000..6d01acd --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java @@ -0,0 +1,31 @@ +package de.olech2412.adapter.dbadapter.model.journey; + +import de.olech2412.adapter.dbadapter.model.journey.sub.Leg; +import de.olech2412.adapter.dbadapter.model.journey.sub.Price; + +import java.util.List; + +/** + * Represents a journey from one location to another. + */ +public class Journey { + /** + * The type of the journey. + */ + private String type; + + /** + * The legs of the journey. Each leg represents a part of the journey. + */ + private List legs; + + /** + * The refresh token for the journey. This can be used to update the journey information. + */ + private String refreshToken; + + /** + * The price of the journey. + */ + private Price price; +} diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java new file mode 100644 index 0000000..5f387ae --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java @@ -0,0 +1,121 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +import de.olech2412.adapter.dbadapter.model.stop.Stop; +import de.olech2412.adapter.dbadapter.model.stop.sub.Line; +import de.olech2412.adapter.dbadapter.model.trip.sub.Remark; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * Represents a leg of a journey. + */ +@Getter +@Setter +public class Leg { + /** + * The origin stop of the leg. + */ + private Stop origin; + + /** + * The destination stop of the leg. + */ + private Stop destination; + + /** + * The departure time of the leg. + */ + private String departure; + + /** + * The planned departure time of the leg. + */ + private String plannedDeparture; + + /** + * The delay in departure of the leg in minutes. + */ + private int departureDelay; + + /** + * The arrival time of the leg. + */ + private String arrival; + + /** + * The planned arrival time of the leg. + */ + private String plannedArrival; + + /** + * The delay in arrival of the leg in minutes. + */ + private int arrivalDelay; + + /** + * Indicates if the leg is reachable. + */ + private boolean reachable; + + /** + * The trip ID of the leg. + */ + private String tripId; + + /** + * The line of the leg. + */ + private Line line; + + /** + * The direction of the leg. + */ + private String direction; + + /** + * The current location of the leg. + */ + private Location currentLocation; + + /** + * The arrival platform of the leg. + */ + private String arrivalPlatform; + + /** + * The planned arrival platform of the leg. + */ + private String plannedArrivalPlatform; + + /** + * The type of arrival prognosis of the leg. + */ + private String arrivalPrognosisType; + + /** + * The departure platform of the leg. + */ + private String departurePlatform; + + /** + * The planned departure platform of the leg. + */ + private String plannedDeparturePlatform; + + /** + * The type of departure prognosis of the leg. + */ + private String departurePrognosisType; + + /** + * The remarks for the leg. + */ + private List remarks; + + /** + * The load factor of the leg. + */ + private String loadFactor; +} \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Location.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Location.java new file mode 100644 index 0000000..d1f2739 --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Location.java @@ -0,0 +1,26 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +/** + * Represents a location in the system. + */ +public class Location { + /** + * The type of the location. + */ + private String type; + + /** + * The ID of the location. + */ + private String id; + + /** + * The latitude of the location. + */ + private double latitude; + + /** + * The longitude of the location. + */ + private double longitude; +} \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Price.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Price.java new file mode 100644 index 0000000..f5a07cd --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Price.java @@ -0,0 +1,21 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +/** + * Represents the price of a journey. + */ +public class Price { + /** + * The amount of the price. + */ + private double amount; + + /** + * The currency of the price. + */ + private String currency; + + /** + * A hint related to the price. + */ + private String hint; +} \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java b/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java index e6cef7d..b9a7d78 100644 --- a/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java +++ b/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java @@ -39,6 +39,10 @@ public enum RequestParametersNames { TRAM("tram"), // include tram? + FROM("from"), // from + + TO("to"), // to + TAXI("taxi"); // include taxi? private final String parameter; diff --git a/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java b/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java index b7145c9..43b7ae8 100644 --- a/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java +++ b/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java @@ -2,6 +2,7 @@ import de.olech2412.adapter.dbadapter.exception.Error; import de.olech2412.adapter.dbadapter.exception.Result; +import de.olech2412.adapter.dbadapter.model.journey.Journey; import de.olech2412.adapter.dbadapter.model.station.Station; import de.olech2412.adapter.dbadapter.model.stop.Stop; import de.olech2412.adapter.dbadapter.model.trip.Trip; @@ -56,6 +57,21 @@ public void testGetDeparturesByStopId() throws IOException { Assertions.assertNotNull(departure.getTripId()); } + @Test + public void testGetJourneys() throws IOException { + + Result journeysResult = db_adapter_v6.getJourney(new Parameter.ParameterBuilder().add( + RequestParametersNames.FROM, 8000001).add(RequestParametersNames.TO, 8000013).build() + ); + + Assertions.assertNotNull(journeysResult); + Assert.assertTrue(journeysResult.isSuccess()); + Assertions.assertNotEquals(0, journeysResult.getData().length); + + Journey journey = journeysResult.getData()[0]; + Assertions.assertNotNull(journey); + } + @Test public void testGetStopById() throws IOException { From c651e7233035b3f88fecca4700c6fa74abc01305 Mon Sep 17 00:00:00 2001 From: olech2412 Date: Tue, 20 Feb 2024 09:19:55 +0100 Subject: [PATCH 2/4] updated RequestParametersNames.java --- .../parameters/RequestParametersNames.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java b/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java index b9a7d78..19c040f 100644 --- a/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java +++ b/src/main/java/de/olech2412/adapter/dbadapter/request/parameters/RequestParametersNames.java @@ -43,6 +43,44 @@ public enum RequestParametersNames { TO("to"), // to + DEPARTURE("departure"), // departure + + ARRIVAL("arrival"), // arrival + + EARLIER_THAN("earlierThan"), // Compute journeys "before" an ealierRef. + + LATER_THAN("laterThan"), // Compute journeys "after" an laterRef. + + STOP_OVERS("stopovers"), // Fetch & parse stopovers on the way? + + TRANSFERS("transfers"), // Maximum number of transfers. + + TRANSFER_TIME("transferTime"), // Minimum time for a single transfer in minutes. + + ACCESSIBILITY("accessibility"), // Partial or complete + + BIKE("bike"), // Compute only bike-friendly journeys? + + START_WITH_WALKING("startWithWalking"), // Consider walking to nearby stations at the beginning of a journey? + + WALKING_SPEED("walkingSpeed"), // slow, normal or fast + + TICKETS("tickets"), // Return information about available tickets? + + POLYLINES("polylines"), // Fetch & parse a shape for each journey leg? + + SUB_STOPS("subStops"), // Parse & return sub-stops of stations? + + ENTRANCES("entrances"), // Parse & return entrances of stops/stations? + + SCHEDULED_DAYS("scheduledDays"), // Parse & return dates each journey is valid on? + + LOYALTY_CARD("loyaltyCard"), // Type of loyalty card in use + + FIRST_CLASS("firstClass"), // Search for first-class options? + + AGE("age"), // Age of traveller + TAXI("taxi"); // include taxi? private final String parameter; From 43b0497ee6ee43386bd0f74b527e0b729bbedd40 Mon Sep 17 00:00:00 2001 From: olech2412 Date: Tue, 20 Feb 2024 10:50:21 +0100 Subject: [PATCH 3/4] implemented journeys with the most important features; some special features are not implemented yet --- .../dbadapter/model/journey/Journey.java | 6 +++ .../dbadapter/model/journey/sub/Feature.java | 23 ++++++++ .../dbadapter/model/journey/sub/Geometry.java | 22 ++++++++ .../dbadapter/model/journey/sub/Leg.java | 12 +++++ .../dbadapter/model/journey/sub/Polyline.java | 22 ++++++++ .../model/journey/sub/Properties.java | 29 ++++++++++ .../dbadapter/model/journey/sub/Stopover.java | 54 +++++++++++++++++++ .../adapter/dbadapter/DB_Adapter_v6Test.java | 30 ++++++++--- 8 files changed, 191 insertions(+), 7 deletions(-) create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Feature.java create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Geometry.java create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Polyline.java create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Properties.java create mode 100644 src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Stopover.java diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java index 6d01acd..19ad08e 100644 --- a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/Journey.java @@ -2,12 +2,18 @@ import de.olech2412.adapter.dbadapter.model.journey.sub.Leg; import de.olech2412.adapter.dbadapter.model.journey.sub.Price; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import java.util.List; /** * Represents a journey from one location to another. */ +@Getter +@Setter +@ToString public class Journey { /** * The type of the journey. diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Feature.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Feature.java new file mode 100644 index 0000000..1ca7e23 --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Feature.java @@ -0,0 +1,23 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * The Feature class represents a feature in a journey. + * It contains a type, properties and geometry of the feature. + */ +@Getter +@Setter +@ToString +public class Feature { + // The type of the feature + private String type; + + // The properties of the feature + private Properties properties; + + // The geometry of the feature + private Geometry geometry; +} \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Geometry.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Geometry.java new file mode 100644 index 0000000..647a4e0 --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Geometry.java @@ -0,0 +1,22 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * The Geometry class represents the geometric coordinates of a location. + * It contains a type and a list of coordinates. + */ +@Getter +@Setter +@ToString +public class Geometry { + // The type of the geometry + private String type; + + // The coordinates of the geometry + private List coordinates; +} \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java index 5f387ae..8b6a086 100644 --- a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Leg.java @@ -5,6 +5,7 @@ import de.olech2412.adapter.dbadapter.model.trip.sub.Remark; import lombok.Getter; import lombok.Setter; +import lombok.ToString; import java.util.List; @@ -13,6 +14,7 @@ */ @Getter @Setter +@ToString public class Leg { /** * The origin stop of the leg. @@ -118,4 +120,14 @@ public class Leg { * The load factor of the leg. */ private String loadFactor; + + /** + * The stopovers of the leg. + */ + private List stopovers; + + /** + * The geometry of the leg. + */ + private Polyline polyline; } \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Polyline.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Polyline.java new file mode 100644 index 0000000..54ca4e5 --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Polyline.java @@ -0,0 +1,22 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * The Polyline class represents a polyline in a journey. + * It contains a type and a list of features associated with the polyline. + */ +@Getter +@Setter +@ToString +public class Polyline { + // The type of the polyline + private String type; + + // A list of features associated with the polyline + private List features; +} \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Properties.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Properties.java new file mode 100644 index 0000000..46f3b58 --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Properties.java @@ -0,0 +1,29 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +import de.olech2412.adapter.dbadapter.model.stop.sub.Products; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Properties of a property. + */ +@Getter +@Setter +@ToString +public class Properties { + // The type of the property + private String type; + + // The id of the property + private String id; + + // The name of the property + private String name; + + // The location of the property + private Location location; + + // The products associated with the property + private Products products; +} \ No newline at end of file diff --git a/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Stopover.java b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Stopover.java new file mode 100644 index 0000000..3af9106 --- /dev/null +++ b/src/main/java/de/olech2412/adapter/dbadapter/model/journey/sub/Stopover.java @@ -0,0 +1,54 @@ +package de.olech2412.adapter.dbadapter.model.journey.sub; + +import de.olech2412.adapter.dbadapter.model.stop.Stop; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * The Stopover class represents a stopover in a journey. + * It contains details about the stop, arrival and departure information. + */ +@Getter +@Setter +@ToString +public class Stopover { + // The stop details + private Stop stop; + + // The arrival time + private String arrival; + + // The planned arrival time + private String plannedArrival; + + // The delay in arrival + private Integer arrivalDelay; + + // The arrival platform + private String arrivalPlatform; + + // The type of arrival prognosis + private String arrivalPrognosisType; + + // The planned arrival platform + private String plannedArrivalPlatform; + + // The departure time + private String departure; + + // The planned departure time + private String plannedDeparture; + + // The delay in departure + private Integer departureDelay; + + // The departure platform + private String departurePlatform; + + // The type of departure prognosis + private String departurePrognosisType; + + // The planned departure platform + private String plannedDeparturePlatform; +} \ No newline at end of file diff --git a/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java b/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java index 43b7ae8..a332b6f 100644 --- a/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java +++ b/src/test/java/de/olech2412/adapter/dbadapter/DB_Adapter_v6Test.java @@ -59,15 +59,31 @@ public void testGetDeparturesByStopId() throws IOException { @Test public void testGetJourneys() throws IOException { - Result journeysResult = db_adapter_v6.getJourney(new Parameter.ParameterBuilder().add( - RequestParametersNames.FROM, 8000001).add(RequestParametersNames.TO, 8000013).build() + RequestParametersNames.FROM, 8000001) + .add(RequestParametersNames.TO, 8000013) + .add(RequestParametersNames.REGIONAL, false) + .add(RequestParametersNames.REGIONAL_EXPRESS, false) + .add(RequestParametersNames.SUBURBAN, false) + .add(RequestParametersNames.BUS, false) + .add(RequestParametersNames.FERRY, false) + .add(RequestParametersNames.SUBWAY, false) + .add(RequestParametersNames.TRAM, false) + .add(RequestParametersNames.TAXI, false) + .add(RequestParametersNames.STOP_OVERS, true) + .add(RequestParametersNames.NATIONAL, true) + .add(RequestParametersNames.LANGUAGE, "de") + .add(RequestParametersNames.NATIONAL_EXPRESS, true) + .build() ); Assertions.assertNotNull(journeysResult); Assert.assertTrue(journeysResult.isSuccess()); Assertions.assertNotEquals(0, journeysResult.getData().length); + // check if the first journey has legs + Assertions.assertNotNull(journeysResult.getData()[0].getLegs()); + Journey journey = journeysResult.getData()[0]; Assertions.assertNotNull(journey); } @@ -145,7 +161,7 @@ public void testParameterTrainType() throws IOException { Assertions.assertNotEquals(0, arrivalsWithParameterResult.getData().length); for (Trip trip : arrivalsWithParameterResult.getData()) { - Assertions.assertTrue(trip.getLine().getProduct().equals("nationalExpress")); + Assertions.assertEquals("nationalExpress", trip.getLine().getProduct()); } Result arrivalsWithParameterResult2 = db_adapter_v6.getArrivalsByStopId(stopId, new Parameter.ParameterBuilder() @@ -163,7 +179,7 @@ public void testParameterTrainType() throws IOException { .build()); for (Trip trip : arrivalsWithParameterResult2.getData()) { - Assertions.assertTrue(trip.getLine().getProduct().equals("national")); + Assertions.assertEquals("national", trip.getLine().getProduct()); } Result arrivalsWithParameterResult3 = db_adapter_v6.getArrivalsByStopId(stopId, new Parameter.ParameterBuilder() @@ -181,7 +197,7 @@ public void testParameterTrainType() throws IOException { .build()); for (Trip trip : arrivalsWithParameterResult3.getData()) { - Assertions.assertTrue(trip.getLine().getProduct().equals("regionalExpress")); + Assertions.assertEquals("regionalExpress", trip.getLine().getProduct()); } Result arrivalsWithParameterResult4 = db_adapter_v6.getArrivalsByStopId(stopId, new Parameter.ParameterBuilder() @@ -199,7 +215,7 @@ public void testParameterTrainType() throws IOException { .build()); for (Trip trip : arrivalsWithParameterResult4.getData()) { - Assertions.assertTrue(trip.getLine().getProduct().equals("regional")); + Assertions.assertEquals("regional", trip.getLine().getProduct()); } Result arrivalsWithParameterResult5 = db_adapter_v6.getArrivalsByStopId(stopId, new Parameter.ParameterBuilder() @@ -217,7 +233,7 @@ public void testParameterTrainType() throws IOException { .build()); for (Trip trip : arrivalsWithParameterResult5.getData()) { - Assertions.assertTrue(trip.getLine().getProduct().equals("suburban")); + Assertions.assertEquals("suburban", trip.getLine().getProduct()); } Result arrivalsWithParameterResult6 = db_adapter_v6.getArrivalsByStopId(stopId, new Parameter.ParameterBuilder() From 3bd409d4e68f2286222e2c488f3e8b280d8c3f86 Mon Sep 17 00:00:00 2001 From: olech2412 Date: Tue, 20 Feb 2024 11:00:23 +0100 Subject: [PATCH 4/4] new version APIConfigurationTest angepasst --- pom.xml | 4 ++-- .../de/olech2412/adapter/dbadapter/APIConfigurationTest.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2d2f810..e361a07 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 de.olech2412.adapter db-adapter-v6 - 2.1.0 + 2.2.0 db-adapter-v6 This is an adapter for this rest-api: https://github.com/derhuerst/db-rest. It can be used as a maven dependency and provides all models @@ -49,7 +49,7 @@ org.apache.logging.log4j log4j-core - 2.22.0 + 2.22.1 diff --git a/src/test/java/de/olech2412/adapter/dbadapter/APIConfigurationTest.java b/src/test/java/de/olech2412/adapter/dbadapter/APIConfigurationTest.java index 93244f4..8aa977a 100644 --- a/src/test/java/de/olech2412/adapter/dbadapter/APIConfigurationTest.java +++ b/src/test/java/de/olech2412/adapter/dbadapter/APIConfigurationTest.java @@ -23,7 +23,8 @@ public void test_getRequests() { new Request.RequestBuilder().setApiEndpoint(RequestPath.STOPS_BY_ID_DEPARTURES).build(), new Request.RequestBuilder().setApiEndpoint(RequestPath.STOPS_BY_ID_ARRIVALS).build(), new Request.RequestBuilder().setApiEndpoint(RequestPath.STATIONS_BY_ID).build(), - new Request.RequestBuilder().setApiEndpoint(RequestPath.STATIONS).build() + new Request.RequestBuilder().setApiEndpoint(RequestPath.STATIONS).build(), + new Request.RequestBuilder().setApiEndpoint(RequestPath.JOURNEYS).build() ); APIConfiguration apiConfiguration = new APIConfiguration(); Assert.assertEquals(apiConfiguration.getRequests().size(), expectedRequests.size());