Changeset 17429 in josm for trunk/test
- Timestamp:
- 2020-12-30T11:52:34+01:00 (4 years ago)
- Location:
- trunk/test
- Files:
-
- 7 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java
r17408 r17429 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertNull; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; 8 9 … … 45 46 @RegisterExtension 46 47 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 47 public JOSMTestRules test = new JOSMTestRules().projection().main().preferences() ;48 public JOSMTestRules test = new JOSMTestRules().projection().main().preferences().mapStyles(); 48 49 49 50 private static Map<String, String> getRefToRoleMap(Relation relation) { … … 214 215 assertEquals(1, ds.getWays().stream().filter(w -> w.hasTag("building", "yes")).count()); 215 216 } 217 218 /** 219 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/20325">Bug #20325</a>. 220 * @throws Exception if an error occurs 221 */ 222 @Test 223 void testTicket20325() throws Exception { 224 DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(20325, "data.osm"), null); 225 assertEquals(1, ds.getRelations().size()); 226 Relation mp = ds.getRelations().iterator().next(); 227 assertFalse(ds.getRelations().iterator().next().hasTag("landuse", "farmland")); 228 assertEquals(1, ds.getWays().stream().filter(w -> w.hasTag("landuse", "farmland")).count()); 229 Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), mp); 230 assertNotNull(cmd); 231 cmd.a.executeCommand(); 232 assertEquals(1, ds.getRelations().size()); 233 assertTrue(ds.getRelations().iterator().next().hasTag("landuse", "farmland")); 234 assertEquals(0, ds.getWays().stream().filter(w -> w.hasTag("landuse", "farmland")).count()); 235 cmd.a.undoCommand(); 236 assertEquals(1, ds.getRelations().size()); 237 assertFalse(ds.getRelations().iterator().next().hasTag("landuse", "farmland")); 238 assertEquals(1, ds.getWays().stream().filter(w -> w.hasTag("landuse", "farmland")).count()); 239 } 240 241 /** 242 * Coverage test for <a href="https://josm.openstreetmap.de/ticket/20325">Bug #20325</a>. 243 * New relation, no update needed, no command should be produced. 244 * @throws Exception if an error occurs 245 */ 246 @Test 247 void testTicket20325New() throws Exception { 248 DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(20325, "no-change-new.osm"), null); 249 assertEquals(1, ds.getRelations().size()); 250 Relation mp = ds.getRelations().iterator().next(); 251 Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), mp); 252 assertNull(cmd); 253 } 254 255 /** 256 * Coverage test for <a href="https://josm.openstreetmap.de/ticket/20325">Bug #20325</a>. 257 * Old relation, no update needed, no command should be produced. 258 * @throws Exception if an error occurs 259 */ 260 @Test 261 void testTicket20325Old() throws Exception { 262 DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(20325, "no-change-old.osm"), null); 263 assertEquals(1, ds.getRelations().size()); 264 Relation mp = ds.getRelations().iterator().next(); 265 Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), mp); 266 assertNull(cmd); 267 } 268 269 /** 270 * Coverage test for <a href="https://josm.openstreetmap.de/ticket/20325">Bug #20325</a>. 271 * Relation cannot be updated but produces warnings. Doesn't test that a popup was shown. 272 * @throws Exception if an error occurs 273 */ 274 @Test 275 void testTicket20325Invalid() throws Exception { 276 DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(20325, "invalid-new-upldate.osm"), null); 277 assertEquals(1, ds.getRelations().size()); 278 Relation mp = ds.getRelations().iterator().next(); 279 Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), mp); 280 assertNull(cmd); 281 } 282 283 /** 284 * Coverage test for <a href="https://josm.openstreetmap.de/ticket/20325">Bug #20325</a>. 285 * Relation needs no updates but produces warnings. Doesn't test that a popup was shown. 286 * @throws Exception if an error occurs 287 */ 288 @Test 289 void testTicket20325NoUpdateWarning() throws Exception { 290 DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(20325, "update-no-command-warning.osm"), null); 291 assertEquals(1, ds.getRelations().size()); 292 Relation mp = ds.getRelations().iterator().next(); 293 Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), mp); 294 assertNull(cmd); 295 } 296 216 297 }
Note:
See TracChangeset
for help on using the changeset viewer.