|
1 | 1 | package org.opentripplanner.routing.linking;
|
2 | 2 |
|
3 |
| -import static org.junit.jupiter.api.Assertions.*; |
| 3 | +import static com.google.common.truth.Truth.assertThat; |
4 | 4 |
|
| 5 | +import java.util.List; |
| 6 | +import java.util.Set; |
5 | 7 | import org.junit.jupiter.api.Test;
|
| 8 | +import org.opentripplanner.framework.application.OTPFeature; |
6 | 9 | import org.opentripplanner.routing.graph.Graph;
|
7 | 10 | import org.opentripplanner.street.model._data.StreetModelForTest;
|
8 |
| -import org.opentripplanner.test.support.GeoJsonIo; |
| 11 | +import org.opentripplanner.street.model.edge.LinkingDirection; |
| 12 | +import org.opentripplanner.street.model.vertex.SplitterVertex; |
| 13 | +import org.opentripplanner.street.model.vertex.StreetVertex; |
| 14 | +import org.opentripplanner.street.search.TraverseModeSet; |
| 15 | +import org.opentripplanner.transit.model._data.TimetableRepositoryForTest; |
| 16 | +import org.opentripplanner.transit.model.site.AreaStop; |
9 | 17 |
|
10 | 18 | class VertexLinkerTest {
|
11 | 19 |
|
| 20 | + public static final TimetableRepositoryForTest REPO = TimetableRepositoryForTest.of(); |
| 21 | + public static final AreaStop AREA_STOP_1 = REPO.areaStop("area-stop-1").build(); |
| 22 | + public static final AreaStop AREA_STOP_2 = REPO.areaStop("area-stop-2").build(); |
| 23 | + |
12 | 24 | @Test
|
13 | 25 | void flex() {
|
14 |
| - var v1 = StreetModelForTest.intersectionVertex(0, 0); |
15 |
| - var v2 = StreetModelForTest.intersectionVertex(0.1, 0.1); |
16 |
| - var edge = StreetModelForTest.streetEdge(v1, v2); |
| 26 | + OTPFeature.FlexRouting.testOn(() -> { |
| 27 | + var v1 = StreetModelForTest.intersectionVertex(0, 0); |
| 28 | + v1.addAreaStops(Set.of(AREA_STOP_1)); |
| 29 | + var v2 = StreetModelForTest.intersectionVertex(0.1, 0.1); |
| 30 | + v2.addAreaStops(Set.of(AREA_STOP_2)); |
| 31 | + |
| 32 | + var toBeLinked = StreetModelForTest.intersectionVertex(0.05, 0.06); |
| 33 | + |
| 34 | + assertThat(toBeLinked.areaStops()).isEmpty(); |
| 35 | + |
| 36 | + StreetModelForTest.streetEdge(v1, v2); |
| 37 | + |
| 38 | + var graph = new Graph(); |
| 39 | + |
| 40 | + graph.addVertex(v1); |
| 41 | + graph.addVertex(v2); |
| 42 | + graph.index(); |
| 43 | + |
| 44 | + var linker = new VertexLinker(graph); |
17 | 45 |
|
18 |
| - var graph = new Graph(); |
| 46 | + linker.linkVertexPermanently( |
| 47 | + toBeLinked, |
| 48 | + TraverseModeSet.allModes(), |
| 49 | + LinkingDirection.BIDIRECTIONAL, |
| 50 | + (vertex, streetVertex) -> |
| 51 | + List.of( |
| 52 | + StreetModelForTest.streetEdge((StreetVertex) vertex, streetVertex), |
| 53 | + StreetModelForTest.streetEdge(streetVertex, (StreetVertex) vertex) |
| 54 | + ) |
| 55 | + ); |
19 | 56 |
|
20 |
| - graph.addVertex(v1); |
21 |
| - graph.addVertex(v2); |
22 |
| - graph.index(); |
| 57 | + var splitterVertices = graph.getVerticesOfType(SplitterVertex.class); |
| 58 | + assertThat(splitterVertices).hasSize(1); |
| 59 | + var splitter = splitterVertices.getFirst(); |
23 | 60 |
|
24 |
| - System.out.println(GeoJsonIo.toUrl(graph)); |
| 61 | + assertThat(splitter.areaStops()).containsExactly(AREA_STOP_1, AREA_STOP_2); |
| 62 | + }); |
25 | 63 | }
|
26 | 64 | }
|
0 commit comments