Test of connectChild method, of class Place.
()
| 684 | * Test of connectChild method, of class Place. |
| 685 | */ |
| 686 | @Test |
| 687 | public void testConnectChild() { |
| 688 | System.out.println("connectChild"); |
| 689 | |
| 690 | Layer layer2 = new Layer(world); |
| 691 | Place p1 = new Place("Child", 0, 0, layer2); |
| 692 | Place instance = new Place("MyPlace", 0, 0, layer); |
| 693 | instance.connectChild(p1); |
| 694 | // test child |
| 695 | assertEquals(1, p1.getParents().size()); |
| 696 | assertTrue(p1.getParents().contains(instance)); |
| 697 | // test parent |
| 698 | assertEquals(1, instance.getChildren().size()); |
| 699 | assertTrue(instance.getChildren().contains(p1)); |
| 700 | |
| 701 | // test with second place |
| 702 | Layer layer3 = new Layer(world); |
| 703 | Place p2 = new Place("Child", 0, 0, layer3); |
| 704 | instance.connectChild(p2); |
| 705 | // test child |
| 706 | assertEquals(1, p2.getParents().size()); |
| 707 | assertTrue(p2.getParents().contains(instance)); |
| 708 | // test parent |
| 709 | assertEquals(2, instance.getChildren().size()); |
| 710 | assertTrue(instance.getChildren().contains(p1)); |
| 711 | assertTrue(instance.getChildren().contains(p2)); |
| 712 | |
| 713 | // test null |
| 714 | try { |
| 715 | instance.connectChild(null); |
| 716 | fail(); |
| 717 | } catch(NullPointerException ex){ |
| 718 | // expected |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | /** |
| 723 | * Test of removeChild method, of class Place. |
nothing calls this directly
no test coverage detected