Ignore:
Timestamp:
2016-11-18T20:00:49+01:00 (8 years ago)
Author:
simon04
Message:

JOSM/wikipedia: Refactoring (wikipediaLang as field)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wikipedia/test/unit/org/wikipedia/WikipediaAppTest.java

    r33070 r33075  
    5555    @Test
    5656    public void testGetInterwikiArticles1() {
    57         final Collection<WikipediaEntry> iw = WikipediaApp.getInterwikiArticles("de", "Österreich");
     57        final Collection<WikipediaEntry> iw = WikipediaApp.forLanguage("de").getInterwikiArticles("Österreich");
    5858        assertThat(iw, hasItem(new WikipediaEntry("en", "Austria")));
    5959        assertThat(iw, hasItem(new WikipediaEntry("no", "Østerrike")));
     
    6363    @Test
    6464    public void testGetInterwikiArticles2() {
    65         final Collection<WikipediaEntry> iw = WikipediaApp.getInterwikiArticles("en", "Ampersand");
     65        final Collection<WikipediaEntry> iw = WikipediaApp.forLanguage("en").getInterwikiArticles("Ampersand");
    6666        assertThat(iw, hasItem(new WikipediaEntry("fi", "&")));
    6767    }
     
    6969    @Test
    7070    public void testGetCoordinates() throws Exception {
    71         assertThat(WikipediaApp.getCoordinateForArticle("de", "Marchreisenspitze"), is(new LatLon(47.1725, 11.30833333)));
    72         assertThat(WikipediaApp.getCoordinateForArticle("en", "Austria"), is(new LatLon(47.33333333, 13.33333333)));
    73         assertThat(WikipediaApp.getCoordinateForArticle("en", "Foobar2000"), nullValue());
     71        assertThat(WikipediaApp.forLanguage("de").getCoordinateForArticle("Marchreisenspitze"), is(new LatLon(47.1725, 11.30833333)));
     72        assertThat(WikipediaApp.forLanguage("en").getCoordinateForArticle("Austria"), is(new LatLon(47.33333333, 13.33333333)));
     73        assertThat(WikipediaApp.forLanguage("en").getCoordinateForArticle("Foobar2000"), nullValue());
    7474    }
    7575
    7676    @Test
    7777    public void testFromCoordinates() throws Exception {
    78         final List<WikipediaEntry> entries = WikipediaApp.getEntriesFromCoordinates("de",
    79                 new LatLon(52.5179786, 13.3753321), new LatLon(52.5192215, 13.3768705));
     78        final List<WikipediaEntry> entries = WikipediaApp.forLanguage("de")
     79                .getEntriesFromCoordinates(new LatLon(52.5179786, 13.3753321), new LatLon(52.5192215, 13.3768705));
    8080        final long c = entries.stream()
    8181                .filter(entry -> "Reichstagsgebäude".equals(entry.article) && "de".equals(entry.lang))
     
    9898    @Test
    9999    public void testFromCoordinatesWikidata() throws Exception {
    100         final List<WikipediaEntry> entries = WikipediaApp.getEntriesFromCoordinates("wikidata",
    101                 new LatLon(47.20, 11.30), new LatLon(47.22, 11.32));
     100        final List<WikipediaEntry> entries = WikipediaApp.forLanguage("wikidata")
     101                .getEntriesFromCoordinates(new LatLon(47.20, 11.30), new LatLon(47.22, 11.32));
    102102        final long c = entries.stream()
    103103                .map(WikidataEntry.class::cast)
     
    109109    @Test
    110110    public void testGetWikidataForArticles() throws Exception {
    111         final Map<String, String> map = WikipediaApp.getWikidataForArticles("en",
    112                 Arrays.asList("London", "Vienna", "Völs, Tyrol", "a-non-existing-article"));
     111        final Map<String, String> map = WikipediaApp.forLanguage("en")
     112                .getWikidataForArticles(Arrays.asList("London", "Vienna", "Völs, Tyrol", "a-non-existing-article"));
    113113        assertThat(map.get("London"), is("Q84"));
    114114        assertThat(map.get("Vienna"), is("Q1741"));
     
    120120    @Test
    121121    public void testTicket13991() throws Exception {
    122         final Map<String, String> map = WikipediaApp.getWikidataForArticles("en",
    123                 Stream.iterate("London", x -> x).limit(100).collect(Collectors.toList()));
     122        final Map<String, String> map = WikipediaApp.forLanguage("en")
     123                .getWikidataForArticles(Stream.iterate("London", x -> x).limit(100).collect(Collectors.toList()));
    124124        assertThat(map, is(Collections.singletonMap("London", "Q84")));
    125125        final List<String> articles = IntStream.range(0, 200)
    126126                .mapToObj(i -> "a-non-existing-article-" + i)
    127127                .collect(Collectors.toList());
    128         assertTrue(WikipediaApp.getWikidataForArticles("en", articles).isEmpty());
     128        assertTrue(WikipediaApp.forLanguage("en").getWikidataForArticles(articles).isEmpty());
    129129    }
    130130
     
    154154        final WikipediaEntry entry2 = new WikipediaEntry("en", "London");
    155155        final WikipediaEntry entry3 = new WikipediaEntry("en", "a-non-existing-article");
    156         WikipediaApp.updateWIWOSMStatus("en", Arrays.asList(entry1, entry2, entry3));
     156        WikipediaApp.forLanguage("en").updateWIWOSMStatus(Arrays.asList(entry1, entry2, entry3));
    157157        assertThat(entry1.getWiwosmStatus(), is(true));
    158158        assertThat(entry2.getWiwosmStatus(), is(true));
     
    162162    @Test
    163163    public void testCategoriesForPrefix() throws Exception {
    164         final List<String> categories = WikipediaApp.getCategoriesForPrefix("de", "Gemeinde in Öster");
     164        final List<String> categories = WikipediaApp.forLanguage("de").getCategoriesForPrefix("Gemeinde in Öster");
    165165        assertTrue(categories.contains("Gemeinde in Österreich"));
    166166    }
Note: See TracChangeset for help on using the changeset viewer.