Ignore:
Timestamp:
2016-11-17T23:29:10+01:00 (8 years ago)
Author:
simon04
Message:

JOSM/wikipedia: fix ISE: Duplicate key again - #josm13991

Location:
applications/editors/josm/plugins/wikipedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java

    r33066 r33070  
    216216                    final String wikidata = X_PATH.evaluateString("./@id", node);
    217217                    final String wikipedia = X_PATH.evaluateString("./sitelinks/sitelink/@title", node);
    218                     r.put(wikipedia, wikidata);
     218                    if (WIKIDATA_PATTERN.matcher(wikidata).matches()) { // non existing entries result in negative integers
     219                        r.put(wikipedia, wikidata);
     220                    }
    219221                });
    220222            }
  • applications/editors/josm/plugins/wikipedia/test/unit/org/wikipedia/WikipediaAppTest.java

    r33066 r33070  
    88import org.wikipedia.data.WikipediaEntry;
    99
    10 import java.util.ArrayList;
    1110import java.util.Arrays;
    1211import java.util.Collection;
     
    116115        assertThat(map.get("Völs, Tyrol"), is("Q278250"));
    117116        assertThat(map.get("a-non-existing-article"), nullValue());
    118         assertThat(map.size(), is(4));
     117        assertThat(map.size(), is(3));
    119118    }
    120119
     
    124123                Stream.iterate("London", x -> x).limit(100).collect(Collectors.toList()));
    125124        assertThat(map, is(Collections.singletonMap("London", "Q84")));
     125        final List<String> articles = IntStream.range(0, 200)
     126                .mapToObj(i -> "a-non-existing-article-" + i)
     127                .collect(Collectors.toList());
     128        assertTrue(WikipediaApp.getWikidataForArticles("en", articles).isEmpty());
    126129    }
    127130
Note: See TracChangeset for help on using the changeset viewer.