source: josm/trunk/test/unit/org/openstreetmap/josm/tools/Tag2LinkTest.java@ 15709

Last change on this file since 15709 was 15709, checked in by Klumbumbus, 4 years ago

see #14465 - adapt unit test to r15706

File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.List;
7
8import org.junit.Assert;
9import org.junit.Test;
10
11/**
12 * Test {@link Tag2Link}
13 */
14public class Tag2LinkTest {
15
16 List<String> links = new ArrayList<>();
17
18 void addLink(String name, String url) {
19 links.add(name + " // " + url);
20 }
21
22 void checkLinks(String... expected) {
23 Assert.assertEquals(Arrays.asList(expected), links);
24 }
25
26 /**
27 * Unit test of function {@link Tag2Link#getLinksForTag}.
28 */
29 @Test
30 public void testImageCommonsImage() {
31 Tag2Link.getLinksForTag("image", "File:Witten Brücke Gasstraße.jpg", this::addLink);
32 checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File:Witten Brücke Gasstraße.jpg");
33 }
34
35 /**
36 * Unit test of function {@link Tag2Link#getLinksForTag}.
37 */
38 @Test
39 public void testImageCommonsCategory() {
40 Tag2Link.getLinksForTag("image", "category:JOSM", this::addLink);
41 checkLinks("View category on Wikimedia Commons // https://commons.wikimedia.org/wiki/category:JOSM");
42 }
43
44 /**
45 * Unit test of function {@link Tag2Link#getLinksForTag}.
46 */
47 @Test
48 public void testBrandWikidata() {
49 Tag2Link.getLinksForTag("brand:wikidata", "Q259340", this::addLink);
50 checkLinks("View Wikidata item // https://www.wikidata.org/wiki/Q259340");
51 }
52
53 /**
54 * Unit test of function {@link Tag2Link#getLinksForTag}.
55 */
56 @Test
57 public void testArchipelagoWikidata() {
58 Tag2Link.getLinksForTag("archipelago:wikidata", "Q756987;Q756988", this::addLink);
59 checkLinks("View Wikidata item // https://www.wikidata.org/wiki/Q756987",
60 "View Wikidata item // https://www.wikidata.org/wiki/Q756988");
61 }
62
63}
Note: See TracBrowser for help on using the repository browser.