Changeset 16595 in josm for trunk/test


Ignore:
Timestamp:
2020-06-11T08:40:11+02:00 (4 years ago)
Author:
simon04
Message:

Add unit test for Territories.getRegionalTaginfoUrls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTest.java

    r16182 r16595  
    99import java.util.Arrays;
    1010import java.util.HashSet;
     11import java.util.List;
    1112import java.util.Map;
    1213import java.util.Set;
    13 import java.util.TreeMap;
    1414
    1515import org.junit.Rule;
     
    3535    /**
    3636     * Tests that {@code Territories} satisfies utility class criteria.
     37     *
    3738     * @throws ReflectiveOperationException if an error occurs
    3839     */
     
    6162    @Test
    6263    public void testTaginfoGeofabrik_nominal() {
    63         Map<String, TaginfoRegionalInstance> cache = new TreeMap<>();
    64         Territories.initializeExternalData(cache, "foo", TestUtils.getTestDataRoot() + "/taginfo/geofabrik-index-v1-nogeom.json");
     64        Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "/taginfo/geofabrik-index-v1-nogeom.json");
     65        Map<String, TaginfoRegionalInstance> cache = Territories.taginfoGeofabrikCache;
    6566        assertEquals(5, cache.size());
    6667        checkTaginfoInstance(cache.get("AF"), singleton("AF"), "https://taginfo.geofabrik.de/asia/afghanistan/");
     
    7071        checkTaginfoInstance(cache.get("PS"), israelAndPalestine, "https://taginfo.geofabrik.de/asia/israel-and-palestine/");
    7172        checkTaginfoInstance(cache.get("IL"), israelAndPalestine, "https://taginfo.geofabrik.de/asia/israel-and-palestine/");
     73        List<TaginfoRegionalInstance> regionalTaginfo = Territories.getRegionalTaginfoUrls(new LatLon(41.3268733, 19.8187913));
     74        assertEquals(1, regionalTaginfo.size());
     75        checkTaginfoInstance(regionalTaginfo.iterator().next(), singleton("AL"), "https://taginfo.geofabrik.de/europe/albania/");
    7276    }
    7377
     
    8387    @Test
    8488    public void testTaginfoGeofabrik_broken() {
    85         Map<String, TaginfoRegionalInstance> cache = new TreeMap<>();
    8689        Logging.clearLastErrorAndWarnings();
    87         Territories.initializeExternalData(cache, "foo", TestUtils.getTestDataRoot() + "taginfo/geofabrik-index-v1-nogeom-broken.json");
     90        Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "taginfo/geofabrik-index-v1-nogeom-broken.json");
     91        Map<String, TaginfoRegionalInstance> cache = Territories.taginfoGeofabrikCache;
    8892        assertTrue(cache.isEmpty());
    8993        String error = Logging.getLastErrorAndWarnings().get(0);
Note: See TracChangeset for help on using the changeset viewer.