Removed redundant annotations
[jalview.git] / test / jalview / ext / archaeopteryx / AptxPhylogenyTreeTest.java
1 package jalview.ext.archaeopteryx;
2
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
5
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;
12
13 public class AptxPhylogenyTreeTest extends TreeViewTest
14 {
15   final Phylogeny inputTree = new Phylogeny();
16
17   final PhylogenyNode rootNode = new PhylogenyNode("root");
18
19   final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
20
21   final PhylogenyNode ancestor2Node = new PhylogenyNode("leaf 2");
22
23   final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
24
25   final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
26
27   final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
28
29   Phylogeny tree;
30
31   TreePanel treePanel;
32
33   MainFrame aptx;
34
35
36   @Override
37   @BeforeClass(alwaysRun = true)
38   public void setUpTree()
39   {
40     ancestor1Node.addAsChild(leaf1aNode);
41     ancestor1Node.addAsChild(leaf1bNode);
42     ancestor1Node.addAsChild(leaf1cNode);
43
44     rootNode.addAsChild(ancestor1Node);
45     rootNode.addAsChild(ancestor2Node);
46
47     leaf1aNode.setDistanceToParent(2);
48     leaf1bNode.setDistanceToParent(3);
49     leaf1cNode.setDistanceToParent(4);
50
51     ancestor1Node.setDistanceToParent(36);
52     ancestor2Node.setDistanceToParent(42);
53
54     inputTree.setRoot(rootNode);
55     inputTree.setRooted(true);
56
57   }
58
59   @Override
60   @BeforeClass(dependsOnMethods = { "setUpJalview", "setUpTree" })
61   public void createTreeView()
62   {
63     treeView = ArchaeopteryxInit.createInstance(inputTree);
64     aptx = (MainFrame) treeView; // pretty ugly
65     treePanel = aptx.getMainPanel().getCurrentTreePanel();
66     tree = treePanel.getPhylogeny();
67   }
68
69
70
71   @Test(groups = "Functional")
72   public void testMainPanelExists()
73   {
74     assertTrue(aptx.getMainPanel() != null);
75   }
76
77   @Test(groups = "Functional")
78   public void testTreePanelExists()
79   {
80     assertTrue(treePanel != null);
81   }
82
83   @Test(
84     groups = "Functional",
85     expectedExceptions = IllegalArgumentException.class)
86   public void testInvalidBranchName()
87   {
88     tree.getNode("I shouldn't exist");
89
90   }
91
92   @Override
93   public void testExistingBranchName()
94   {
95     tree.getNode("leaf 2");
96
97   }
98
99   @Override
100   public void testTreeLoaded()
101   {
102     assertTrue(tree != null);
103   }
104
105   @Override
106   public void testChildNodesCount()
107   {
108     assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
109
110   }
111
112   @Override
113   public void testChildToParentBranchLength()
114   {
115     assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
116
117   }
118
119   @Override
120   public void testNodeToRootBranchLength()
121   {
122     assertEquals(tree.getNode("leaf 2").getDistanceToParent(), 42.0);
123
124   }
125
126   @Override
127   public void testDistantNodeToRootBranchLength()
128   {
129     assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),
130             4.0 + 36.0);
131
132   }
133
134
135
136
137
138
139 }