From 9d7c3f8d9b8fbe2f4c8cafe0826f0987175cb094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Erik=20St=C3=B8wer?= Date: Tue, 4 Jun 2024 14:17:52 +0200 Subject: [PATCH] Add rideStartAllowed and rideEndAllowed to gql api --- .../entitymapper/GeofencingZonesMapper.java | 2 ++ .../model/entities/GeofencingZones.java | 18 ++++++++++++++++++ src/main/resources/graphql/schema.graphqls | 4 +++- .../integration/GraphQLIntegrationTest.java | 12 ++++++++++++ .../resources/geofencing_zones_query.graphql | 4 +++- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/entur/lamassu/mapper/entitymapper/GeofencingZonesMapper.java b/src/main/java/org/entur/lamassu/mapper/entitymapper/GeofencingZonesMapper.java index 81fd8209..fb7efe9d 100644 --- a/src/main/java/org/entur/lamassu/mapper/entitymapper/GeofencingZonesMapper.java +++ b/src/main/java/org/entur/lamassu/mapper/entitymapper/GeofencingZonesMapper.java @@ -136,6 +136,8 @@ private org.entur.lamassu.model.entities.GeofencingZones.Rule mapRule(GBFSRule r var mapped = new org.entur.lamassu.model.entities.GeofencingZones.Rule(); mapped.setVehicleTypeIds(rule.getVehicleTypeIds()); mapped.setRideAllowed(rule.getRideStartAllowed() && rule.getRideEndAllowed()); + mapped.setRideStartAllowed(rule.getRideStartAllowed()); + mapped.setRideEndAllowed(rule.getRideEndAllowed()); mapped.setRideThroughAllowed(rule.getRideThroughAllowed()); mapped.setMaximumSpeedKph( rule.getMaximumSpeedKph() != null ? rule.getMaximumSpeedKph() : null diff --git a/src/main/java/org/entur/lamassu/model/entities/GeofencingZones.java b/src/main/java/org/entur/lamassu/model/entities/GeofencingZones.java index a1f2efc9..49995306 100644 --- a/src/main/java/org/entur/lamassu/model/entities/GeofencingZones.java +++ b/src/main/java/org/entur/lamassu/model/entities/GeofencingZones.java @@ -148,6 +148,8 @@ public static class Rule implements Serializable { private List vehicleTypeIds; private Boolean rideAllowed; + private Boolean rideStartAllowed; + private Boolean rideEndAllowed; private Boolean rideThroughAllowed; private Integer maximumSpeedKph; private Boolean stationParking; @@ -168,6 +170,22 @@ public void setRideAllowed(Boolean rideAllowed) { this.rideAllowed = rideAllowed; } + public Boolean getRideStartAllowed() { + return rideStartAllowed; + } + + public void setRideStartAllowed(Boolean rideStartAllowed) { + this.rideStartAllowed = rideStartAllowed; + } + + public Boolean getRideEndAllowed() { + return rideEndAllowed; + } + + public void setRideEndAllowed(Boolean rideEndAllowed) { + this.rideEndAllowed = rideEndAllowed; + } + public Boolean getRideThroughAllowed() { return rideThroughAllowed; } diff --git a/src/main/resources/graphql/schema.graphqls b/src/main/resources/graphql/schema.graphqls index 9838042b..2554152f 100644 --- a/src/main/resources/graphql/schema.graphqls +++ b/src/main/resources/graphql/schema.graphqls @@ -369,7 +369,9 @@ type GeofencingZoneProperties { type GeofencingZoneRule { vehicleTypeIds: [String] - rideAllowed: Boolean! + rideAllowed: Boolean! @deprecated(reason: "Use rideStartAllowed and rideEndAllowed") + rideStartAllowed: Boolean! + rideEndAllowed: Boolean! rideThroughAllowed: Boolean! maximumSpeedKph: Int stationParking: Boolean diff --git a/src/test/java/org/entur/lamassu/integration/GraphQLIntegrationTest.java b/src/test/java/org/entur/lamassu/integration/GraphQLIntegrationTest.java index 6c98bc32..6662d390 100644 --- a/src/test/java/org/entur/lamassu/integration/GraphQLIntegrationTest.java +++ b/src/test/java/org/entur/lamassu/integration/GraphQLIntegrationTest.java @@ -125,6 +125,18 @@ public void testGeofencingZones() throws IOException { ); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals("testatlantis", response.get("$.data.geofencingZones[0].systemId")); + assertEquals( + "true", + response.get( + "$.data.geofencingZones[0].geojson.features[0].properties.rules[0].rideStartAllowed" + ) + ); + assertEquals( + "true", + response.get( + "$.data.geofencingZones[0].geojson.features[0].properties.rules[0].rideEndAllowed" + ) + ); } @Test diff --git a/src/test/resources/geofencing_zones_query.graphql b/src/test/resources/geofencing_zones_query.graphql index 952b3145..054865a9 100644 --- a/src/test/resources/geofencing_zones_query.graphql +++ b/src/test/resources/geofencing_zones_query.graphql @@ -12,10 +12,12 @@ name rules { rideAllowed + rideStartAllowed + rideEndAllowed rideThroughAllowed } } } } } -} \ No newline at end of file +}