JAL-2326 added setup method for JvOptionPane in all Jalveiw test classes to enable...
[jalview.git] / test / jalview / io / AnnotatedPDBFileInputTest.java
index 4b10ab8..86fc236 100644 (file)
@@ -31,10 +31,12 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
+import jalview.gui.JvOptionPane;
+import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
 
 import java.io.File;
 
-import org.junit.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
@@ -43,6 +45,13 @@ import org.testng.annotations.Test;
 public class AnnotatedPDBFileInputTest
 {
 
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
   AlignmentI al;
 
   String pdbId;
@@ -66,6 +75,9 @@ public class AnnotatedPDBFileInputTest
     al = af.getViewport().getAlignment();
     pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
             .get(0).getId();
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    // StructureImportSettings
+    // .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
   }
 
   @Test(groups = { "Functional" })
@@ -81,8 +93,8 @@ public class AnnotatedPDBFileInputTest
     {
       for (int q = p + 1; q < avec.length; q++)
       {
-        Assert.assertNotEquals("Found a duplicate annotation row "
-                + avec[p].label, avec[p], avec[q]);
+        assertTrue("Found a duplicate annotation row " + avec[p].label,
+                avec[p] != avec[q]);
       }
     }
   }
@@ -97,7 +109,11 @@ public class AnnotatedPDBFileInputTest
       {
 
         System.out.println("CalcId: " + aa.getCalcId());
-        assertTrue(MCview.PDBfile.isCalcIdForFile(aa, pdbId));
+        if (StructureImportSettings.getDefaultPDBFileParser().equals(
+                StructureParser.JALVIEW_PARSER))
+        {
+          assertTrue(MCview.PDBfile.isCalcIdForFile(aa, pdbId));
+        }
       }
     }
   }
@@ -181,7 +197,7 @@ public class AnnotatedPDBFileInputTest
   /**
    * @throws java.lang.Exception
    */
-  @AfterClass
+  @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
     jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
@@ -213,8 +229,8 @@ public class AnnotatedPDBFileInputTest
         sq = sq.getDatasetSequence();
       }
       assertNotNull(sq.getAllPDBEntries());
-      assertEquals("Expected only one PDB ID",
-              sq.getAllPDBEntries().size(), 1);
+      assertEquals("Expected only one PDB ID", 1, sq.getAllPDBEntries()
+              .size());
       for (PDBEntry pdbentry : sq.getAllPDBEntries())
       {
         System.err.println("PDB Entry " + pdbentry.getId() + " "