-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
70 additions
and
12 deletions.
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
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
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
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
56 changes: 56 additions & 0 deletions
56
application/src/test/java/org/opentripplanner/updater/siri/EntityResolverTest.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,56 @@ | ||
package org.opentripplanner.updater.siri; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest; | ||
import org.opentripplanner.transit.model.framework.Deduplicator; | ||
import org.opentripplanner.transit.model.framework.FeedScopedId; | ||
import org.opentripplanner.transit.model.site.RegularStop; | ||
import org.opentripplanner.transit.service.DefaultTransitService; | ||
import org.opentripplanner.transit.service.SiteRepository; | ||
import org.opentripplanner.transit.service.TimetableRepository; | ||
|
||
class EntityResolverTest { | ||
|
||
private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); | ||
private static final RegularStop STOP_1 = TEST_MODEL.stop("stop-1").build(); | ||
private static final RegularStop STOP_2 = TEST_MODEL.stop("stop-2").build(); | ||
private static final SiteRepository SITE_REPOSITORY = TEST_MODEL | ||
.siteRepositoryBuilder() | ||
.withRegularStops(List.of(STOP_1, STOP_2)) | ||
.build(); | ||
private static final String FEED_ID = STOP_1.getId().getFeedId(); | ||
private static final FeedScopedId SSP_ID = new FeedScopedId(FEED_ID, "ssp-1"); | ||
|
||
@Test | ||
void resolveScheduledStopPointId() { | ||
var timetableRepository = new TimetableRepository(); | ||
timetableRepository.addScheduledStopPointMapping(Map.of(SSP_ID, STOP_1)); | ||
var transitService = new DefaultTransitService(timetableRepository); | ||
var resolver = new EntityResolver(transitService, FEED_ID); | ||
var stop = resolver.resolveQuay(SSP_ID.getId()); | ||
assertEquals(STOP_1, stop); | ||
} | ||
|
||
@Test | ||
void resolveQuayId() { | ||
var timetableRepository = new TimetableRepository(SITE_REPOSITORY, new Deduplicator()); | ||
var transitService = new DefaultTransitService(timetableRepository); | ||
var resolver = new EntityResolver(transitService, FEED_ID); | ||
var stop = resolver.resolveQuay(STOP_1.getId().getId()); | ||
assertEquals(STOP_1, stop); | ||
} | ||
|
||
@Test | ||
void scheduledStopPointTakesPrecedence() { | ||
var timetableRepository = new TimetableRepository(SITE_REPOSITORY, new Deduplicator()); | ||
var transitService = new DefaultTransitService(timetableRepository); | ||
timetableRepository.addScheduledStopPointMapping(Map.of(SSP_ID, STOP_2)); | ||
var resolver = new EntityResolver(transitService, FEED_ID); | ||
assertEquals(STOP_2, resolver.resolveQuay(SSP_ID.getId())); | ||
assertEquals(STOP_1, resolver.resolveQuay(STOP_1.getId().getId())); | ||
} | ||
} |