Skip to content

Commit 4b71057

Browse files
committed
Add validation for 3.0-RC2
1 parent 7ff74b6 commit 4b71057

File tree

16 files changed

+869
-2
lines changed

16 files changed

+869
-2
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
*
3+
*
4+
* * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by
5+
* * the European Commission - subsequent versions of the EUPL (the "Licence");
6+
* * You may not use this work except in compliance with the Licence.
7+
* * You may obtain a copy of the Licence at:
8+
* *
9+
* * https://joinup.ec.europa.eu/software/page/eupl
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the Licence is distributed on an "AS IS" basis,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the Licence for the specific language governing permissions and
15+
* * limitations under the Licence.
16+
*
17+
*/
18+
19+
package org.entur.gbfs.validation.validator.versions;
20+
21+
import org.entur.gbfs.validation.validator.rules.NoMissingCurrentRangeMetersInVehicleStatusForMotorizedVehicles;
22+
import org.entur.gbfs.validation.validator.rules.CustomRuleSchemaPatcher;
23+
import org.entur.gbfs.validation.validator.rules.NoInvalidReferenceToPricingPlansInVehicleTypes;
24+
import org.entur.gbfs.validation.validator.rules.NoMissingStoreUriInSystemInformation;
25+
import org.entur.gbfs.validation.validator.rules.NoMissingVehicleTypeIdInVehicleStatusWhenVehicleTypesExist;
26+
import org.entur.gbfs.validation.validator.rules.NoInvalidReferenceToVehicleTypesInStationStatus;
27+
import org.entur.gbfs.validation.validator.rules.NoMissingVehicleTypesAvailableWhenVehicleTypesExists;
28+
29+
import java.util.Arrays;
30+
import java.util.List;
31+
import java.util.Map;
32+
33+
public class Version30_RC2 extends AbstractVersion {
34+
public static final String VERSION = "3.0-RC2";
35+
36+
private static final List<String> feeds = Arrays.asList(
37+
"gbfs",
38+
"gbfs_versions",
39+
"system_information",
40+
"vehicle_types",
41+
"station_information",
42+
"station_status",
43+
"vehicle_status",
44+
"manifest",
45+
"system_regions",
46+
"system_pricing_plans",
47+
"system_alerts",
48+
"geofencing_zones"
49+
);
50+
51+
private static final Map<String, List<CustomRuleSchemaPatcher>> customRules = Map.of(
52+
"vehicle_types", List.of(
53+
new NoInvalidReferenceToPricingPlansInVehicleTypes()
54+
),
55+
"station_status", List.of(
56+
new NoInvalidReferenceToVehicleTypesInStationStatus(),
57+
new NoMissingVehicleTypesAvailableWhenVehicleTypesExists()
58+
),
59+
"vehicle_status", List.of(
60+
new NoMissingVehicleTypeIdInVehicleStatusWhenVehicleTypesExist("vehicle_status"),
61+
new NoMissingCurrentRangeMetersInVehicleStatusForMotorizedVehicles("vehicle_status")
62+
),
63+
"system_information", List.of(
64+
new NoMissingStoreUriInSystemInformation("vehicle_status")
65+
)
66+
);
67+
68+
protected Version30_RC2() {
69+
super(VERSION, feeds, customRules);
70+
}
71+
72+
@Override
73+
public boolean isFileRequired(String file) {
74+
return super.isFileRequired(file) || "gbfs".equals(file);
75+
}
76+
}

src/main/java/org/entur/gbfs/validation/validator/versions/VersionFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ public static Version createVersion(String version) {
3535
return new Version22();
3636
case "2.3":
3737
return new Version23();
38-
case "3.0":
3938
case "3.0-RC":
4039
return new Version30_RC();
40+
case "3.0":
41+
case "3.0-RC2":
42+
return new Version30_RC2();
4143
default:
4244
throw new UnsupportedOperationException("Version not implemented");
4345
}

src/test/java/org/entur/gbfs/validation/validator/GbfsJsonValidatorTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,32 @@ void testSuccessfulV3_0_RCValidation() {
192192
Assertions.assertEquals(0, result.getSummary().getErrorsCount());
193193
}
194194

195+
@Test
196+
void testSuccessfulV3_0_RC2Validation() {
197+
GbfsJsonValidator validator = new GbfsJsonValidator();
198+
199+
Map<String, InputStream> deliveryMap = new HashMap<>();
200+
deliveryMap.put("gbfs", getFixture("fixtures/v3.0-RC2/gbfs.json"));
201+
deliveryMap.put("gbfs_versions", getFixture("fixtures/v3.0-RC2/gbfs_versions.json"));
202+
deliveryMap.put("system_information", getFixture("fixtures/v3.0-RC2/system_information.json"));
203+
deliveryMap.put("vehicle_types", getFixture("fixtures/v3.0-RC2/vehicle_types.json"));
204+
deliveryMap.put("station_information", getFixture("fixtures/v3.0-RC2/station_information.json"));
205+
deliveryMap.put("station_status", getFixture("fixtures/v3.0-RC2/station_status.json"));
206+
deliveryMap.put("vehicle_status", getFixture("fixtures/v3.0-RC2/vehicle_status.json"));
207+
deliveryMap.put("manifest", getFixture("fixtures/v3.0-RC2/manifest.json"));
208+
deliveryMap.put("system_regions", getFixture("fixtures/v3.0-RC2/system_regions.json"));
209+
deliveryMap.put("system_pricing_plans", getFixture("fixtures/v3.0-RC2/system_pricing_plans.json"));
210+
deliveryMap.put("system_alerts", getFixture("fixtures/v3.0-RC2/system_alerts.json"));
211+
deliveryMap.put("geofencing_zones", getFixture("fixtures/v3.0-RC2/geofencing_zones.json"));
212+
213+
ValidationResult result = validator.validate(deliveryMap);
214+
215+
printErrors("3.0-RC2", result);
216+
217+
Assertions.assertEquals("3.0-RC2", result.getSummary().getVersion());
218+
Assertions.assertEquals(0, result.getSummary().getErrorsCount());
219+
}
220+
195221
@Test
196222
void testFailed2_3Validation() {
197223
GbfsJsonValidator validator = new GbfsJsonValidator();

src/test/resources/fixtures/v3.0-RC/gbfs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"last_updated": 1640887163,
33
"ttl": 0,
4-
"version": "3.0",
4+
"version": "3.0-RC",
55
"data": {
66
"feeds": [
77
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"last_updated": "2024-03-21T09:25:53.343Z",
3+
"ttl": 0,
4+
"version": "3.0-RC2",
5+
"data": {
6+
"feeds": [
7+
{
8+
"name": "system_information",
9+
"url": "https://www.example.com/gbfs/1/system_information"
10+
},
11+
{
12+
"name": "station_information",
13+
"url": "https://www.example.com/gbfs/1/station_information"
14+
}
15+
]
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"last_updated": "2024-03-21T09:25:53.343Z",
3+
"ttl": 0,
4+
"version": "3.0-RC2",
5+
"data": {
6+
"versions": [
7+
{
8+
"version": "2.0",
9+
"url": "https://www.example.com/gbfs/2/gbfs"
10+
},
11+
{
12+
"version": "3.0-RC",
13+
"url": "https://www.example.com/gbfs/3/gbfs"
14+
}
15+
]
16+
}
17+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"last_updated": "2024-03-21T09:25:53.343Z",
3+
"ttl": 60,
4+
"version": "3.0-RC2",
5+
"data": {
6+
"geofencing_zones": {
7+
"type": "FeatureCollection",
8+
"features": [
9+
{
10+
"type": "Feature",
11+
"geometry": {
12+
"type": "MultiPolygon",
13+
"coordinates": [
14+
[
15+
[
16+
[
17+
-122.578067,
18+
45.562982
19+
],
20+
[
21+
-122.661838,
22+
45.562741
23+
],
24+
[
25+
-122.661151,
26+
45.504542
27+
],
28+
[
29+
-122.578926,
30+
45.5046625
31+
],
32+
[
33+
-122.578067,
34+
45.562982
35+
]
36+
]
37+
],
38+
[
39+
[
40+
[
41+
-122.650680,
42+
45.548197
43+
],
44+
[
45+
-122.650852,
46+
45.534731
47+
],
48+
[
49+
-122.630939,
50+
45.535212
51+
],
52+
[
53+
-122.630424,
54+
45.548197
55+
],
56+
[
57+
-122.650680,
58+
45.548197
59+
]
60+
]
61+
]
62+
]
63+
},
64+
"properties": {
65+
"name": [
66+
{
67+
"text": "NE 24th/NE Knott",
68+
"language": "en"
69+
}
70+
],
71+
"start": "2024-03-21T09:25:53.343Z",
72+
"end": "2024-03-21T09:25:53.343Z",
73+
"rules": [
74+
{
75+
"vehicle_type_id": [
76+
"moped1",
77+
"car1"
78+
],
79+
"ride_start_allowed": false,
80+
"ride_end_allowed": false,
81+
"ride_through_allowed": true,
82+
"maximum_speed_kph": 10,
83+
"station_parking": true
84+
}
85+
]
86+
}
87+
}
88+
]
89+
},
90+
"global_rules": [
91+
{
92+
"ride_start_allowed": false,
93+
"ride_end_allowed": false,
94+
"ride_through_allowed": true
95+
}
96+
]
97+
}
98+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"last_updated": "2024-03-21T09:25:53.343Z",
3+
"ttl":0,
4+
"version":"3.0-RC2",
5+
"data":{
6+
"datasets":[
7+
{
8+
"system_id":"example_berlin",
9+
"versions":[
10+
{
11+
"version":"2.0",
12+
"url":"https://berlin.example.com/gbfs/2/gbfs"
13+
},
14+
{
15+
"version":"3.0-RC2",
16+
"url":"https://berlin.example.com/gbfs/3/gbfs"
17+
}
18+
]
19+
},
20+
{
21+
"system_id":"example_paris",
22+
"versions":[
23+
{
24+
"version":"2.0",
25+
"url":"https://paris.example.com/gbfs/2/gbfs"
26+
},
27+
{
28+
"version":"3.0-RC2",
29+
"url":"https://paris.example.com/gbfs/3/gbfs"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"last_updated": "2024-03-21T09:25:53.343Z",
3+
"ttl": 0,
4+
"version": "3.0-RC2",
5+
"data": {
6+
"stations": [
7+
{
8+
"station_id": "pga",
9+
"name": [
10+
{
11+
"text": "Parking garage A",
12+
"language": "en"
13+
}
14+
],
15+
"lat": 12.345678,
16+
"lon": 45.678901,
17+
"station_opening_hours": "Su-Th 05:00-22:00; Fr-Sa 05:00-01:00",
18+
"parking_type": "underground_parking",
19+
"parking_hoop": false,
20+
"contact_phone": "+33109874321",
21+
"is_charging_station": true,
22+
"vehicle_type_dock_capacity": [
23+
{
24+
"vehicle_type_id": "abc123",
25+
"count": 7
26+
},
27+
{
28+
"vehicle_type_id": "def456",
29+
"count": 0
30+
}
31+
]
32+
},
33+
{
34+
"station_id": "station12",
35+
"name": [
36+
{
37+
"text": "SE Belmont & SE 10th",
38+
"language": "en"
39+
}
40+
],
41+
"lat": 45.516445,
42+
"lon": -122.655775,
43+
"is_valet_station": false,
44+
"is_virtual_station": true,
45+
"is_charging_station": false,
46+
"station_area": {
47+
"type": "MultiPolygon",
48+
"coordinates": [
49+
[
50+
[
51+
[
52+
-122.655775,
53+
45.516445
54+
],
55+
[
56+
-122.655705,
57+
45.516445
58+
],
59+
[
60+
-122.655705,
61+
45.516495
62+
],
63+
[
64+
-122.655775,
65+
45.516495
66+
],
67+
[
68+
-122.655775,
69+
45.516445
70+
]
71+
]
72+
]
73+
]
74+
},
75+
"capacity": 16,
76+
"vehicle_type_area_capacity": [
77+
{
78+
"vehicle_type_id": "abc123",
79+
"count": 7
80+
},
81+
{
82+
"vehicle_type_id": "def456",
83+
"count": 8
84+
}
85+
]
86+
}
87+
]
88+
}
89+
}

0 commit comments

Comments
 (0)