Changeset 17400 in josm for trunk/test
- Timestamp:
- 2020-12-10T17:38:18+01:00 (4 years ago)
- Location:
- trunk/test
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java
r17275 r17400 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 7 8 import java.nio.file.Files; 9 import java.nio.file.Paths; 8 10 import java.util.HashMap; 9 11 import java.util.List; 10 12 13 import org.junit.jupiter.api.Test; 11 14 import org.junit.jupiter.api.extension.RegisterExtension; 12 import org.junit.jupiter.api.Test;13 15 import org.openstreetmap.josm.TestUtils; 14 16 import org.openstreetmap.josm.data.coor.EastNorth; 15 17 import org.openstreetmap.josm.data.coor.LatLon; 18 import org.openstreetmap.josm.data.osm.DataSet; 16 19 import org.openstreetmap.josm.data.osm.Node; 17 20 import org.openstreetmap.josm.data.osm.Way; 18 21 import org.openstreetmap.josm.data.osm.WaySegment; 22 import org.openstreetmap.josm.data.validation.TestError; 19 23 import org.openstreetmap.josm.data.validation.tests.CrossingWays.Boundaries; 20 24 import org.openstreetmap.josm.data.validation.tests.CrossingWays.SelfCrossing; 21 25 import org.openstreetmap.josm.data.validation.tests.CrossingWays.Ways; 26 import org.openstreetmap.josm.io.OsmReader; 22 27 import org.openstreetmap.josm.testutils.JOSMTestRules; 23 28 … … 34 39 @RegisterExtension 35 40 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 36 public JOSMTestRules rule = new JOSMTestRules().preferences() ;41 public JOSMTestRules rule = new JOSMTestRules().preferences().projection(); 37 42 38 43 private static Way newUsableWay(String tags) { … … 127 132 testMessage(601, test, "amenity=restaurant", "amenity=restaurant"); 128 133 testMessage(611, test, "building=yes", "amenity=restaurant"); 134 testMessage(611, test, "building=yes", "natural=water"); 129 135 testMessage(612, test, "building=yes", "highway=road"); 130 136 testMessage(613, test, "building=yes", "railway=rail"); … … 133 139 testMessage(620, test, "highway=road", "highway=road"); 134 140 testMessage(621, test, "highway=road", "amenity=restaurant"); 141 testMessage(621, test, "highway=road", "natural=water"); 135 142 testMessage(622, test, "highway=road", "railway=rail"); 136 143 testMessage(623, test, "highway=road", "waterway=river"); 137 144 testMessage(630, test, "railway=rail", "railway=rail"); 138 145 testMessage(631, test, "railway=rail", "amenity=restaurant"); 146 testMessage(631, test, "railway=rail", "natural=water"); 139 147 testMessage(632, test, "railway=rail", "waterway=river"); 140 148 testMessage(641, test, "landuse=residential", "amenity=restaurant"); … … 146 154 testMessage(663, test, "barrier=hedge", "railway=rail"); 147 155 testMessage(664, test, "barrier=hedge", "waterway=river"); 156 testMessage(665, test, "barrier=hedge", "natural=water"); 148 157 149 158 assertFalse(test.isPrimitiveUsable(newUsableWay("amenity=restaurant"))); … … 174 183 SelfCrossing test = new CrossingWays.SelfCrossing(); 175 184 // isPrimitiveUsable 176 assertFalse(test.isPrimitiveUsable(newUsableWay("highway=motorway")));177 assertFalse(test.isPrimitiveUsable(newUsableWay("barrier=yes")));178 assertFalse(test.isPrimitiveUsable(newUsableWay("boundary=administrative")));179 185 assertFalse(test.isPrimitiveUsable(TestUtils.newWay("amenity=restaurant"))); // Unusable (0 node) 180 assertTrue(test.isPrimitiveUsable(newUsableWay("amenity=restaurant"))); // Usable (2 nodes) 181 } 186 } 187 188 /** 189 * Various cases of crossing linear ways and areas, mainly for coverage 190 * @throws Exception if an error occurs 191 */ 192 @Test 193 void testCoverage() throws Exception { 194 DataSet ds = OsmReader.parseDataSet( 195 Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "crossingWays.osm")), null); 196 CrossingWays crossingWays = new CrossingWays.Ways(); 197 crossingWays.startTest(null); 198 crossingWays.visit(ds.allPrimitives()); 199 crossingWays.endTest(); 200 201 for (TestError e : crossingWays.getErrors()) { 202 // we don't report self crossing ways in this test 203 assertEquals(2, e.getPrimitives().size(), e.getPrimitives().toString()); 204 // see #20121: crossing water areas should not be reported 205 assertFalse(e.getPrimitives().stream().filter(Way.class::isInstance).allMatch(CrossingWays::isWaterArea)); 206 } 207 208 CrossingWays selfCrossing = new CrossingWays.SelfCrossing(); 209 selfCrossing.startTest(null); 210 selfCrossing.visit(ds.allPrimitives()); 211 selfCrossing.endTest(); 212 assertEquals(1, selfCrossing.getErrors().size()); 213 214 CrossingWays crossingBoundaries = new CrossingWays.Boundaries(); 215 crossingBoundaries.startTest(null); 216 crossingBoundaries.visit(ds.allPrimitives()); 217 crossingBoundaries.endTest(); 218 assertEquals(2, crossingBoundaries.getErrors().size()); 219 } 220 182 221 }
Note:
See TracChangeset
for help on using the changeset viewer.