From a55f616a9e6bcf5f0d85cf9044c78d8f51035b33 Mon Sep 17 00:00:00 2001 From: Ialokim Date: Wed, 7 Feb 2018 13:53:58 -0600 Subject: [PATCH] Adapt to navitia.io configuration (one single country provider) --- .../de/schildbach/pte/ManaguaProvider.java | 44 ---------- enabler/src/de/schildbach/pte/NetworkId.java | 2 +- ...liProvider.java => NicaraguaProvider.java} | 21 ++--- .../pte/live/NicaraguaProviderLiveTest.java | 85 +++++++++++++++++++ 4 files changed, 92 insertions(+), 60 deletions(-) delete mode 100644 enabler/src/de/schildbach/pte/ManaguaProvider.java rename enabler/src/de/schildbach/pte/{EsteliProvider.java => NicaraguaProvider.java} (62%) create mode 100644 enabler/test/de/schildbach/pte/live/NicaraguaProviderLiveTest.java diff --git a/enabler/src/de/schildbach/pte/ManaguaProvider.java b/enabler/src/de/schildbach/pte/ManaguaProvider.java deleted file mode 100644 index 4706327b3..000000000 --- a/enabler/src/de/schildbach/pte/ManaguaProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 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; - -import okhttp3.HttpUrl; - -/** - * @author Nico Alt - */ -public class ManaguaProvider extends AbstractNavitiaProvider { - private static String API_REGION = "ni-managua"; - - public ManaguaProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.MANAGUA, apiBase, authorization); - - setTimeZone("America/Managua"); - } - - public ManaguaProvider(final String authorization) { - super(NetworkId.MANAGUA, authorization); - - setTimeZone("America/Managua"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/enabler/src/de/schildbach/pte/NetworkId.java b/enabler/src/de/schildbach/pte/NetworkId.java index edb8f457d..3ef4f452c 100644 --- a/enabler/src/de/schildbach/pte/NetworkId.java +++ b/enabler/src/de/schildbach/pte/NetworkId.java @@ -91,5 +91,5 @@ public enum NetworkId { GHANA, // Nicaragua - ESTELI, MANAGUA, + NICARAGUA, } diff --git a/enabler/src/de/schildbach/pte/EsteliProvider.java b/enabler/src/de/schildbach/pte/NicaraguaProvider.java similarity index 62% rename from enabler/src/de/schildbach/pte/EsteliProvider.java rename to enabler/src/de/schildbach/pte/NicaraguaProvider.java index 70cdefa79..3ad1543f0 100644 --- a/enabler/src/de/schildbach/pte/EsteliProvider.java +++ b/enabler/src/de/schildbach/pte/NicaraguaProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * 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 @@ -17,23 +17,14 @@ package de.schildbach.pte; -import okhttp3.HttpUrl; - /** - * @author Nico Alt + * @author ialokim */ -public class EsteliProvider extends AbstractNavitiaProvider { - private static String API_REGION = "ni-esteli"; - - public EsteliProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.ESTELI, apiBase, authorization); - - setTimeZone("America/Managua"); - } - - public EsteliProvider(final String authorization) { - super(NetworkId.ESTELI, authorization); +public class NicaraguaProvider extends AbstractNavitiaProvider { + private static final String API_REGION = "ni"; + public NicaraguaProvider(final String authorization) { + super(NetworkId.NICARAGUA, authorization); setTimeZone("America/Managua"); } diff --git a/enabler/test/de/schildbach/pte/live/NicaraguaProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/NicaraguaProviderLiveTest.java new file mode 100644 index 000000000..981831cc4 --- /dev/null +++ b/enabler/test/de/schildbach/pte/live/NicaraguaProviderLiveTest.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 org.junit.Test; + +import de.schildbach.pte.NicaraguaProvider; +import de.schildbach.pte.dto.Point; + +import static org.junit.Assert.assertTrue; + +public class NicaraguaProviderLiveTest extends AbstractNavitiaProviderLiveTest { + + public NicaraguaProviderLiveTest() { + super(new NicaraguaProvider(secretProperty("navitia.authorization"))); + } + + @Test + public void nearbyStationsAddress() throws Exception { + // Managua + nearbyStationsAddress(13090080, -86356250); + } + + @Test + public void nearbyStationsAddress2() throws Exception { + // Esteli + nearbyStationsAddress(12146120, -86274660); + } + + @Test + public void nearbyStationsStation() throws Exception { + nearbyStationsStation("stop_point:MNI:SP:node3230617621"); + } + + @Test + public void nearbyStationsInvalidStation() throws Exception { + nearbyStationsInvalidStation("stop_point:MNIX:SP:node3230617621"); + } + + @Test + public void queryDeparturesEquivsFalse() throws Exception { + queryDeparturesEquivsFalse("stop_point:MNI:SP:node3230617621"); + } + + @Test + public void queryDeparturesInvalidStation() throws Exception { + queryDeparturesInvalidStation("stop_point:MNIX:SP:node3230617621"); + } + + @Test + public void suggestLocations() throws Exception { + suggestLocationsFromName("Hospital"); + } + + @Test + public void queryTripStations() throws Exception { + queryTrip("27 de Mayo", "San Miguel Arcángel"); + } + + @Test + public void queryMoreTrips() throws Exception { + queryMoreTrips("Hospital", "Super Las Segovias"); + } + + @Test + public void getArea() throws Exception { + final Point[] polygon = provider.getArea(); + assertTrue(polygon.length > 0); + } +}