source: josm/trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialogTest.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

  • Property svn:eol-style set to native
File size: 2.0 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;
5
6import java.util.ArrayList;
7import java.util.List;
8
9import org.junit.jupiter.api.extension.RegisterExtension;
10import org.junit.jupiter.api.Test;
11import org.openstreetmap.josm.data.coor.LatLon;
12import org.openstreetmap.josm.data.osm.Node;
13import org.openstreetmap.josm.data.osm.OsmPrimitive;
14import org.openstreetmap.josm.data.osm.Way;
15import org.openstreetmap.josm.testutils.JOSMTestRules;
16
17import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
18
19/**
20 * Unit tests of {@link PropertiesDialog} class.
21 */
22class PropertiesDialogTest {
23
24 /**
25 * Setup tests
26 */
27 @RegisterExtension
28 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
29 public JOSMTestRules test = new JOSMTestRules();
30
31 private static String createSearchSetting(List<OsmPrimitive> sel, boolean sameType) {
32 return PropertiesDialog.createSearchSetting("foo", sel, sameType).text;
33 }
34
35 /**
36 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12504">#12504</a>.
37 */
38 @Test
39 void testTicket12504() {
40 List<OsmPrimitive> sel = new ArrayList<>();
41 // 160 objects with foo=bar, 400 objects without foo
42 for (int i = 0; i < 160+400; i++) {
43 Node n = new Node(LatLon.ZERO);
44 if (i < 160) {
45 n.put("foo", "bar");
46 }
47 sel.add(n);
48 }
49 assertEquals("(\"foo\"=\"bar\")", createSearchSetting(sel, false));
50
51 Node n = new Node(LatLon.ZERO);
52 n.put("foo", "baz");
53 sel.add(0, n);
54
55 assertEquals("(\"foo\"=\"baz\") OR (\"foo\"=\"bar\")", createSearchSetting(sel, false));
56
57 sel.remove(0);
58
59 Way w = new Way();
60 w.put("foo", "bar");
61 sel.add(0, w);
62
63 assertEquals("(type:way \"foo\"=\"bar\") OR (type:node \"foo\"=\"bar\")", createSearchSetting(sel, true));
64 }
65}
Note: See TracBrowser for help on using the repository browser.