Skip to content

Commit

Permalink
Deprecate fields with "bike" in the name, add new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
testower committed Jun 4, 2024
1 parent 9d7c3f8 commit b3ac5cf
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public Station mapStation(
? stationStatus.getNumVehiclesAvailable()
: null
);
station.setNumVehiclesAvailable(
stationStatus.getNumVehiclesAvailable() != null
? stationStatus.getNumVehiclesAvailable()
: null
);
station.setVehicleTypesAvailable(
stationStatus.getVehicleTypesAvailable() != null
? mapVehicleTypesAvailable(
Expand All @@ -162,6 +167,11 @@ public Station mapStation(
? stationStatus.getNumVehiclesDisabled()
: null
);
station.setNumVehiclesDisabled(
stationStatus.getNumVehiclesDisabled() != null
? stationStatus.getNumVehiclesDisabled()
: null
);
station.setNumDocksAvailable(
stationStatus.getNumDocksAvailable() != null
? stationStatus.getNumDocksAvailable()
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/entur/lamassu/model/entities/Station.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ public class Station implements LocationEntity {
private Boolean isChargingStation;
private RentalUris rentalUris;
private Integer numBikesAvailable;
private Integer numVehiclesAvailable;
private List<VehicleTypeAvailability> vehicleTypesAvailable;
private Integer numBikesDisabled;
private Integer numVehiclesDisabled;
private Integer numDocksAvailable;
private List<VehicleDocksAvailability> vehicleDocksAvailable;
private Integer numDocksDisabled;
Expand Down Expand Up @@ -236,6 +238,14 @@ public void setNumBikesAvailable(Integer numBikesAvailable) {
this.numBikesAvailable = numBikesAvailable;
}

public Integer getNumVehiclesAvailable() {
return numVehiclesAvailable;
}

public void setNumVehiclesAvailable(Integer numVehiclesAvailable) {
this.numVehiclesAvailable = numVehiclesAvailable;
}

public List<VehicleTypeAvailability> getVehicleTypesAvailable() {
return vehicleTypesAvailable;
}
Expand All @@ -254,6 +264,14 @@ public void setNumBikesDisabled(Integer numBikesDisabled) {
this.numBikesDisabled = numBikesDisabled;
}

public Integer getNumVehiclesDisabled() {
return numVehiclesDisabled;
}

public void setNumVehiclesDisabled(Integer numVehiclesDisabled) {
this.numVehiclesDisabled = numVehiclesDisabled;
}

public Integer getNumDocksAvailable() {
return numDocksAvailable;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ type Station {
isValetStation: Boolean
isChargingStation: Boolean
rentalUris: RentalUris
numBikesAvailable: Int!
numBikesAvailable: Int! @deprecated(reason: "Use numVehiclesAvailable")
numVehiclesAvailable: Int!
vehicleTypesAvailable: [VehicleTypeAvailability]
numBikesDisabled: Int
numBikesDisabled: Int @deprecated(reason: "Use numVehiclesDisabled")
numVehiclesDisabled: Int
numDocksAvailable: Int
vehicleDocksAvailable: [VehicleDocksAvailability]
numDocksDisabled: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public void testStationByIdQuery() throws IOException {
assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals("TST:Station:1", response.get("$.data.station.id"));
assertEquals("2", response.get("$.data.station.vehicleDocksAvailable[0].count"));
assertEquals("1", response.get("$.data.station.numVehiclesAvailable"));
assertEquals("2", response.get("$.data.station.numVehiclesDisabled"));
}

@Test
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/station_by_id_query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
address
capacity
numBikesAvailable
numVehiclesAvailable
numVehiclesDisabled
vehicleTypesAvailable {
vehicleType {
formFactor
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/v2/station_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"count": 1
}],
"num_bikes_available": 1,
"num_bikes_disabled": 2,
"vehicle_types_available": [{
"vehicle_type_id": "TST:VehicleType:Scooter",
"count": 1
Expand Down Expand Up @@ -51,4 +52,4 @@
}
]
}
}
}

0 comments on commit b3ac5cf

Please sign in to comment.