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.
Sort GTFS files alphabetically inside GtfsModule
- Loading branch information
1 parent
b272f14
commit 9b13977
Showing
3 changed files
with
50 additions
and
9 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
29 changes: 29 additions & 0 deletions
29
src/test/java/org/opentripplanner/graph_builder/module/GtfsModuleTest.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,29 @@ | ||
package org.opentripplanner.graph_builder.module; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import org.junit.Test; | ||
import org.opentripplanner.graph_builder.model.GtfsBundle; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class GtfsModuleTest { | ||
|
||
@Test | ||
public void shouldSortByFileNameAlphabetically() { | ||
List<GtfsBundle> bundles = ImmutableList.of("C.gtfs", "/tmp/z.gtfs", "/x-files/001-a.gtfs", "/some/other/folder/b.gtfs") | ||
.stream() | ||
.map(name -> new GtfsBundle(new File(name))).collect(Collectors.toList()); | ||
|
||
GtfsModule module = new GtfsModule(bundles); | ||
|
||
List<String> names = module.getGtfsBundles().stream().map(m -> m.getPath().getName()).collect(Collectors.toList()); | ||
|
||
assertThat(names, is(ImmutableList.of("001-a.gtfs", "b.gtfs", "C.gtfs", "z.gtfs"))); | ||
|
||
} | ||
} |