From 446e2d4ead774db0743ae5183c6ec5db3af16bd2 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 5 Dec 2017 12:58:59 -0200 Subject: [PATCH] Navitia: Add Spain provider. --- enabler/src/de/schildbach/pte/NetworkId.java | 3 + .../src/de/schildbach/pte/SpainProvider.java | 32 +++++++ .../pte/live/SpainProviderLiveTest.java | 85 +++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 enabler/src/de/schildbach/pte/SpainProvider.java create mode 100644 enabler/test/de/schildbach/pte/live/SpainProviderLiveTest.java diff --git a/enabler/src/de/schildbach/pte/NetworkId.java b/enabler/src/de/schildbach/pte/NetworkId.java index 38eca908..4001b842 100644 --- a/enabler/src/de/schildbach/pte/NetworkId.java +++ b/enabler/src/de/schildbach/pte/NetworkId.java @@ -36,6 +36,9 @@ public enum NetworkId { // France PARIS, FRANCESOUTHWEST, FRANCESOUTHEAST, FRANCENORTHWEST, FRANCENORTHEAST, + // Spain + SPAIN, + // Belgium SNCB, diff --git a/enabler/src/de/schildbach/pte/SpainProvider.java b/enabler/src/de/schildbach/pte/SpainProvider.java new file mode 100644 index 00000000..7b0a2081 --- /dev/null +++ b/enabler/src/de/schildbach/pte/SpainProvider.java @@ -0,0 +1,32 @@ +/* + * Copyright 2014-2015 the original author or authors. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.schildbach.pte; + +public class SpainProvider extends AbstractNavitiaProvider { + private static final String API_REGION = "es"; + + public SpainProvider(final String authorization) { + super(NetworkId.SPAIN, authorization); + setTimeZone("Europe/Spain"); + } + + @Override + public String region() { + return API_REGION; + } +} diff --git a/enabler/test/de/schildbach/pte/live/SpainProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/SpainProviderLiveTest.java new file mode 100644 index 00000000..fc4ab547 --- /dev/null +++ b/enabler/test/de/schildbach/pte/live/SpainProviderLiveTest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2015-2016 the original author or authors. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.schildbach.pte.live; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import de.schildbach.pte.SpainProvider; +import de.schildbach.pte.dto.Point; + +public class SpainProviderLiveTest extends AbstractNavitiaProviderLiveTest { + + public SpainProviderLiveTest() { + super(new SpainProvider(secretProperty("navitia.authorization"))); + } + + @Test + public void nearbyStationsAddress() throws Exception { + // Valencia + nearbyStationsAddress(39473600, -371100); + } + + @Test + public void nearbyStationsAddress2() throws Exception { + // Madrid + nearbyStationsAddress(40410400, -3702400); + } + + @Test + public void nearbyStationsStation() throws Exception { + nearbyStationsStation("stop_point:E38:SP:2223"); + } + + @Test + public void nearbyStationsInvalidStation() throws Exception { + nearbyStationsInvalidStation("stop_point:EX38:SP:2223"); + } + + @Test + public void queryDeparturesEquivsFalse() throws Exception { + queryDeparturesEquivsFalse("stop_point:E38:SP:2223"); + } + + @Test + public void queryDeparturesInvalidStation() throws Exception { + queryDeparturesInvalidStation("stop_point:OWX:SP:6911"); + } + + @Test + public void suggestLocations() throws Exception { + suggestLocationsFromName("Turia"); + } + + @Test + public void queryTripStations() throws Exception { + queryTrip("Benimaclet", "Nou d'Octubre"); + } + + @Test + public void queryMoreTrips() throws Exception { + queryMoreTrips("Valencia Sud", "Faitanar"); + } + + @Test + public void getArea() throws Exception { + final Point[] polygon = provider.getArea(); + assertTrue(polygon.length > 0); + } +}