Skip to content
Snippets Groups Projects
Commit 6ae474a1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

validation of miriam types is not cached

parent 1743d0f2
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!507Resolve "Add ClinicalTrials.gov to handled MIRIAMs"
Pipeline #7478 passed
...@@ -181,12 +181,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna ...@@ -181,12 +181,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna
* otherwise * otherwise
*/ */
public boolean isValid(String uri) { public boolean isValid(String uri) {
String query = VALID_URI_PREFIX + uri;
String val = getCacheValue(query);
if (val != null) {
return "true".equalsIgnoreCase(val);
}
boolean result = false; boolean result = false;
String name = getLink().getName(uri); String name = getLink().getName(uri);
if (name == null) { if (name == null) {
...@@ -194,7 +188,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna ...@@ -194,7 +188,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna
} else { } else {
result = !name.isEmpty(); result = !name.isEmpty();
} }
setCacheValue(query, "" + result);
return result; return result;
} }
......
...@@ -6,9 +6,9 @@ import static org.junit.Assert.assertNotNull; ...@@ -6,9 +6,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.io.IOException; import java.io.IOException;
...@@ -138,7 +138,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions { ...@@ -138,7 +138,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
try { try {
for (MiriamType mt : MiriamType.values()) { for (MiriamType mt : MiriamType.values()) {
if (!MiriamType.UNKNOWN.equals(mt)) { if (!MiriamType.UNKNOWN.equals(mt)) {
assertTrue("Invalid URI for MiriamType: " + mt, miriamConnector.isValid(mt.getUris().get(0))); String uri = mt.getUris().get(0);
assertTrue("Invalid URI (" + uri + ") for MiriamType: " + mt, miriamConnector.isValid(mt.getUris().get(0)));
} }
} }
...@@ -231,7 +232,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions { ...@@ -231,7 +232,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
try { try {
miriamConnector.setCache(null); miriamConnector.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException()); when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenThrow(new IOException());
miriamConnector.setWebPageDownloader(mockDownloader); miriamConnector.setWebPageDownloader(mockDownloader);
miriamConnector.getUrlString2(TaxonomyBackend.HUMAN_TAXONOMY); miriamConnector.getUrlString2(TaxonomyBackend.HUMAN_TAXONOMY);
...@@ -252,7 +254,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions { ...@@ -252,7 +254,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
WebPageDownloader downloader = miriamConnector.getWebPageDownloader(); WebPageDownloader downloader = miriamConnector.getWebPageDownloader();
try { try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException()); when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenThrow(new IOException());
miriamConnector.setWebPageDownloader(mockDownloader); miriamConnector.setWebPageDownloader(mockDownloader);
miriamConnector.refreshCacheQuery("http://google.pl/"); miriamConnector.refreshCacheQuery("http://google.pl/");
fail("Exception expected"); fail("Exception expected");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment