diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java index e94b20927801ebbfce582b8035b0ef7853eef8e0..4dcb534e248e6cf1c3deaedf396faec38a57f87d 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java @@ -60,14 +60,12 @@ public class MeSHParser extends CachableInterface implements IExternalService { } @Override - public String refreshCacheQuery(Object query) throws SourceNotAvailable { - String result = null; + public Object refreshCacheQuery(Object query) throws SourceNotAvailable { + Object result = null; try { if (query instanceof String) { String identifier = (String) query; - if (identifier.startsWith("http")) { - result = getWebPageContent(identifier); - } else if (identifier.startsWith(MESH_PREFIX)) { + if (identifier.startsWith(MESH_PREFIX)) { String[] ids = identifier.split("\\:"); if (ids.length == 2) { MiriamData meshID = new MiriamData(MiriamType.MESH_2012, ids[1]); @@ -77,10 +75,10 @@ public class MeSHParser extends CachableInterface implements IExternalService { throw new InvalidArgumentException("Problematic query: \"" + query + "\""); } } else { - throw new InvalidArgumentException("Don't know what to do with string \"" + query + "\""); + result = super.refreshCacheQuery(query); } } else { - throw new InvalidArgumentException("Don't know what to do with class: " + query.getClass()); + result = super.refreshCacheQuery(query); } } catch (IOException e) { throw new SourceNotAvailable("Problem with accessing Mesh database", e); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java index 135431aab661aa86355c4cda16b6dcebf87b4589..cab9db6010db0f7cec6141e6bd089dde6e3e5bce 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java @@ -253,20 +253,12 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { } @Test(timeout = 150000) - public void testCachableInterfaceInvalidateDrug() throws Exception { - + public void testRefreshCacheForDrug() throws Exception { String query = "drug:amantadine"; - String newRes = "hello"; - cache.setCachedQuery(query, drugBankHTMLParser.getCacheType(), newRes); - cache.invalidateByQuery(query, drugBankHTMLParser.getCacheType()); - - permanentDatabaseLevelCache.waitToFinishTasks(); - String res = cache.getStringByQuery(query, drugBankHTMLParser.getCacheType()); + String res = drugBankHTMLParser.refreshCacheQuery(query); assertNotNull(res); - - assertFalse("Value wasn't refreshed from db", newRes.equals(res)); } @Test diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java index 896b49de796518f4f7185bfa5f5981e1493020a0..30d37d613f5e6eec8447aea4c803dbdb11206a1d 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java @@ -86,12 +86,6 @@ public class MeSHParserTest extends AnnotationTestFunctions { meshParser.getMeSH(null); } - @Test - public void testRefreshCacheQuery() throws Exception { - Object res = meshParser.refreshCacheQuery("http://google.pl/"); - assertNotNull(res); - } - @Test public void testGetRotenoneMesh() throws Exception { // Rotenone disease -no synonyms @@ -143,19 +137,11 @@ public class MeSHParserTest extends AnnotationTestFunctions { } @Test - public void testCachableInterfaceInvalidateChemical() throws Exception { + public void testRefreshCacheQuery() throws Exception { MiriamData meshID = new MiriamData(MiriamType.MESH_2012, "D010300"); - MeSH mesh = meshParser.getMeSH(meshID); - assertNotNull(mesh); - - cache.invalidateByQuery(meshParser.getIdentifier(meshID), meshParser.getCacheType()); - - permanentDatabaseLevelCache.waitToFinishTasks(); - - MeSH mesh2 = meshParser.getMeSH(meshID); - assertNotNull(mesh2); - assertFalse("Value wasn't refreshed from db", mesh.equals(mesh2)); + Object result = meshParser.refreshCacheQuery(meshParser.getIdentifier(meshID)); + assertNotNull(result); } @Test diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiRNAParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiRNAParserTest.java index d6d84474f98fbc089028cbc5dc58f222fe04c6f8..449885587915af66fcbe743c7c1b6ab470ca8869 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiRNAParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiRNAParserTest.java @@ -137,28 +137,6 @@ public class MiRNAParserTest extends AnnotationTestFunctions { } } - @Test(timeout = 50000) - public void testCachableInterfaceInvalidateMiRNA() throws Exception { - List<String> listIds = new ArrayList<>(); - listIds.add("gga-miR-489-3p"); - List<MiRNA> list = miRNAParser.getMiRnasByNames(listIds); - assertTrue(!list.isEmpty()); - assertEquals(1, list.get(0).getTargets().size()); - - cache.invalidateByQuery(MiRNAParser.MI_RNA_PREFIX + list.get(0).getName(), miRNAParser.getCacheType()); - - permanentDatabaseLevelCache.waitToFinishTasks(); - - listIds.clear(); - listIds.add(list.get(0).getName()); - - List<MiRNA> list2 = miRNAParser.getMiRnasByNames(listIds); - assertNotNull(list2); - assertEquals(1, list2.size()); - assertFalse("Value wasn't refreshed from db", list.get(0).equals(list2.get(0))); - assertTrue(list.get(0).getName().equals(list2.get(0).getName())); - } - @Test public void testGetMiRna() throws Exception { String mirBaseName = "hsa-miR-296-5p";