Unofficial Dart implementation of Deutsche Bahn’s construction site API
https://pub.dev/packages/db_construction_site
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.2 KiB
87 lines
3.2 KiB
import 'dart:convert';
|
|
|
|
import 'package:db_construction_site/src/models/construction_report.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
test('test if json parsing works as expected', () {
|
|
const exampleReportJsonString = '''
|
|
{
|
|
"id": "5604",
|
|
"nr": "1",
|
|
"termin": "von Montag, 27. Juli bis Sonntag, 16. August, jeweils ganztägig",
|
|
"termin_pins": "",
|
|
"termin_zeit": "",
|
|
"zusatz": "",
|
|
"headline": "Zugausfall Frankfurt-Höchst <> Frankfurt (Main) Hbf",
|
|
"headline_pins": "",
|
|
"meldung": "Die Züge der Linien RE 4 und RE 14 enden/beginnen in Frankfurt-Höchst und fallen zwischen Frankfurt-Höchst und Frankfurt (Main) Hbf aus. Als Ersatz nutzen Sie bitte die noch verkehrenden Züge in diesem Abschnitt.",
|
|
"meldung_pins": "",
|
|
"meldung_hinweis": "",
|
|
"hinweis_tabelle": "0",
|
|
"grund": "Oberleitungsarbeiten",
|
|
"von": "2020-07-27 00:00:00",
|
|
"bis": "2020-08-16 23:59:00",
|
|
"abschnitt": [
|
|
"Frankfurt-Höchst",
|
|
"Frankfurt (Main) Hbf"
|
|
],
|
|
"abschnitt_hin": "1",
|
|
"abschnitt_zurueck": "1",
|
|
"online": "1",
|
|
"last_change": "2020-06-29 09:35:03",
|
|
"termine": [
|
|
{
|
|
"datum_von": "2020-07-27",
|
|
"datum_bis": "2020-08-16",
|
|
"st_von": "00",
|
|
"min_von": "00",
|
|
"st_bis": "23",
|
|
"min_bis": "59",
|
|
"jeweils": "0",
|
|
"ganztaegig": "1",
|
|
"wochentage": []
|
|
}
|
|
],
|
|
"ics": "https://bauinfos.deutschebahn.com/docs/hessen/ical-hessen-471-5604.ics",
|
|
"infos": [
|
|
{
|
|
"TEXT": "Fahrplan Mannheim Hbf – Frankfurt (Main) Hbf 27.07. – 16.08.2020",
|
|
"URL": null,
|
|
"VERFALL": "2020-08-16 23:00:00",
|
|
"HIDDEN": "0",
|
|
"PRIORITAET": "1",
|
|
"last_change": "2020-06-02 10:25:10",
|
|
"url": "https://bauinfos.deutschebahn.com/docs/hessen/infos/471_2707-16082020_fahrplan.pdf"
|
|
},
|
|
{
|
|
"TEXT": "Plakat Oberleitungsarbeiten Frankfurt-Höchst – Frankfurt (Main) Hbf 24.07. – 17.08.2020",
|
|
"URL": null,
|
|
"VERFALL": "2020-08-19 03:00:00",
|
|
"HIDDEN": "0",
|
|
"PRIORITAET": "1",
|
|
"last_change": "2020-07-20 14:18:22",
|
|
"url": "https://bauinfos.deutschebahn.com/docs/hessen/infos/471_627_645_1_8_2407-17082020.pdf"
|
|
}
|
|
]
|
|
}
|
|
''';
|
|
Map<String, dynamic> json;
|
|
try {
|
|
json = JsonDecoder().convert(exampleReportJsonString);
|
|
assert(json != null);
|
|
} catch (e) {
|
|
print('JSON decoding failed, skipping test.');
|
|
return;
|
|
}
|
|
final connection = ConstructionReport.fromJson(json);
|
|
expect(connection.id, '5604');
|
|
expect(connection.index, 1);
|
|
expect(connection.messages, [
|
|
'Die Züge der Linien RE 4 und RE 14 enden/beginnen in Frankfurt-Höchst und fallen zwischen Frankfurt-Höchst und Frankfurt (Main) Hbf aus. Als Ersatz nutzen Sie bitte die noch verkehrenden Züge in diesem Abschnitt.'
|
|
]);
|
|
expect(connection.timeRanges.length, 1);
|
|
expect(connection.timeRanges[0].begin, connection.startDate);
|
|
expect(connection.affectedStations.length, 2);
|
|
});
|
|
}
|
|
|