Test of connectPath method, of class Place.
()
| 524 | * Test of connectPath method, of class Place. |
| 525 | */ |
| 526 | @Test |
| 527 | public void testConnectPath() { |
| 528 | System.out.println("connectPath"); |
| 529 | |
| 530 | Place instance = new Place("MyPlace", 1, 1, layer); |
| 531 | Place place1 = new Place("Another place", 1, 2, layer); |
| 532 | Place place2 = new Place("Another place", 1, 2, layer); |
| 533 | |
| 534 | assertTrue(instance.getPaths().isEmpty()); |
| 535 | |
| 536 | Path p1 = new Path(instance, "n", place1, "s"); |
| 537 | instance.connectPath(p1); |
| 538 | assertEquals(1, instance.getPaths().size()); |
| 539 | assertTrue(instance.getPaths().contains(p1)); |
| 540 | |
| 541 | Path p2 = new Path(place1, "n", instance, "s"); |
| 542 | instance.connectPath(p2); |
| 543 | assertEquals(2, instance.getPaths().size()); |
| 544 | assertTrue(instance.getPaths().contains(p1)); |
| 545 | assertTrue(instance.getPaths().contains(p2)); |
| 546 | |
| 547 | // test null |
| 548 | try { |
| 549 | instance.connectPath(null); |
| 550 | fail(); |
| 551 | } catch(RuntimeException e){ |
| 552 | // expected |
| 553 | } |
| 554 | assertEquals(2, instance.getPaths().size()); |
| 555 | |
| 556 | // test other place is null |
| 557 | Path p3 = new Path(null, "n", instance, "s"); |
| 558 | try { |
| 559 | instance.connectPath(p3); |
| 560 | fail(); |
| 561 | } catch(RuntimeException e){ |
| 562 | // expected |
| 563 | } |
| 564 | |
| 565 | // test instance not in path |
| 566 | Path p4 = new Path(place1, "n", place2, "s"); |
| 567 | try { |
| 568 | instance.connectPath(p4); |
| 569 | fail(); |
| 570 | } catch(RuntimeException e){ |
| 571 | // expected |
| 572 | } |
| 573 | |
| 574 | // test instance to instance, different exits |
| 575 | Path p5 = new Path(instance, "n", instance, "s"); |
| 576 | try { |
| 577 | instance.connectPath(p5); |
| 578 | } catch(RuntimeException e){ |
| 579 | fail(); |
| 580 | } |
| 581 | |
| 582 | // test instance to instance, same exit |
| 583 | Path p6 = new Path(instance, "n", instance, "n"); |
nothing calls this directly
no test coverage detected