-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5782 from HBTGmbH/island-pruning-for-stops-withou…
…t-modes Prune islands with mode-less stop vertices
- Loading branch information
Showing
3 changed files
with
138 additions
and
20 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
112 changes: 112 additions & 0 deletions
112
...st/java/org/opentripplanner/graph_builder/module/islandpruning/SubgraphOnlyFerryTest.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,112 @@ | ||
package org.opentripplanner.graph_builder.module.islandpruning; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.Set; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.street.model.vertex.TransitStopVertex; | ||
import org.opentripplanner.street.model.vertex.TransitStopVertexBuilder; | ||
import org.opentripplanner.transit.model._data.TransitModelForTest; | ||
import org.opentripplanner.transit.model.basic.TransitMode; | ||
import org.opentripplanner.transit.model.site.RegularStop; | ||
|
||
class SubgraphOnlyFerryTest { | ||
|
||
private static final TransitModelForTest TEST_MODEL = TransitModelForTest.of(); | ||
private static final RegularStop regularStop1 = TEST_MODEL.stop("TEST-1").build(); | ||
private static final RegularStop regularStop2 = TEST_MODEL.stop("TEST-2").build(); | ||
|
||
@Test | ||
void subgraphHasOnlyFerry() { | ||
TransitStopVertex transitStopVertex = new TransitStopVertexBuilder() | ||
.withStop(regularStop1) | ||
.withModes(Set.of(TransitMode.FERRY)) | ||
.build(); | ||
|
||
Subgraph subgraph = new Subgraph(); | ||
subgraph.addVertex(transitStopVertex); | ||
|
||
assertTrue(subgraph.hasOnlyFerryStops()); | ||
} | ||
|
||
@Test | ||
void subgraphHasOnlyNoFerry() { | ||
TransitStopVertex transitStopVertex1 = new TransitStopVertexBuilder() | ||
.withStop(regularStop1) | ||
.withModes(Set.of(TransitMode.BUS)) | ||
.build(); | ||
|
||
Subgraph subgraph = new Subgraph(); | ||
subgraph.addVertex(transitStopVertex1); | ||
|
||
assertFalse(subgraph.hasOnlyFerryStops()); | ||
} | ||
|
||
@Test | ||
void subgraphHasOnlyNoMode() { | ||
TransitStopVertex transitStopVertex1 = new TransitStopVertexBuilder() | ||
.withStop(regularStop1) | ||
.withModes(Set.of()) | ||
.build(); | ||
|
||
Subgraph subgraph = new Subgraph(); | ||
subgraph.addVertex(transitStopVertex1); | ||
|
||
assertFalse(subgraph.hasOnlyFerryStops()); | ||
} | ||
|
||
@Test | ||
void subgraphHasOnlyFerryMoreStops() { | ||
TransitStopVertex transitStopVertex1 = new TransitStopVertexBuilder() | ||
.withStop(regularStop1) | ||
.withModes(Set.of(TransitMode.FERRY)) | ||
.build(); | ||
TransitStopVertex transitStopVertex2 = new TransitStopVertexBuilder() | ||
.withStop(regularStop2) | ||
.withModes(Set.of(TransitMode.FERRY)) | ||
.build(); | ||
|
||
Subgraph subgraph = new Subgraph(); | ||
subgraph.addVertex(transitStopVertex1); | ||
subgraph.addVertex(transitStopVertex2); | ||
|
||
assertTrue(subgraph.hasOnlyFerryStops()); | ||
} | ||
|
||
@Test | ||
void subgraphHasNotOnlyFerryMoreStops() { | ||
TransitStopVertex transitStopVertex1 = new TransitStopVertexBuilder() | ||
.withStop(regularStop1) | ||
.withModes(Set.of(TransitMode.FERRY)) | ||
.build(); | ||
TransitStopVertex transitStopVertex2 = new TransitStopVertexBuilder() | ||
.withStop(regularStop2) | ||
.withModes(Set.of(TransitMode.BUS)) | ||
.build(); | ||
|
||
Subgraph subgraph = new Subgraph(); | ||
subgraph.addVertex(transitStopVertex1); | ||
subgraph.addVertex(transitStopVertex2); | ||
|
||
assertFalse(subgraph.hasOnlyFerryStops()); | ||
} | ||
|
||
@Test | ||
void subgraphHasNoModeMoreStops() { | ||
TransitStopVertex transitStopVertex1 = new TransitStopVertexBuilder() | ||
.withStop(regularStop1) | ||
.withModes(Set.of(TransitMode.FERRY)) | ||
.build(); | ||
TransitStopVertex transitStopVertex2 = new TransitStopVertexBuilder() | ||
.withStop(regularStop2) | ||
.withModes(Set.of()) | ||
.build(); | ||
|
||
Subgraph subgraph = new Subgraph(); | ||
subgraph.addVertex(transitStopVertex1); | ||
subgraph.addVertex(transitStopVertex2); | ||
|
||
assertFalse(subgraph.hasOnlyFerryStops()); | ||
} | ||
} |