Changeset 18649 in josm
- Timestamp:
- 2023-02-06T19:39:32+01:00 (22 months ago)
- Location:
- trunk
- Files:
-
- 5 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r18637 r18649 467 467 if (tr("Ignore list").equals(description)) 468 468 description = ""; 469 if (!key.matches("^ [0-9]+(_.*|$)")) {469 if (!key.matches("^-?[0-9]+(_.*|$)")) { 470 470 description = key; 471 471 key = ""; … … 480 480 // single element 481 481 entry = key + ":" + item; 482 } else if (item.matches("^ [0-9]+(_.*|)$")) {482 } else if (item.matches("^-?[0-9]+(_.*|)$")) { 483 483 // no element ids 484 484 entry = item; -
trunk/test/unit/org/openstreetmap/josm/data/validation/TestErrorTest.java
r18636 r18649 18 18 import org.junit.jupiter.params.provider.MethodSource; 19 19 import org.openstreetmap.josm.TestUtils; 20 import org.openstreetmap.josm.data.coor.LatLon; 21 import org.openstreetmap.josm.data.osm.DataSet; 22 import org.openstreetmap.josm.data.osm.Node; 20 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 24 import org.openstreetmap.josm.data.validation.tests.InternetTags; 25 import org.openstreetmap.josm.data.validation.tests.UnconnectedWays; 26 import org.openstreetmap.josm.gui.MainApplication; 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 28 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 23 29 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 30 import org.openstreetmap.josm.testutils.annotations.Projection; 24 31 25 32 /** … … 27 34 */ 28 35 @BasicPreferences 36 @Projection 29 37 class TestErrorTest { 30 38 static Stream<Arguments> testCodeCompatibility() { 31 39 return Stream.of(Arguments.of(InternetTags.class, 3301, 1166507262, false, Collections.singletonList(TestUtils.newNode("url=invalid"))), 32 Arguments.of(InternetTags.class, 3301, 1166507262, true, Collections.singletonList(TestUtils.newNode("url=invalid")))); 40 Arguments.of(InternetTags.class, 3301, 1166507262, true, Collections.singletonList(TestUtils.newNode("url=invalid"))), 41 Arguments.of(UnconnectedWays.UnconnectedHighways.class, 1311, -1765317246, true, 42 Arrays.asList(TestUtils.newWay("highway=residential", new Node(LatLon.ZERO), new Node(LatLon.NORTH_POLE)), 43 TestUtils.newWay("highway=residential", new Node(LatLon.ZERO), new Node(LatLon.SOUTH_POLE)))), 44 Arguments.of(UnconnectedWays.UnconnectedHighways.class, 1311, -1765317246, false, 45 Arrays.asList(TestUtils.newWay("highway=residential", new Node(LatLon.ZERO), new Node(LatLon.NORTH_POLE)), 46 TestUtils.newWay("highway=residential", new Node(LatLon.ZERO), new Node(LatLon.SOUTH_POLE))))); 33 47 } 34 48 … … 47 61 void testCodeCompatibility(Class<? extends Test> testClass, int originalCode, int expectedCode, 48 62 boolean switchOver, List<OsmPrimitive> primitiveCollection) throws ReflectiveOperationException { 63 // Create the data layer and add it to the layer manager -- needed if the test looks for an active dataset 64 final DataSet ds = new DataSet(); 65 primitiveCollection.forEach(ds::addPrimitiveRecursive); 66 for (OsmPrimitive primitive : ds.allPrimitives()) { 67 if (primitive.isNew()) { 68 primitive.setOsmId(-primitive.getUniqueId(), 1); 69 } 70 } 71 final OsmDataLayer layer = new OsmDataLayer(ds, "testCodeCompatibility", null); 72 MainApplication.getLayerManager().addLayer(layer); 49 73 // Ensure that this test always works 50 74 TestError.setUpdateErrorCodes(switchOver); … … 56 80 test.endTest(); 57 81 assertFalse(test.getErrors().isEmpty()); 58 assertEquals(1, test.getErrors().size()); 82 final int expectedIssues; 83 if (InternetTags.class.equals(testClass)) { 84 expectedIssues = 1; 85 } else if (UnconnectedWays.UnconnectedHighways.class.equals(testClass)) { 86 expectedIssues = 2; 87 } else { 88 expectedIssues = Integer.MIN_VALUE; 89 } 90 assertEquals(expectedIssues, test.getErrors().size()); 59 91 final TestError testError = test.getErrors().get(0); 60 92 final String ignoreGroup = testError.getIgnoreGroup(); … … 80 112 OsmValidator.clearIgnoredErrors(); 81 113 OsmValidator.addIgnoredError(ignore); 114 OsmValidator.saveIgnoredErrors(); 82 115 // Add the ignored error 83 116 assertTrue(testError.updateIgnored());
Note:
See TracChangeset
for help on using the changeset viewer.