Changeset 19697 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2026-11-21T17:35:19+01:00 (18 hours ago)
Author:
stoecker
Message:

fix #25045 - adapt loader to properly handle values of country code

File:
1 edited

Legend:

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

    r18799 r19697  
    44import static java.util.Collections.singleton;
    55import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
    67import static org.junit.jupiter.api.Assertions.assertNull;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
    … …  
    5152
    5253    /**
    53      * Test of {@link Territories#initializeExternalData} - nominal case
     54     * Test of {@link Territories#initializeExternalData} with ISO codes represented as arrays.
    5455     */
    5556    @Test
    56     void testTaginfoGeofabrik_nominal() {
     57    void testTaginfoGeofabrik_arrays() {
    5758        Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "/taginfo/geofabrik-index-v1-nogeom.json");
    5859        Map<String, TaginfoRegionalInstance> cache = Territories.taginfoGeofabrikCache;
    … …  
    6768        assertEquals(1, regionalTaginfo.size());
    6869        checkTaginfoInstance(regionalTaginfo.iterator().next(), singleton("AL"), "https://taginfo.geofabrik.de/europe/albania/");
     70    }
     71
     72    /**
     73     * Test of {@link Territories#initializeExternalData} with ISO codes represented as strings.
     74     */
     75    @Test
     76    void testTaginfoGeofabrik_strings() {
     77        Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "/taginfo/geofabrik-index-v1-nogeom-strings.json");
     78        Map<String, TaginfoRegionalInstance> cache = Territories.taginfoGeofabrikCache;
     79        assertEquals(3, cache.size());
     80        assertFalse(cache.containsKey("CA-AB"), "ISO3166-1 must take precedence over ISO3166-2");
     81        assertFalse(cache.containsKey(""), "Empty ISO codes must not be cached");
     82        checkTaginfoInstance(cache.get("AL"), singleton("AL"), "https://taginfo.geofabrik.de/europe/albania/");
     83        Set<String> guernseyAndJersey = new HashSet<>(Arrays.asList("GG", "JE"));
     84        checkTaginfoInstance(cache.get("GG"), guernseyAndJersey, "https://taginfo.geofabrik.de/europe/guernsey-jersey/");
     85        checkTaginfoInstance(cache.get("JE"), guernseyAndJersey, "https://taginfo.geofabrik.de/europe/guernsey-jersey/");
    6986    }
    7087
Note: See TracChangeset for help on using the changeset viewer.