source: josm/trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/TaginfoActionTest.java@ 16597

Last change on this file since 16597 was 16597, checked in by simon04, 4 years ago

see #19369 - TaginfoAction.withTaginfoUrl: simplify construction of custom instances, share Consumer objects

File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.properties;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNull;
6
7import javax.swing.Action;
8
9import org.junit.Rule;
10import org.junit.Test;
11import org.openstreetmap.josm.data.osm.Tag;
12import org.openstreetmap.josm.testutils.JOSMTestRules;
13
14import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15
16public class TaginfoActionTest {
17
18 /**
19 * Setup test.
20 */
21 @Rule
22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
23 public JOSMTestRules test = new JOSMTestRules();
24
25 /**
26 * Unit test of {@link TaginfoAction#getTaginfoUrlForTag} and {@link TaginfoAction#getTaginfoUrlForRelationType}
27 */
28 @Test
29 public void testTaginfoUrls() {
30 TaginfoAction action = new TaginfoAction(() -> null, () -> null);
31 assertEquals("https://taginfo.openstreetmap.org/keys/railway", action.getTaginfoUrlForTag(new Tag("railway")));
32 assertEquals("https://taginfo.openstreetmap.org/tags/railway=tram", action.getTaginfoUrlForTag(new Tag("railway", "tram")));
33 assertEquals("https://taginfo.openstreetmap.org/relations/route", action.getTaginfoUrlForRelationType("route"));
34 }
35
36 /**
37 * Unit test of {@link TaginfoAction#toTagHistoryAction()}
38 */
39 @Test
40 public void testCustomInstance() {
41 TaginfoAction action = new TaginfoAction(() -> null, () -> null).withTaginfoUrl("example.com", "https://taginfo.example.com////");
42 assertEquals("example.com", action.getValue(Action.NAME));
43 assertEquals("https://taginfo.example.com/keys/railway", action.getTaginfoUrlForTag(new Tag("railway")));
44 }
45
46 /**
47 * Unit test of {@link TaginfoAction#toTagHistoryAction()}
48 */
49 @Test
50 public void testTagHistoryUrls() {
51 TaginfoAction action = new TaginfoAction(() -> null, () -> null).toTagHistoryAction();
52 assertEquals("https://taghistory.raifer.tech/#***/railway/", action.getTaginfoUrlForTag(new Tag("railway")));
53 assertEquals("https://taghistory.raifer.tech/#***/railway/tram", action.getTaginfoUrlForTag(new Tag("railway", "tram")));
54 assertNull(action.getTaginfoUrlForRelationType("route"));
55 }
56}
Note: See TracBrowser for help on using the repository browser.