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

Last change on this file since 17275 was 17275, checked in by Don-vip, 3 years ago

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

File size: 2.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.properties;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertNull;
6
7import javax.swing.Action;
8
9import org.junit.jupiter.api.Test;
10import org.junit.jupiter.api.extension.RegisterExtension;
11import org.openstreetmap.josm.data.osm.Tag;
12import org.openstreetmap.josm.testutils.JOSMTestRules;
13
14import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15
16class TaginfoActionTest {
17
18 /**
19 * Setup test.
20 */
21 @RegisterExtension
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 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/tags/addr%3Acity=Bassum%3ACity",
34 action.getTaginfoUrlForTag(new Tag("addr:city", "Bassum:City")));
35 assertEquals("https://taginfo.openstreetmap.org/relations/route", action.getTaginfoUrlForRelationType("route"));
36 }
37
38 /**
39 * Unit test of {@link TaginfoAction#toTagHistoryAction()}
40 */
41 @Test
42 void testCustomInstance() {
43 TaginfoAction action = new TaginfoAction(() -> null, () -> null).withTaginfoUrl("example.com", "https://taginfo.example.com////");
44 assertEquals("example.com", action.getValue(Action.NAME));
45 assertEquals("https://taginfo.example.com/keys/railway", action.getTaginfoUrlForTag(new Tag("railway")));
46 }
47
48 /**
49 * Unit test of {@link TaginfoAction#toTagHistoryAction()}
50 */
51 @Test
52 void testTagHistoryUrls() {
53 TaginfoAction action = new TaginfoAction(() -> null, () -> null).toTagHistoryAction();
54 assertEquals("https://taghistory.raifer.tech/#***/railway/", action.getTaginfoUrlForTag(new Tag("railway")));
55 assertEquals("https://taghistory.raifer.tech/#***/railway/tram", action.getTaginfoUrlForTag(new Tag("railway", "tram")));
56 assertEquals("https://taghistory.raifer.tech/#***/addr:city/Bassum:City",
57 action.getTaginfoUrlForTag(new Tag("addr:city", "Bassum:City")));
58 assertNull(action.getTaginfoUrlForRelationType("route"));
59 }
60}
Note: See TracBrowser for help on using the repository browser.