forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add module test for listing canceled trips
- Loading branch information
1 parent
45a01af
commit 0423999
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...test/java/org/opentripplanner/updater/trip/moduletests/cancellation/CanceledTripTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.opentripplanner.updater.trip.moduletests.cancellation; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static com.google.transit.realtime.GtfsRealtime.TripDescriptor.ScheduleRelationship.CANCELED; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.id; | ||
import static org.opentripplanner.updater.spi.UpdateResultAssertions.assertSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.updater.trip.RealtimeTestConstants; | ||
import org.opentripplanner.updater.trip.RealtimeTestEnvironment; | ||
import org.opentripplanner.updater.trip.TripInput; | ||
import org.opentripplanner.updater.trip.TripUpdateBuilder; | ||
|
||
public class CanceledTripTest implements RealtimeTestConstants { | ||
|
||
@Test | ||
void listCanceledTrips() { | ||
var env = RealtimeTestEnvironment | ||
.gtfs() | ||
.addTrip( | ||
TripInput | ||
.of(TRIP_1_ID) | ||
.addStop(STOP_A1, "0:00:10", "0:00:11") | ||
.addStop(STOP_B1, "0:00:20", "0:00:21") | ||
.build() | ||
) | ||
.build(); | ||
|
||
assertThat(env.getTransitService().listCanceledTrips()).isEmpty(); | ||
|
||
var update = new TripUpdateBuilder(TRIP_1_ID, SERVICE_DATE, CANCELED, TIME_ZONE).build(); | ||
assertSuccess(env.applyTripUpdate(update)); | ||
|
||
var canceled = env.getTransitService().listCanceledTrips(); | ||
assertThat(canceled).hasSize(1); | ||
var trip = canceled.getFirst(); | ||
assertEquals(id(TRIP_1_ID), trip.getTrip().getId()); | ||
assertEquals(SERVICE_DATE, trip.getServiceDate()); | ||
} | ||
} |