1 package jalview.ext.archaeopteryx;
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
6 import jalview.bin.Jalview;
7 import jalview.gui.Desktop;
8 import jalview.gui.JvOptionPane;
10 import org.forester.archaeopteryx.MainFrame;
11 import org.forester.archaeopteryx.TreePanel;
12 import org.forester.phylogeny.Phylogeny;
13 import org.forester.phylogeny.PhylogenyNode;
14 import org.testng.annotations.BeforeClass;
15 import org.testng.annotations.Test;
17 public class AptxPhylogenyTreeTest
19 final Phylogeny inputTree = new Phylogeny();
21 final PhylogenyNode rootNode = new PhylogenyNode("root");
23 final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
25 final PhylogenyNode ancestor2Node = new PhylogenyNode("ancestor 2");
27 final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
29 final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
31 final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
41 @BeforeClass(alwaysRun = true)
42 public void setUpTree()
44 ancestor1Node.addAsChild(leaf1aNode);
45 ancestor1Node.addAsChild(leaf1bNode);
46 ancestor1Node.addAsChild(leaf1cNode);
48 rootNode.addAsChild(ancestor1Node);
49 rootNode.addAsChild(ancestor2Node);
51 leaf1aNode.setDistanceToParent(2);
52 leaf1bNode.setDistanceToParent(3);
53 leaf1cNode.setDistanceToParent(4);
55 ancestor1Node.setDistanceToParent(36);
56 ancestor2Node.setDistanceToParent(42);
58 inputTree.setRoot(rootNode);
59 inputTree.setRooted(true);
63 @BeforeClass(dependsOnMethods = { "setUpTree" })
64 public void setUpJalview()
66 String[] args = new String[0];
68 aptx = ArchaeopteryxInit.createInstance(inputTree);
70 treePanel = aptx.getMainPanel().getCurrentTreePanel();
71 tree = treePanel.getPhylogeny();
75 @BeforeClass(alwaysRun = true)
76 public void setUpJvOptionPane()
78 JvOptionPane.setInteractiveMode(false);
79 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
82 @Test(groups = "Functional")
83 public void testAptxExists()
85 assertTrue(aptx != null);
89 @Test(groups = "Functional")
90 public void testAptxBoundToJalview()
92 assertTrue(aptx.getTopLevelAncestor() instanceof Desktop);
95 @Test(groups = "Functional")
96 public void testShowingAptx()
98 assertTrue(aptx.isShowing());
102 @Test(groups = "Functional")
103 public void testMainPanelExists()
105 assertTrue(aptx.getMainPanel() != null);
108 @Test(groups = "Functional")
109 public void testTreePanelExists()
111 assertTrue(aptx.getMainPanel().getCurrentTreePanel() != null);
114 @Test(groups = "Functional")
115 public void testTreeLoaded()
117 assertTrue(aptx.getMainPanel().getCurrentTreePanel() != null);
120 @Test(groups = "Functional")
121 public void testChildNodesCount()
123 assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
127 @Test(groups = "Functional")
128 public void testCorrectLeafToParentBranchLength()
130 assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
134 @Test(groups = "Functional")
135 public void testCorrectAncestorLeafToRootBranchLength()
137 assertEquals(tree.getNode("ancestor 2").getDistanceToParent(), 42.0);
141 @Test(groups = "Functional")
142 public void testCorrectLeafToRootBranchLength()
144 assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),