JAL-3829 minimal test of additional TDB filters - not at all robust
authorJim Procter <j.procter@dundee.ac.uk>
Mon, 13 Sep 2021 15:02:25 +0000 (16:02 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Mon, 13 Sep 2021 15:02:25 +0000 (16:02 +0100)
test/jalview/gui/structurechooser/StructureChooserQuerySourceTest.java

index 414e8a7..36d7d0a 100644 (file)
@@ -25,6 +25,7 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.Vector;
 
 import org.junit.Assert;
@@ -267,11 +268,20 @@ public class StructureChooserQuerySourceTest
     // Best Alphafold Model
     // Best model (by confidence score)
     // Will also need to develop a more sophisticated filtering system
-    FilterOption opt = tdbquery.getAvailableFilterOptions(StructureChooser.VIEWS_FILTER).get(0);
+    List<FilterOption> opts = tdbquery.getAvailableFilterOptions(StructureChooser.VIEWS_FILTER);
+    FilterOption opt_singlebest = opts.get(0);
+    FilterOption opt_manybest = opts.get(1);
+    assertEquals(opt_singlebest.getValue(), ThreeDBStructureChooserQuerySource.FILTER_FIRST_BEST_COVERAGE);
+    assertEquals(opt_manybest.getValue(), ThreeDBStructureChooserQuerySource.FILTER_TDBEACONS_COVERAGE);
+    
     try {
-      upResponse = tdbquery.fetchStructuresMetaData(upSeq, tdbquery.getDocFieldPrefs().getStructureSummaryFields(),  opt, false);
+      upResponse = tdbquery.fetchStructuresMetaData(upSeq, tdbquery.getDocFieldPrefs().getStructureSummaryFields(),  opt_singlebest, false);
+      tdbquery.updateAvailableFilterOptions(StructureChooser.VIEWS_FILTER,opts,upResponse.getSearchSummary());
       // test ranking without additional PDBe data
-      FTSRestResponse firstRanked = tdbquery.selectFirstRankedQuery(upSeq, upResponse.getSearchSummary(), tdbquery.getDocFieldPrefs().getStructureSummaryFields(), opt.getValue(), false);
+      FTSRestResponse firstRanked = tdbquery.selectFirstRankedQuery(upSeq, upResponse.getSearchSummary(), tdbquery.getDocFieldPrefs().getStructureSummaryFields(), opt_singlebest.getValue(), false);
+      assertEquals(firstRanked.getNumberOfItemsFound(),1);
+      // many best response
+      upResponse = tdbquery.fetchStructuresMetaData(upSeq, tdbquery.getDocFieldPrefs().getStructureSummaryFields(),  opt_manybest, false);
       assertTrue(firstRanked.getNumberOfItemsFound()<upResponse.getNumberOfItemsFound());
       // NB Could have race condition here 
       String pdb_Query = tdbquery.buildPDBFTSQueryFor(upResponse);