JAL-3626 from JAL-3253-applet Cache applicationProperties made private
[jalview.git] / test / jalview / ws / PDBSequenceFetcherTest.java
index ba90dd8..9992137 100644 (file)
@@ -57,12 +57,12 @@ public class PDBSequenceFetcherTest
   {
     Cache.loadProperties("test/jalview/io/testProps.jvprops");
     // ensure 'add annotation from structure' is selected
-    Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
+    Cache.setPropertyNoSave("STRUCT_FROM_PDB",
             Boolean.TRUE.toString());
-    Cache.applicationProperties.setProperty("ADD_SS_ANN",
+    Cache.setPropertyNoSave("ADD_SS_ANN",
             Boolean.TRUE.toString());
 
-    sf = new SequenceFetcher(false);
+    sf = new SequenceFetcher();
   }
 
   /**
@@ -76,7 +76,7 @@ public class PDBSequenceFetcherTest
   @Test(groups = { "Network" }, enabled = true)
   public void testRnaSeqRetrieve() throws Exception
   {
-    Cache.applicationProperties.setProperty("PDB_DOWNLOAD_FORMAT", "PDB");
+    Cache.setPropertyNoSave("PDB_DOWNLOAD_FORMAT", "PDB");
     List<DbSourceProxy> sps = sf.getSourceProxy("PDB");
     AlignmentI response = sps.get(0).getSequenceRecords("2GIS");
     assertTrue(response != null);
@@ -132,6 +132,7 @@ public class PDBSequenceFetcherTest
   private void testRetrieveProteinSeqFromPDB() throws Exception
   {
     List<DbSourceProxy> sps = sf.getSourceProxy("PDB");
+    StringBuilder errors = new StringBuilder();
     for (TestRetrieveObject str : toRetrieve)
     {
       AlignmentI response = sps.get(0).getSequenceRecords(str.id);
@@ -146,21 +147,24 @@ public class PDBSequenceFetcherTest
                 sq.getAllPDBEntries().size() > 0);
         // FIXME: should test that all residues extracted as sequences from
         // chains in structure have a mapping to data in the structure
-        StringBuilder errors = new StringBuilder();
         List<SequenceFeature> prev = null;
         int lastp = -1;
-        for (int rs = sq.getStart(); rs < sq.getStart()
-                + sq.getLength(); rs++)
+        for (int col = 1; col <= sq.getLength(); col++)
         {
-          List<SequenceFeature> sf = sq.findFeatures(rs, rs, "RESNUM");
+          List<SequenceFeature> sf = sq.findFeatures(col, col, "RESNUM");
           if (sf.size() != 1)
           {
             errors.append(
-                    "Expected feature at " + rs + ": saw " + sf.size());
+                    str.id + ": " +
+                            "Expected one feature at column (position): "
+                            + (col - 1)
+                            + " (" + sq.findPosition(col - 1) + ")"
+                            + ": saw "
+                            + sf.size());
             errors.append("\n");
             if (prev != null)
             {
-              errors.append("Last Feature was at " + lastp + ": "
+              errors.append("Last Feature was at position " + lastp + ": "
                       + prev.get(0).toString());
               errors.append("\n");
             }
@@ -168,14 +172,14 @@ public class PDBSequenceFetcherTest
           else
           {
             prev = sf;
-            lastp = rs;
+            lastp = sq.findPosition(col - 1);
           }
         }
-        if (errors.length() > 0)
-        {
-          Assert.fail(errors.toString());
-        }
       }
     }
+    if (errors.length() > 0)
+    {
+      Assert.fail(errors.toString());
+    }
   }
 }