|
28 | 28 | import java.util.Map; |
29 | 29 |
|
30 | 30 | /** |
31 | | - * Available vehicle types in station_status must exist in the system's vehicle_types file |
| 31 | + * References to vehicle types in station_status must exist in the system's vehicle_types file |
32 | 32 | */ |
33 | | -public class VehicleTypeIdsInVehicleTypesAvailableExistsInVehicleTypes implements CustomRuleSchemaPatcher { |
| 33 | +public class NoInvalidReferenceToVehicleTypesInStationStatus implements CustomRuleSchemaPatcher { |
34 | 34 |
|
35 | | - public static final String VEHICLE_TYPE_ID_SCHEMA_PATH = "$.properties.data.properties.stations.items.properties.vehicle_types_available.items.properties.vehicle_type_id"; |
| 35 | + public static final String VEHICLE_TYPES_AVAILABLE_VEHICLE_TYPE_ID_SCHEMA_PATH = "$.properties.data.properties.stations.items.properties.vehicle_types_available.items.properties.vehicle_type_id"; |
| 36 | + public static final String VEHICLE_DOCKS_AVAILABLE_VEHICLE_TYPE_IDS_SCHEMA_PATH = "$.properties.data.properties.stations.items.properties.vehicle_docks_available.items.properties.vehicle_type_ids.items"; |
36 | 37 |
|
37 | 38 | /** |
38 | | - * Adds an enum to the vehicle_type_id schema of vehicle_types_available with the vehilce type ids from vehicle_types.json |
| 39 | + * Adds an enum to the vehicle_type_id schema of vehicle_types_available and vehicle_docks_available with the vehilce type ids from vehicle_types.json |
39 | 40 | */ |
40 | 41 | @Override |
41 | 42 | public DocumentContext addRule(DocumentContext rawSchemaDocumentContext, Map<String, JSONObject> feeds) { |
42 | 43 | JSONObject vehicleTypesFeed = feeds.get("vehicle_types"); |
43 | | - JSONObject vehicleTypeIdSchema = rawSchemaDocumentContext.read(VEHICLE_TYPE_ID_SCHEMA_PATH); |
| 44 | + JSONObject vehicleTypesAvailableVehicleTypeIdSchema = rawSchemaDocumentContext.read(VEHICLE_TYPES_AVAILABLE_VEHICLE_TYPE_ID_SCHEMA_PATH); |
| 45 | + JSONObject vehicleDocksAvailableVehiecleTypeIdSchema = rawSchemaDocumentContext.read(VEHICLE_DOCKS_AVAILABLE_VEHICLE_TYPE_IDS_SCHEMA_PATH); |
44 | 46 |
|
45 | 47 | if (vehicleTypesFeed != null) { |
46 | 48 | JSONArray vehicleTypeIds = JsonPath.parse(vehicleTypesFeed).read("$.data.vehicle_types[*].vehicle_type_id"); |
47 | | - vehicleTypeIdSchema.put("enum", vehicleTypeIds); |
| 49 | + vehicleTypesAvailableVehicleTypeIdSchema.put("enum", vehicleTypeIds); |
| 50 | + vehicleDocksAvailableVehiecleTypeIdSchema.put("enum", vehicleTypeIds); |
48 | 51 | } |
49 | 52 |
|
50 | | - return rawSchemaDocumentContext.set(VEHICLE_TYPE_ID_SCHEMA_PATH, vehicleTypeIdSchema); |
| 53 | + return rawSchemaDocumentContext |
| 54 | + .set(VEHICLE_TYPES_AVAILABLE_VEHICLE_TYPE_ID_SCHEMA_PATH, vehicleTypesAvailableVehicleTypeIdSchema) |
| 55 | + .set(VEHICLE_DOCKS_AVAILABLE_VEHICLE_TYPE_IDS_SCHEMA_PATH, vehicleDocksAvailableVehiecleTypeIdSchema); |
51 | 56 | } |
52 | 57 | } |
0 commit comments