Skip to content

Commit 1e029c6

Browse files
Convert to List
1 parent 3e4268e commit 1e029c6

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

application/src/main/java/org/opentripplanner/transit/service/TransitService.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,8 @@ public interface TransitService {
168168
* are returned. If the id matches a regular stop, area stop or stop group, then a list with one
169169
* item is returned.
170170
*/
171-
default Set<FeedScopedId> findStopOrChildIds(FeedScopedId id) {
172-
return findStopOrChildStops(id)
173-
.stream()
174-
.map(StopLocation::getId)
175-
.collect(Collectors.toUnmodifiableSet());
171+
default List<FeedScopedId> findStopOrChildIds(FeedScopedId id) {
172+
return findStopOrChildStops(id).stream().map(StopLocation::getId).distinct().toList();
176173
}
177174

178175
Collection<StopLocationsGroup> listStopLocationGroups();

application/src/test/java/org/opentripplanner/transit/service/DefaultTransitServiceTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.opentripplanner.transit.service;
22

3+
import static com.google.common.truth.Truth.assertThat;
34
import static org.junit.jupiter.api.Assertions.assertEquals;
45
import static org.junit.jupiter.api.Assertions.assertFalse;
56
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -337,24 +338,24 @@ void hasTripsForStop() {
337338
@Test
338339
void stopOrChildId() {
339340
var res = service.findStopOrChildIds(STOP_A.getId());
340-
assertEquals(Set.of(STOP_A.getId()), res);
341+
assertThat(res).containsExactly(STOP_A.getId());
341342
}
342343

343344
@Test
344345
void stationChildIds() {
345346
var res = service.findStopOrChildIds(STATION.getId());
346-
assertEquals(Set.of(STOP_A.getId(), STOP_B.getId()), res);
347+
assertThat(res).containsExactly(STOP_A.getId(), STOP_B.getId());
347348
}
348349

349350
@Test
350351
void multiModalStationChildIds() {
351352
var res = service.findStopOrChildIds(MM_STATION.getId());
352-
assertEquals(Set.of(STOP_A.getId(), STOP_B.getId()), res);
353+
assertThat(res).containsExactly(STOP_A.getId(), STOP_B.getId());
353354
}
354355

355356
@Test
356357
void groupOfStationsChildIds() {
357358
var res = service.findStopOrChildIds(GO_STATIONS.getId());
358-
assertEquals(Set.of(STOP_A.getId(), STOP_B.getId()), res);
359+
assertThat(res).containsExactly(STOP_A.getId(), STOP_B.getId());
359360
}
360361
}

0 commit comments

Comments
 (0)