Skip to content

Commit

Permalink
Add test for parking processor
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 5, 2024
1 parent 65f40af commit 5fb878a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ public final StyleBuilder permissionsFilter(StreetTraversalPermission p) {
return this;
}

/**
* Filter the entities by a boolean property.
*/
public final StyleBuilder booleanFilter(String propertyName, boolean value) {
filter = List.of("==", propertyName, value);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private List<VehicleParking.VehicleParkingEntranceCreator> createArtificialEntra
);
}

private VehicleParking createVehicleParkingObjectFromOsmEntity(
VehicleParking createVehicleParkingObjectFromOsmEntity(
boolean isCarParkAndRide,
Coordinate coordinate,
OsmWithTags entity,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.opentripplanner.graph_builder.module.osm;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.opentripplanner._support.geometry.Coordinates;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.osm.wayproperty.specifier.WayTestData;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.street.model._data.StreetModelForTest;
import org.opentripplanner.street.model.vertex.IntersectionVertex;

class ParkingProcessorTest {

private static final IntersectionVertex INTERSECTION_VERTEX = StreetModelForTest.intersectionVertex(
1,
1
);
private static final ParkingProcessor PROCESSOR = new ParkingProcessor(
new Graph(),
DataImportIssueStore.NOOP,
(n, w) -> INTERSECTION_VERTEX
);

@Test
void noWheelchairParking() {
var entity = WayTestData.parkAndRide();
var parking = PROCESSOR.createVehicleParkingObjectFromOsmEntity(
true,
Coordinates.BERLIN,
entity,
I18NString.of("parking"),
List.of()
);

assertFalse(parking.hasWheelchairAccessibleCarPlaces());
assertNull(parking.getCapacity().getWheelchairAccessibleCarSpaces());
}

@Test
void wheelchairParking() {
var entity = WayTestData.parkAndRide();
entity.addTag("capacity:disabled", "yes");
var parking = PROCESSOR.createVehicleParkingObjectFromOsmEntity(
true,
Coordinates.BERLIN,
entity,
I18NString.of("parking"),
List.of()
);

assertTrue(parking.hasWheelchairAccessibleCarPlaces());
assertEquals(1, parking.getCapacity().getWheelchairAccessibleCarSpaces());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,12 @@ public static OsmWithTags indoor(String value) {
way.addTag("indoor", value);
return way;
}

public static OsmWithTags parkAndRide() {
var way = new OsmWithTags();
way.addTag("amenity", "parking");
way.addTag("park_ride", "yes");
way.addTag("capacity", "10");
return way;
}
}

0 comments on commit 5fb878a

Please sign in to comment.