forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'realtime-vehicle-pattern' into test-during-holiday
- Loading branch information
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
.../opentripplanner/service/realtimevehicles/internal/DefaultRealtimeVehicleServiceTest.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,55 @@ | ||
package org.opentripplanner.service.realtimevehicles.internal; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.opentripplanner.framework.geometry.WgsCoordinate.GREENWICH; | ||
import static org.opentripplanner.transit.model._data.TransitModelForTest.route; | ||
import static org.opentripplanner.transit.model._data.TransitModelForTest.tripPattern; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.service.realtimevehicles.model.RealtimeVehicle; | ||
import org.opentripplanner.transit.model._data.TransitModelForTest; | ||
import org.opentripplanner.transit.model.network.Route; | ||
import org.opentripplanner.transit.model.network.StopPattern; | ||
import org.opentripplanner.transit.model.network.TripPattern; | ||
import org.opentripplanner.transit.service.DefaultTransitService; | ||
import org.opentripplanner.transit.service.TransitModel; | ||
|
||
class DefaultRealtimeVehicleServiceTest { | ||
|
||
private static final Route ROUTE = route("r1").build(); | ||
private static final TransitModelForTest MODEL = TransitModelForTest.of(); | ||
private static final StopPattern STOP_PATTERN = TransitModelForTest.stopPattern( | ||
MODEL.stop("1").build(), | ||
MODEL.stop("2").build() | ||
); | ||
private static final TripPattern ORIGINAL = tripPattern("original", ROUTE) | ||
.withStopPattern(STOP_PATTERN) | ||
.build(); | ||
private static final Instant TIME = Instant.ofEpochSecond(1000); | ||
private static final List<RealtimeVehicle> VEHICLES = List.of( | ||
RealtimeVehicle.builder().withTime(TIME).withCoordinates(GREENWICH).build() | ||
); | ||
|
||
@Test | ||
void originalPattern() { | ||
var service = new DefaultRealtimeVehicleService(new DefaultTransitService(new TransitModel())); | ||
service.setRealtimeVehicles(ORIGINAL, VEHICLES); | ||
var updates = service.getRealtimeVehicles(ORIGINAL); | ||
assertEquals(VEHICLES, updates); | ||
} | ||
|
||
@Test | ||
void realtimeAddedPattern() { | ||
var service = new DefaultRealtimeVehicleService(new DefaultTransitService(new TransitModel())); | ||
var realtimePattern = tripPattern("realtime-added", ROUTE) | ||
.withStopPattern(STOP_PATTERN) | ||
.withOriginalTripPattern(ORIGINAL) | ||
.withCreatedByRealtimeUpdater(true) | ||
.build(); | ||
service.setRealtimeVehicles(realtimePattern, VEHICLES); | ||
var updates = service.getRealtimeVehicles(ORIGINAL); | ||
assertEquals(VEHICLES, updates); | ||
} | ||
} |