JAL-3829 ensure tests use mocked service - proper exception for mocked 400 response
authorJim Procter <j.procter@dundee.ac.uk>
Sat, 11 Sep 2021 11:10:40 +0000 (12:10 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Sat, 11 Sep 2021 11:10:40 +0000 (12:10 +0100)
src/jalview/fts/service/pdb/PDBFTSRestClient.java
test/jalview/gui/StructureChooserTest.java

index 483bb2f..a06b0f2 100644 (file)
@@ -222,7 +222,7 @@ public class PDBFTSRestClient extends FTSRestClient implements StructureFTSRestC
         }
         break;
       case 400:
-        throw new Exception(parseJsonExceptionString(responseString));
+        throw new Exception(isMocked() ? "400 response (Mocked)" : parseJsonExceptionString(responseString));
       default:
         throw new Exception(
                 getMessageByHTTPStatusCode(responseStatus, "PDB"));
index dbe0906..23b572f 100644 (file)
@@ -30,6 +30,7 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 import jalview.fts.api.FTSData;
+import jalview.fts.core.FTSRestClient;
 import jalview.fts.core.FTSRestRequest;
 import jalview.fts.service.pdb.PDBFTSRestClient;
 import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
@@ -129,6 +130,9 @@ public class StructureChooserTest
   @Test(groups = { "Functional" })
   public void populateFilterComboBoxTest() throws InterruptedException
   {
+    TDBeaconsFTSRestClientTest.setMock();
+    PDBFTSRestClient.setMock();
+
     SequenceI[] selectedSeqs = new SequenceI[] { seq };
     StructureChooser sc = new StructureChooser(selectedSeqs, seq, null);
     sc.populateFilterComboBox(false, false);
@@ -151,6 +155,8 @@ public class StructureChooserTest
   @Test(groups = { "Network" })
   public void fetchStructuresInfoTest()
   {
+    FTSRestClient.unMock((FTSRestClient) TDBeaconsFTSRestClient.getInstance());
+    PDBFTSRestClient.unMock((FTSRestClient) PDBFTSRestClient.getInstance());
     SequenceI[] selectedSeqs = new SequenceI[] { seq };
     StructureChooser sc = new StructureChooser(selectedSeqs, seq, null);
     sc.fetchStructuresMetaData();