Changeset 18961 in josm for trunk/test/unit/org
- Timestamp:
- 2024-01-30T10:28:35+01:00 (9 months ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java
r18870 r18961 10 10 import java.util.HashMap; 11 11 import java.util.List; 12 import java.util.stream.Collectors; 12 13 13 14 import org.junit.jupiter.api.Test; … … 17 18 import org.openstreetmap.josm.data.osm.DataSet; 18 19 import org.openstreetmap.josm.data.osm.Node; 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 21 import org.openstreetmap.josm.data.osm.Way; 20 22 import org.openstreetmap.josm.data.osm.WaySegment; … … 23 25 import org.openstreetmap.josm.data.validation.tests.CrossingWays.SelfCrossing; 24 26 import org.openstreetmap.josm.data.validation.tests.CrossingWays.Ways; 27 import org.openstreetmap.josm.gui.MainApplication; 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 25 29 import org.openstreetmap.josm.io.OsmReader; 26 30 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; … … 200 204 crossingWays.endTest(); 201 205 206 assertEquals(109, crossingWays.getErrors().size()); 202 207 for (TestError e : crossingWays.getErrors()) { 203 208 // we don't report self crossing ways in this test … … 220 225 } 221 226 227 /** 228 * Check if partial selection find crossings with unselected objects. 229 * @throws Exception if an error occurs 230 */ 231 @Test 232 void testPartial() throws Exception { 233 234 DataSet ds = OsmReader.parseDataSet( 235 Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "crossingWays.osm")), null); 236 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null)); 237 238 CrossingWays crossingWays = new CrossingWays.Ways(); 239 List<OsmPrimitive> partialSelection = ds.getWays().stream().filter(w -> w.hasTag("testsel", "horizontal")) 240 .collect(Collectors.toList()); 241 242 crossingWays.setPartialSelection(true); 243 crossingWays.startTest(null); 244 crossingWays.visit(partialSelection); 245 crossingWays.endTest(); 246 247 assertEquals(109, crossingWays.getErrors().size()); 248 for (TestError e : crossingWays.getErrors()) { 249 // we don't report self crossing ways in this test 250 assertEquals(2, e.getPrimitives().size(), e.getPrimitives().toString()); 251 // see #20121: crossing water areas should not be reported 252 assertFalse(e.getPrimitives().stream().filter(Way.class::isInstance).allMatch(CrossingWays::isWaterArea)); 253 } 254 255 CrossingWays crossingBoundaries = new CrossingWays.Boundaries(); 256 crossingBoundaries.setPartialSelection(true); 257 crossingBoundaries.startTest(null); 258 crossingBoundaries.visit(ds.allPrimitives()); 259 crossingBoundaries.endTest(); 260 assertEquals(2, crossingBoundaries.getErrors().size()); 261 } 222 262 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DuplicateWayTest.java
r18853 r18961 35 35 private static void doTest(int code, String tags1, String tags2, boolean fixable) { 36 36 performTest(code, buildDataSet(tags1, tags2), fixable); 37 performPartialTest(code, buildDataSet(tags1, tags2), fixable); 37 38 } 38 39 39 40 private static void performTest(int code, DataSet ds, boolean fixable) { 41 TEST.setPartialSelection(false); 40 42 TEST.startTest(NullProgressMonitor.INSTANCE); 41 43 TEST.visit(ds.allPrimitives()); 44 TEST.endTest(); 45 46 assertEquals(1, TEST.getErrors().size()); 47 TestError error = TEST.getErrors().iterator().next(); 48 assertEquals(code, error.getCode()); 49 assertEquals(fixable, error.isFixable()); 50 } 51 52 private static void performPartialTest(int code, DataSet ds, boolean fixable) { 53 ds.setSelected(ds.getWays().iterator().next()); 54 TEST.setPartialSelection(true); 55 TEST.startTest(NullProgressMonitor.INSTANCE); 56 TEST.visit(ds.getSelectedWays().iterator().next()); 42 57 TEST.endTest(); 43 58
Note:
See TracChangeset
for help on using the changeset viewer.