1 package jalview.ext.archaeopteryx;
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
6 import org.forester.archaeopteryx.MainFrame;
7 import org.forester.archaeopteryx.TreePanel;
8 import org.forester.phylogeny.Phylogeny;
9 import org.forester.phylogeny.PhylogenyNode;
10 import org.testng.annotations.BeforeClass;
11 import org.testng.annotations.Test;
13 public class AptxPhylogenyTreeTest extends TreeViewTest
15 final Phylogeny inputTree = new Phylogeny();
17 final PhylogenyNode rootNode = new PhylogenyNode("root");
19 final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
21 final PhylogenyNode ancestor2Node = new PhylogenyNode("leaf 2");
23 final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
25 final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
27 final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
37 @BeforeClass(alwaysRun = true)
38 public void setUpTree()
40 ancestor1Node.addAsChild(leaf1aNode);
41 ancestor1Node.addAsChild(leaf1bNode);
42 ancestor1Node.addAsChild(leaf1cNode);
44 rootNode.addAsChild(ancestor1Node);
45 rootNode.addAsChild(ancestor2Node);
47 leaf1aNode.setDistanceToParent(2);
48 leaf1bNode.setDistanceToParent(3);
49 leaf1cNode.setDistanceToParent(4);
51 ancestor1Node.setDistanceToParent(36);
52 ancestor2Node.setDistanceToParent(42);
54 inputTree.setRoot(rootNode);
55 inputTree.setRooted(true);
60 @BeforeClass(dependsOnMethods = { "setUpJalview", "setUpTree" })
61 public void createTreeView()
63 treeView = ArchaeopteryxInit.createInstance(inputTree);
64 aptx = (MainFrame) treeView; // pretty ugly
65 treePanel = aptx.getMainPanel().getCurrentTreePanel();
66 tree = treePanel.getPhylogeny();
71 @Test(groups = "Functional")
72 public void testMainPanelExists()
74 assertTrue(aptx.getMainPanel() != null);
77 @Test(groups = "Functional")
78 public void testTreePanelExists()
80 assertTrue(treePanel != null);
84 groups = "Functional",
85 expectedExceptions = IllegalArgumentException.class)
86 public void testInvalidBranchName()
88 tree.getNode("I shouldn't exist");
93 public void testExistingBranchName()
95 tree.getNode("leaf 2");
100 public void testTreeLoaded()
102 assertTrue(tree != null);
106 public void testChildNodesCount()
108 assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
113 public void testChildToParentBranchLength()
115 assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
120 public void testNodeToRootBranchLength()
122 assertEquals(tree.getNode("leaf 2").getDistanceToParent(), 42.0);
127 public void testDistantNodeToRootBranchLength()
129 assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),