X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Ffts%2Fcore%2FFTSRestClient.java;h=b1cfc539d704dda709ec9ffccaf624c3c9ae6127;hb=dfa42fba9774fe4659d234661c1e0d2c17980505;hp=b262f64a1922b9bb896ef455926f6b1329e89dfc;hpb=29538a14c49fcd47f00f1d2fff51f357b8e0388e;p=jalview.git diff --git a/src/jalview/fts/core/FTSRestClient.java b/src/jalview/fts/core/FTSRestClient.java index b262f64..b1cfc53 100644 --- a/src/jalview/fts/core/FTSRestClient.java +++ b/src/jalview/fts/core/FTSRestClient.java @@ -26,6 +26,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Objects; import jalview.fts.api.FTSDataColumnI; @@ -58,9 +59,7 @@ public abstract class FTSRestClient implements FTSRestClientI private int defaultResponsePageSize = 100; - protected String mockQuery = null; - - protected String mockResponse = null; + protected HashMap mockQueries = null; protected FTSRestClient() { @@ -433,10 +432,14 @@ public abstract class FTSRestClient implements FTSRestClientI "Couldn't find data column with name : " + nameOrCode); } - public static void createMockFTSRestClient(FTSRestClient instance,String workingQuery, - String jsonResponse) + /** + * + * @param instance + * @param mocks {{working query, working response}, ...} + */ + public static void createMockFTSRestClient(FTSRestClient instance,String[][] mocks) { - instance.setMock(workingQuery,jsonResponse); + instance.setMock(mocks); } @Override @@ -494,8 +497,7 @@ public abstract class FTSRestClient implements FTSRestClientI public static void unMock(FTSRestClient instance) { - instance.mockQuery =null; - instance.mockResponse =null; + instance.mockQueries=null; } protected String getResourceFile(String fileName) @@ -522,15 +524,22 @@ public abstract class FTSRestClient implements FTSRestClientI return defaultResponsePageSize; } - protected void setMock(String workingQuery, String jsonResponse) + protected void setMock(String[][] mocks) { - mockQuery=workingQuery; - mockResponse = jsonResponse; + if (mocks==null) { + mockQueries=null; + return; + } + mockQueries=new HashMap(); + for (String[] mock:mocks) + { + mockQueries.put(mock[0],mock[1]); + } } protected boolean isMocked() { - return mockQuery != null && mockResponse!=null; + return mockQueries!=null; } @Override