JAL-1925 update source version in license
[jalview.git] / test / jalview / gui / AnnotationChooserTest.java
index 2b890d2..87b27a2 100644 (file)
@@ -1,8 +1,29 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
+ * Copyright (C) 2015 The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.gui;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
 import jalview.datamodel.AlignmentAnnotation;
@@ -25,8 +46,8 @@ import java.util.List;
 import javax.swing.JButton;
 import javax.swing.JPanel;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
 /**
  * Unit tests for AnnotationChooser
@@ -51,14 +72,18 @@ public class AnnotationChooserTest
 
   AlignFrame af;
 
-  @Before
+  @BeforeMethod(alwaysRun = true)
   public void setUp() throws IOException
   {
     // pin down annotation sort order for test
     Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS,
             SequenceAnnotationOrder.NONE.name());
+    final String TRUE = Boolean.TRUE.toString();
     Cache.applicationProperties.setProperty(
-            Preferences.SHOW_AUTOCALC_ABOVE, Boolean.TRUE.toString());
+            Preferences.SHOW_AUTOCALC_ABOVE, TRUE);
+    Cache.applicationProperties.setProperty("SHOW_QUALITY", TRUE);
+    Cache.applicationProperties.setProperty("SHOW_CONSERVATION", TRUE);
+    Cache.applicationProperties.setProperty("SHOW_IDENTITY", TRUE);
 
     AlignmentI al = new jalview.io.FormatAdapter().readFile(TEST_DATA,
             AppletFormatAdapter.PASTE, "FASTA");
@@ -80,8 +105,7 @@ public class AnnotationChooserTest
   private void addAnnotations()
   {
     Annotation an = new Annotation(2f);
-    Annotation[] anns = new Annotation[]
-    { an, an, an };
+    Annotation[] anns = new Annotation[] { an, an, an };
     AlignmentAnnotation ann0 = new AlignmentAnnotation("IUPRED", "", anns);
     AlignmentAnnotation ann1 = new AlignmentAnnotation("Beauty", "", anns);
     AlignmentAnnotation ann2 = new AlignmentAnnotation("JMol", "", anns);
@@ -102,7 +126,7 @@ public class AnnotationChooserTest
   /**
    * Test creation of panel with OK and Cancel buttons
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testBuildActionButtonsPanel()
   {
     testee = new AnnotationChooser(parentPanel);
@@ -131,7 +155,7 @@ public class AnnotationChooserTest
    * Test 'Apply to' has 3 radio buttons enabled, 'Selected Sequences' selected,
    * when there is a current selection group.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testBuildApplyToOptionsPanel_withSelectionGroup()
   {
     selectSequences(0, 2, 3);
@@ -178,7 +202,7 @@ public class AnnotationChooserTest
    * Test 'Apply to' has 1 radio button enabled, 'All Sequences' selected, when
    * there is no current selection group.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testBuildApplyToOptionsPanel_noSelectionGroup()
   {
     testee = new AnnotationChooser(parentPanel);
@@ -219,7 +243,7 @@ public class AnnotationChooserTest
   /**
    * Test Show and Hide radio buttons created, with Hide initially selected.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testBuildShowHidePanel()
   {
     testee = new AnnotationChooser(parentPanel);
@@ -257,7 +281,7 @@ public class AnnotationChooserTest
   /**
    * Test construction of panel containing two sub-panels
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testBuildShowHideOptionsPanel()
   {
     testee = new AnnotationChooser(parentPanel);
@@ -274,7 +298,7 @@ public class AnnotationChooserTest
    * Test that annotation types are (uniquely) identified.
    * 
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testGetAnnotationTypes()
   {
     selectSequences(1);
@@ -306,7 +330,7 @@ public class AnnotationChooserTest
    * We expect all annotations of that type to be set hidden. Other annotations
    * should be left visible.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testSelectType_hideForAll()
   {
     selectSequences(1, 2);
@@ -342,7 +366,7 @@ public class AnnotationChooserTest
    * We expect the annotations of that type, linked to the sequence group, to be
    * set hidden. Other annotations should be left visible.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testSelectType_hideForSelected()
   {
     selectSequences(1, 2);
@@ -379,7 +403,7 @@ public class AnnotationChooserTest
    * We expect all annotations of that type to be set visible. Other annotations
    * should be left unchanged.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testDeselectType_hideForAll()
   {
     selectSequences(1, 2);
@@ -421,7 +445,7 @@ public class AnnotationChooserTest
    * We expect the annotations of that type, linked to the sequence group, to be
    * set visible. Other annotations should be left unchanged.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testDeselectType_hideForSelected()
   {
     selectSequences(1, 2);
@@ -456,7 +480,7 @@ public class AnnotationChooserTest
    * We expect all annotations of that type to be set visible. Other annotations
    * should be left unchanged
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testSelectType_showForAll()
   {
     selectSequences(1, 2);
@@ -495,7 +519,7 @@ public class AnnotationChooserTest
    * We expect all annotations of that type, linked to the sequence group, to be
    * set visible. Other annotations should be left unchanged
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testSelectType_showForSelected()
   {
     // sequences 1 and 2 have annotations IUPred and Jmol
@@ -537,7 +561,7 @@ public class AnnotationChooserTest
    * We expect all annotations of that type to be set hidden. Other annotations
    * should be left unchanged.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testDeselectType_showForAll()
   {
     selectSequences(1, 2);
@@ -578,7 +602,7 @@ public class AnnotationChooserTest
    * We expect the annotations of that type, linked to the sequence group, to be
    * set hidden. Other annotations should be left unchanged.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testDeselectType_showForSelected()
   {
     selectSequences(1, 2);
@@ -672,7 +696,7 @@ public class AnnotationChooserTest
    * Test cases include sequences in the selection group, and others not in the
    * group.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testIsInActionScope_selectedScope()
   {
     // sequences 1 and 2 have annotations 4 and 3 respectively
@@ -698,7 +722,7 @@ public class AnnotationChooserTest
    * Test cases include sequences in the selection group, and others not in the
    * group.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testIsInActionScope_unselectedScope()
   {
     // sequences 1 and 2 have annotations 4 and 3 respectively
@@ -722,7 +746,7 @@ public class AnnotationChooserTest
   /**
    * Test that the reset method restores previous visibility flags.
    */
-  @Test
+  @Test(groups = { "Functional" })
   public void testResetOriginalState()
   {
     testee = new AnnotationChooser(parentPanel);
@@ -735,6 +759,9 @@ public class AnnotationChooserTest
       assertTrue(i + "'th sequence not visible", anns[i].visible);
     }
 
+    /*
+     * check options to hide JMol and IUPRED annotations for all sequences
+     */
     final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
     setSelected(hideCheckbox, true);
 
@@ -748,8 +775,8 @@ public class AnnotationChooserTest
     assertTrue(anns[0].visible); // Conservation
     assertTrue(anns[1].visible); // Quality
     assertTrue(anns[2].visible); // Consensus
-    assertTrue(anns[3].visible); // Beauty (not seq-related)
-    assertFalse(anns[4].visible); // IUPRED
+    assertFalse(anns[3].visible); // IUPRED
+    assertTrue(anns[4].visible); // Beauty (not seq-related)
     assertFalse(anns[5].visible); // JMol
     assertFalse(anns[6].visible); // IUPRED
     assertFalse(anns[7].visible); // JMol