From 876d4a91fbe3c15d7cc7cf54ee477a79ce16a706 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sat, 11 Sep 2021 12:10:40 +0100 Subject: [PATCH] JAL-3829 ensure tests use mocked service - proper exception for mocked 400 response --- src/jalview/fts/service/pdb/PDBFTSRestClient.java | 2 +- test/jalview/gui/StructureChooserTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/jalview/fts/service/pdb/PDBFTSRestClient.java b/src/jalview/fts/service/pdb/PDBFTSRestClient.java index 483bb2f..a06b0f2 100644 --- a/src/jalview/fts/service/pdb/PDBFTSRestClient.java +++ b/src/jalview/fts/service/pdb/PDBFTSRestClient.java @@ -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")); diff --git a/test/jalview/gui/StructureChooserTest.java b/test/jalview/gui/StructureChooserTest.java index dbe0906..23b572f 100644 --- a/test/jalview/gui/StructureChooserTest.java +++ b/test/jalview/gui/StructureChooserTest.java @@ -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(); -- 1.7.10.2