Changeset 16442 in josm for trunk/test/functional
- Timestamp:
- 2020-05-17T15:57:55+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r15426 r16442 242 242 assertNotNull(w); 243 243 244 DataSet refer ers = new OsmServerBackreferenceReader(n).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE);245 printNumberOfPrimitives(refer ers);244 DataSet referrers = new OsmServerBackreferenceReader(n).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE); 245 printNumberOfPrimitives(referrers); 246 246 247 247 Set<Long> expectedNodeIds = new HashSet<>(); … … 260 260 } 261 261 262 assertEquals(expectedNodeIds.size(), refer ers.getNodes().size());263 assertEquals(expectedWayIds.size(), refer ers.getWays().size());264 assertEquals(expectedRelationIds.size(), refer ers.getRelations().size());265 266 for (Node node : refer ers.getNodes()) {262 assertEquals(expectedNodeIds.size(), referrers.getNodes().size()); 263 assertEquals(expectedWayIds.size(), referrers.getWays().size()); 264 assertEquals(expectedRelationIds.size(), referrers.getRelations().size()); 265 266 for (Node node : referrers.getNodes()) { 267 267 assertTrue(expectedNodeIds.contains(node.getId())); 268 268 assertFalse(node.isIncomplete()); 269 269 } 270 270 271 for (Way way : refer ers.getWays()) {271 for (Way way : referrers.getWays()) { 272 272 assertTrue(expectedWayIds.contains(way.getId())); 273 273 assertEquals(n.getReferrers().contains(way), !way.isIncomplete()); 274 274 } 275 275 276 for (Relation relation : refer ers.getRelations()) {276 for (Relation relation : referrers.getRelations()) { 277 277 assertTrue(expectedRelationIds.contains(relation.getId())); 278 278 assertFalse(relation.isIncomplete()); … … 280 280 } 281 281 282 private void printNumberOfPrimitives(DataSet refer ers) {283 System.out.println("#nodes=" + refer ers.getNodes().size() +284 " #ways=" + refer ers.getWays().size() +285 " #relations=" + refer ers.getRelations().size());282 private void printNumberOfPrimitives(DataSet referrers) { 283 System.out.println("#nodes=" + referrers.getNodes().size() + 284 " #ways=" + referrers.getWays().size() + 285 " #relations=" + referrers.getRelations().size()); 286 286 } 287 287 … … 296 296 assertNotNull(n); 297 297 298 DataSet refer ers = new OsmServerBackreferenceReader(n).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE);299 printNumberOfPrimitives(refer ers);298 DataSet referrers = new OsmServerBackreferenceReader(n).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE); 299 printNumberOfPrimitives(referrers); 300 300 301 301 Set<Long> expectedNodeIds = new HashSet<>(); … … 313 313 } 314 314 315 assertEquals(expectedNodeIds.size(), refer ers.getNodes().size());316 assertEquals(expectedWayIds.size(), refer ers.getWays().size());317 assertEquals(expectedRelationIds.size(), refer ers.getRelations().size());318 319 for (Node node : refer ers.getNodes()) {315 assertEquals(expectedNodeIds.size(), referrers.getNodes().size()); 316 assertEquals(expectedWayIds.size(), referrers.getWays().size()); 317 assertEquals(expectedRelationIds.size(), referrers.getRelations().size()); 318 319 for (Node node : referrers.getNodes()) { 320 320 assertTrue(expectedNodeIds.contains(node.getId())); 321 321 assertFalse(node.isIncomplete()); 322 322 } 323 323 324 for (Way way : refer ers.getWays()) {324 for (Way way : referrers.getWays()) { 325 325 assertTrue(expectedWayIds.contains(way.getId())); 326 326 assertFalse(way.isIncomplete()); 327 327 } 328 328 329 for (Relation relation : refer ers.getRelations()) {329 for (Relation relation : referrers.getRelations()) { 330 330 assertTrue(expectedRelationIds.contains(relation.getId())); 331 331 assertFalse(relation.isIncomplete()); … … 345 345 // 346 346 347 DataSet refer ers = new OsmServerBackreferenceReader(w).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE);348 printNumberOfPrimitives(refer ers);347 DataSet referrers = new OsmServerBackreferenceReader(w).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE); 348 printNumberOfPrimitives(referrers); 349 349 350 350 Set<Long> expectedNodeIds = new HashSet<>(); … … 360 360 } 361 361 362 assertEquals(expectedNodeIds.size(), refer ers.getNodes().size());363 assertEquals(expectedWayIds.size(), refer ers.getWays().size());364 assertEquals(expectedRelationIds.size(), refer ers.getRelations().size());365 366 for (Way w1 : refer ers.getWays()) {362 assertEquals(expectedNodeIds.size(), referrers.getNodes().size()); 363 assertEquals(expectedWayIds.size(), referrers.getWays().size()); 364 assertEquals(expectedRelationIds.size(), referrers.getRelations().size()); 365 366 for (Way w1 : referrers.getWays()) { 367 367 assertTrue(w1.isIncomplete()); 368 368 } 369 assertEquals(2, refer ers.getRelations().size()); // two relations referring to w370 371 Relation r = lookupRelation(refer ers, 0);372 assertNotNull(r); 373 assertFalse(r.isIncomplete()); 374 r = lookupRelation(refer ers, 1);369 assertEquals(2, referrers.getRelations().size()); // two relations referring to w 370 371 Relation r = lookupRelation(referrers, 0); 372 assertNotNull(r); 373 assertFalse(r.isIncomplete()); 374 r = lookupRelation(referrers, 1); 375 375 assertFalse(r.isIncomplete()); 376 376 } … … 388 388 // 389 389 390 DataSet refer ers = new OsmServerBackreferenceReader(w).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE);391 assertEquals(6, refer ers.getWays().size()); // 6 ways referred by two relations392 for (Way w1 : refer ers.getWays()) {390 DataSet referrers = new OsmServerBackreferenceReader(w).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE); 391 assertEquals(6, referrers.getWays().size()); // 6 ways referred by two relations 392 for (Way w1 : referrers.getWays()) { 393 393 assertFalse(w1.isIncomplete()); 394 394 } 395 assertEquals(2, refer ers.getRelations().size()); // two relations referring to395 assertEquals(2, referrers.getRelations().size()); // two relations referring to 396 396 Set<Long> expectedNodeIds = new HashSet<>(); 397 for (Way way : refer ers.getWays()) {397 for (Way way : referrers.getWays()) { 398 398 Way orig = (Way) ds.getPrimitiveById(way); 399 399 for (Node n : orig.getNodes()) { … … 401 401 } 402 402 } 403 assertEquals(expectedNodeIds.size(), refer ers.getNodes().size());404 for (Node n : refer ers.getNodes()) {403 assertEquals(expectedNodeIds.size(), referrers.getNodes().size()); 404 for (Node n : referrers.getNodes()) { 405 405 assertTrue(expectedNodeIds.contains(n.getId())); 406 406 } 407 407 408 Relation r = lookupRelation(refer ers, 0);409 assertNotNull(r); 410 assertFalse(r.isIncomplete()); 411 r = lookupRelation(refer ers, 1);408 Relation r = lookupRelation(referrers, 0); 409 assertNotNull(r); 410 assertFalse(r.isIncomplete()); 411 r = lookupRelation(referrers, 1); 412 412 assertFalse(r.isIncomplete()); 413 413 } … … 426 426 // 427 427 428 DataSet refer ers = new OsmServerBackreferenceReader(r).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE);429 printNumberOfPrimitives(refer ers);428 DataSet referrers = new OsmServerBackreferenceReader(r).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE); 429 printNumberOfPrimitives(referrers); 430 430 431 431 Set<Long> referringRelationsIds = new HashSet<>(); 432 Relation r6 = lookupRelation(refer ers, 6);432 Relation r6 = lookupRelation(referrers, 6); 433 433 assertNotNull(r6); 434 434 assertFalse(r6.isIncomplete()); 435 435 referringRelationsIds.add(r6.getId()); 436 Relation r7 = lookupRelation(refer ers, 7);436 Relation r7 = lookupRelation(referrers, 7); 437 437 assertNotNull(r7); 438 438 assertFalse(r7.isIncomplete()); 439 439 referringRelationsIds.add(r7.getId()); 440 Relation r8 = lookupRelation(refer ers, 8);440 Relation r8 = lookupRelation(referrers, 8); 441 441 assertNotNull(r8); 442 442 assertFalse(r8.isIncomplete()); 443 443 referringRelationsIds.add(r8.getId()); 444 Relation r9 = lookupRelation(refer ers, 9);444 Relation r9 = lookupRelation(referrers, 9); 445 445 assertNotNull(r9); 446 446 assertFalse(r9.isIncomplete()); 447 447 referringRelationsIds.add(r9.getId()); 448 448 449 for (Relation r1 : refer ers.getRelations()) {449 for (Relation r1 : referrers.getRelations()) { 450 450 if (!referringRelationsIds.contains(r1.getId())) { 451 451 assertTrue(r1.isIncomplete()); … … 478 478 } 479 479 480 assertEquals(expectedWayIds.size(), refer ers.getWays().size());481 for (Way w1 : refer ers.getWays()) {480 assertEquals(expectedWayIds.size(), referrers.getWays().size()); 481 for (Way w1 : referrers.getWays()) { 482 482 assertTrue(expectedWayIds.contains(w1.getId())); 483 483 assertTrue(w1.isIncomplete()); … … 491 491 } 492 492 } 493 assertEquals(expectedNodeIds.size(), refer ers.getNodes().size());493 assertEquals(expectedNodeIds.size(), referrers.getNodes().size()); 494 494 } 495 495 … … 544 544 // 545 545 546 DataSet refer ers = new OsmServerBackreferenceReader(r).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE);547 548 r = lookupRelation(refer ers, 6);549 assertNotNull(r); 550 assertFalse(r.isIncomplete()); 551 r = lookupRelation(refer ers, 7);552 assertNotNull(r); 553 assertFalse(r.isIncomplete()); 554 r = lookupRelation(refer ers, 8);555 assertNotNull(r); 556 assertFalse(r.isIncomplete()); 557 r = lookupRelation(refer ers, 9);546 DataSet referrers = new OsmServerBackreferenceReader(r).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE); 547 548 r = lookupRelation(referrers, 6); 549 assertNotNull(r); 550 assertFalse(r.isIncomplete()); 551 r = lookupRelation(referrers, 7); 552 assertNotNull(r); 553 assertFalse(r.isIncomplete()); 554 r = lookupRelation(referrers, 8); 555 assertNotNull(r); 556 assertFalse(r.isIncomplete()); 557 r = lookupRelation(referrers, 9); 558 558 assertNotNull(r); 559 559 assertFalse(r.isIncomplete()); … … 561 561 // all relations are fully loaded 562 562 // 563 for (Relation r1 : refer ers.getRelations()) {563 for (Relation r1 : referrers.getRelations()) { 564 564 assertFalse(r1.isIncomplete()); 565 565 } … … 590 590 } 591 591 for (long id : expectedWayIds) { 592 Way w = (Way) refer ers.getPrimitiveById(id, OsmPrimitiveType.WAY);592 Way w = (Way) referrers.getPrimitiveById(id, OsmPrimitiveType.WAY); 593 593 assertNotNull(w); 594 594 assertFalse(w.isIncomplete()); … … 601 601 } 602 602 603 assertEquals(expectedNodeIds.size(), refer ers.getNodes().size());604 for (Node n : refer ers.getNodes()) {603 assertEquals(expectedNodeIds.size(), referrers.getNodes().size()); 604 for (Node n : referrers.getNodes()) { 605 605 assertTrue(expectedNodeIds.contains(n.getId())); 606 606 }
Note:
See TracChangeset
for help on using the changeset viewer.