Merge branch 'patch/JAL-3874_newJmolAndGradleDedup' into develop
[jalview.git] / src / jalview / fts / service / threedbeacons / TDBeaconsFTSRestClient.java
index 8263b22..c05306a 100644 (file)
@@ -99,7 +99,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       String responseString = null;
 
       // Check the response status and report exception if one occurs
-      int responseStatus = isMocked() ? (mockQuery.equals(query) ? 200 : 404) : clientResponse.getStatus();
+      int responseStatus = isMocked() ? (mockQueries.containsKey(query) ? 200 : 404) : clientResponse.getStatus();
       switch (responseStatus)
       {
       // if success
@@ -110,7 +110,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
         }
         else
         {
-          responseString = isMocked() ? mockResponse: clientResponse.getEntity(String.class);
+          responseString = isMocked() ? mockQueries.get(query): clientResponse.getEntity(String.class);
         }
         break;
       case 400:
@@ -127,22 +127,23 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
     } catch (Exception e)
     {
       String exceptionMsg = e.getMessage();
-      if (exceptionMsg.contains("SocketException"))
+      if (exceptionMsg != null)
       {
-        // No internet connection
-        throw new Exception(MessageManager.getString(
-                "exception.unable_to_detect_internet_connection"));
-      }
-      else if (exceptionMsg.contains("UnknownHostException"))
-      {
-        // The server is unreachable
-        throw new Exception(MessageManager.formatMessage(
-                "exception.fts_server_unreachable", "3DB Hub"));
-      }
-      else
-      {
-        throw e;
+        if (exceptionMsg.contains("SocketException"))
+        {
+          // No internet connection
+          throw new Exception(MessageManager.getString(
+                  "exception.unable_to_detect_internet_connection"));
+        }
+        else if (exceptionMsg.contains("UnknownHostException"))
+        {
+          // The server is unreachable
+          throw new Exception(MessageManager.formatMessage(
+                  "exception.fts_server_unreachable", "3DB Hub"));
+        }
       }
+      throw e;
+      
     }
 
   }