1 package jalview.ext.archaeopteryx;
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
6 import jalview.gui.JvOptionPane;
8 import org.forester.archaeopteryx.MainFrame;
9 import org.forester.archaeopteryx.TreePanel;
10 import org.forester.phylogeny.Phylogeny;
11 import org.forester.phylogeny.PhylogenyNode;
12 import org.testng.annotations.BeforeClass;
13 import org.testng.annotations.Test;
15 public class AptxPhylogenyTreeTest extends TreeViewTest
17 final Phylogeny inputTree = new Phylogeny();
19 final PhylogenyNode rootNode = new PhylogenyNode("root");
21 final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
23 final PhylogenyNode ancestor2Node = new PhylogenyNode("leaf 2");
25 final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
27 final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
29 final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
39 @BeforeClass(alwaysRun = true)
40 public void setUpTree()
42 ancestor1Node.addAsChild(leaf1aNode);
43 ancestor1Node.addAsChild(leaf1bNode);
44 ancestor1Node.addAsChild(leaf1cNode);
46 rootNode.addAsChild(ancestor1Node);
47 rootNode.addAsChild(ancestor2Node);
49 leaf1aNode.setDistanceToParent(2);
50 leaf1bNode.setDistanceToParent(3);
51 leaf1cNode.setDistanceToParent(4);
53 ancestor1Node.setDistanceToParent(36);
54 ancestor2Node.setDistanceToParent(42);
56 inputTree.setRoot(rootNode);
57 inputTree.setRooted(true);
61 @BeforeClass(dependsOnMethods = { "setUpJalview", "setUpTree" })
62 public void createTreeView()
65 treeView = ArchaeopteryxInit.createInstance(inputTree);
66 aptx = (MainFrame) treeView; // pretty ugly
67 treePanel = aptx.getMainPanel().getCurrentTreePanel();
68 tree = treePanel.getPhylogeny();
72 @BeforeClass(alwaysRun = true)
73 public void setUpJvOptionPane()
75 JvOptionPane.setInteractiveMode(false);
76 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
79 @Test(groups = "Functional")
80 public void testMainPanelExists()
82 assertTrue(aptx.getMainPanel() != null);
85 @Test(groups = "Functional")
86 public void testTreePanelExists()
88 assertTrue(aptx.getMainPanel().getCurrentTreePanel() != null);
92 @Test(groups = "Functional")
93 public void testTreeLoaded()
95 assertTrue(aptx.getMainPanel().getCurrentTreePanel()
96 .getPhylogeny() != null);
100 @Test(groups = "Functional")
101 public void testChildNodesCount()
103 assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
108 @Test(groups = "Functional")
109 public void testChildToParentBranchLength()
111 assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
116 @Test(groups = "Functional")
117 public void testNodeToRootBranchLength()
119 assertEquals(tree.getNode("leaf 2").getDistanceToParent(), 42.0);
124 @Test(groups = "Functional")
125 public void testDistantNodeToRootBranchLength()
127 assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),