JAL-3875 test case and patch to verify the query 3d beacons button is shown for prote...
authorJim Procter <j.procter@dundee.ac.uk>
Tue, 2 Nov 2021 12:10:08 +0000 (12:10 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Tue, 2 Nov 2021 12:11:46 +0000 (12:11 +0000)
src/jalview/gui/StructureChooser.java
test/jalview/gui/StructureChooserTest.java

index 09eb7af..e400b51 100644 (file)
@@ -168,7 +168,8 @@ public class StructureChooser extends GStructureChooser
       canQueryTDB = true;
       if (needCanonical)
       {
-        notQueriedTDBYet = false;
+        // triggers display of the 'Query TDB' button
+        notQueriedTDBYet = true;
       }
     }
   };
@@ -1503,4 +1504,16 @@ public class StructureChooser extends GStructureChooser
             && mainFrame.isVisible()
             && cmb_filterOption.getSelectedItem() != null;
   }
+  /**
+   * 
+   * @return true if the 3D-Beacons query button will/has been displayed
+   */
+  public boolean isCanQueryTDB() {
+         return canQueryTDB;
+  }
+
+  public boolean isNotQueriedTDBYet()
+  {
+    return notQueriedTDBYet;
+  }
 }
index a87e1c6..f183e5c 100644 (file)
@@ -58,7 +58,7 @@ public class StructureChooserTest
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
   }
 
-  Sequence seq,upSeq;
+  Sequence seq,upSeq,upSeq_nocanonical;
 
   @BeforeMethod(alwaysRun = true)
   public void setUp() throws Exception
@@ -111,9 +111,15 @@ public class StructureChooserTest
             + "GTGVHPIVVVQPDAWTEDNGFHAIGQMCEAPVVTREWVLDSVALYQCQELDTYLIPQIPHSHY\n"
             + "", 1,
 1863);
-    upSeq.createDatasetSequence();
     upSeq.setDescription("Breast cancer type 1 susceptibility protein");
+    upSeq_nocanonical = new Sequence(upSeq);
+    upSeq.createDatasetSequence();
     upSeq.addDBRef(new DBRefEntry("UNIPROT","0","P38398",null,true));
+    
+    upSeq_nocanonical.createDatasetSequence();
+    // not a canonical reference
+    upSeq_nocanonical.addDBRef(new DBRefEntry("UNIPROT","0","P38398",null,false));
+
   }
 
   @AfterMethod(alwaysRun = true)
@@ -121,6 +127,7 @@ public class StructureChooserTest
   {
     seq = null;
     upSeq=null;
+    upSeq_nocanonical=null;
   }
 
   @Test(groups = { "Functional" })
@@ -163,6 +170,20 @@ public class StructureChooserTest
 
   }
 
+  @Test(groups = { "Functional" })
+  public void displayTDBQueryTest() throws InterruptedException
+  {
+    TDBeaconsFTSRestClientTest.setMock();
+    PDBFTSRestClientTest.setMock();
+
+    SequenceI[] selectedSeqs = new SequenceI[] { upSeq_nocanonical };
+    StructureChooser sc = new StructureChooser(selectedSeqs, upSeq_nocanonical, null);
+    // mock so should be quick. Exceptions from mocked PDBFTS are expected too
+    ThreadwaitFor(500, sc);
+    
+    assertTrue(sc.isCanQueryTDB() && sc.isNotQueriedTDBYet());
+  }
+
   @Test(groups = { "Network" })
   public void fetchStructuresInfoTest()
   {