Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.gui

File AnnotationRowFilterTest.java

 

Code metrics

0
39
5
1
121
87
5
0.13
7.8
5
1

Classes

Class Line # Actions
AnnotationRowFilterTest 20 39 5 3
0.931818293.2%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    package jalview.gui;
2   
3    import static org.testng.Assert.assertEquals;
4   
5    import jalview.bin.Cache;
6    import jalview.datamodel.AlignmentAnnotation;
7    import jalview.datamodel.AlignmentI;
8    import jalview.datamodel.SequenceI;
9    import jalview.io.DataSourceType;
10    import jalview.io.FileLoader;
11   
12    import java.util.Vector;
13   
14    import org.testng.annotations.BeforeClass;
15    import org.testng.annotations.Test;
16   
17    /**
18    * Tests for methods of base class of annotation column or colour chooser
19    */
 
20    public class AnnotationRowFilterTest
21    {
22    AlignFrame af;
23   
24    private AnnotationRowFilter testee;
25   
 
26  1 toggle @BeforeClass(alwaysRun = true)
27    public void setUp()
28    {
29  1 Cache.loadProperties("test/jalview/io/testProps.jvprops");
30  1 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
31    Boolean.TRUE.toString());
32  1 Cache.applicationProperties.setProperty(
33    Preferences.SHOW_AUTOCALC_ABOVE, Boolean.TRUE.toString());
34  1 af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
35    DataSourceType.FILE);
36  1 testee = new AnnotationRowFilter(af.viewport, af.alignPanel)
37    {
 
38  0 toggle @Override
39    public void valueChanged(boolean updateAllAnnotation)
40    {
41    }
42   
 
43  0 toggle @Override
44    public void updateView()
45    {
46    }
47   
 
48  0 toggle @Override
49    public void reset()
50    {
51    }
52    };
53    }
54   
55    /**
56    * Test the method that builds the drop-down list of annotations to choose
57    * from for colour by annotation or select columns by annotation
58    */
 
59  1 toggle @Test(groups = "Functional")
60    public void testGetAnnotationItems()
61    {
62  1 AlignmentI al = af.getViewport().getAlignment();
63  1 SequenceI seq1 = al.findSequenceMatch("FER_CAPAA")[0];
64  1 SequenceI seq2 = al.findSequenceMatch("FER_BRANA")[0];
65   
66  1 AlignmentAnnotation ann1 = new AlignmentAnnotation("ann1Label", "ann1",
67    null);
68  1 al.addAnnotation(ann1);
69  1 AlignmentAnnotation ann2 = new AlignmentAnnotation("Significance",
70    "ann2", null);
71  1 al.addAnnotation(ann2);
72    /*
73    * a second Significance alignment annotation
74    */
75  1 AlignmentAnnotation ann2a = new AlignmentAnnotation("Significance",
76    "ann2", null);
77  1 al.addAnnotation(ann2a);
78   
79  1 AlignmentAnnotation ann3 = new AlignmentAnnotation("Jronn", "Jronn",
80    null);
81  1 ann3.setSequenceRef(seq1);
82  1 al.addAnnotation(ann3);
83  1 AlignmentAnnotation ann4 = new AlignmentAnnotation("Jronn", "Jronn",
84    null);
85  1 ann4.setSequenceRef(seq2);
86  1 al.addAnnotation(ann4);
87  1 AlignmentAnnotation ann5 = new AlignmentAnnotation("Jnet", "Jnet", null);
88  1 ann5.setSequenceRef(seq2);
89  1 al.addAnnotation(ann5);
90    /*
91    * a second Jnet annotation for FER_BRANA
92    */
93  1 AlignmentAnnotation ann6 = new AlignmentAnnotation("Jnet", "Jnet", null);
94  1 ann6.setSequenceRef(seq2);
95  1 al.addAnnotation(ann6);
96   
97    /*
98    * drop-down items with 'Per-sequence only' not checked
99    */
100  1 Vector<String> items = testee.getAnnotationItems(false);
101  1 assertEquals(
102    items.toString(),
103    "[Conservation, Quality, Consensus, Occupancy, ann1Label, Significance, Significance_1, Jronn_FER_CAPAA, Jronn_FER_BRANA, Jnet_FER_BRANA, Jnet_FER_BRANA_2]");
104  1 assertEquals(testee.getAnnotationMenuLabel(ann1), "ann1Label");
105  1 assertEquals(testee.getAnnotationMenuLabel(ann2), "Significance");
106  1 assertEquals(testee.getAnnotationMenuLabel(ann2a), "Significance_1");
107  1 assertEquals(testee.getAnnotationMenuLabel(ann3), "Jronn_FER_CAPAA");
108  1 assertEquals(testee.getAnnotationMenuLabel(ann4), "Jronn_FER_BRANA");
109  1 assertEquals(testee.getAnnotationMenuLabel(ann5), "Jnet_FER_BRANA");
110  1 assertEquals(testee.getAnnotationMenuLabel(ann6), "Jnet_FER_BRANA_2");
111   
112    /*
113    * drop-down items with 'Per-sequence only' checked
114    */
115  1 items = testee.getAnnotationItems(true);
116  1 assertEquals(items.toString(), "[Jronn, Jnet]");
117    // the first annotation of the type is associated with the menu item
118  1 assertEquals(testee.getAnnotationMenuLabel(ann3), "Jronn");
119  1 assertEquals(testee.getAnnotationMenuLabel(ann5), "Jnet");
120    }
121    }