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

Merge branch '580-add-clinicaltrials-gov-to-handled-miriams' into 'master'

Resolve "Add ClinicalTrials.gov to handled MIRIAMs"

Closes #580

See merge request !507
parents 5544953e 6ae474a1
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 #7489 failed
......@@ -181,12 +181,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna
* otherwise
*/
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;
String name = getLink().getName(uri);
if (name == null) {
......@@ -194,7 +188,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna
} else {
result = !name.isEmpty();
}
setCacheValue(query, "" + result);
return result;
}
......
......@@ -6,9 +6,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
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.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
import java.io.IOException;
......@@ -138,7 +138,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
try {
for (MiriamType mt : MiriamType.values()) {
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 {
try {
miriamConnector.setCache(null);
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.getUrlString2(TaxonomyBackend.HUMAN_TAXONOMY);
......@@ -252,7 +254,8 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
WebPageDownloader downloader = miriamConnector.getWebPageDownloader();
try {
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.refreshCacheQuery("http://google.pl/");
fail("Exception expected");
......
......@@ -105,6 +105,11 @@ public enum MiriamType {
new String[] { "urn:miriam:chembl.target" },
new Class<?>[] { Protein.class, Complex.class }, "MIR:00000085"),
CLINICAL_TRIALS_GOV("ClinicalTrials.gov",
"https://clinicaltrials.gov/",
new String[] { "urn:miriam:clinicaltrials" },
new Class<?>[] { }, "MIR:00000137"),
/**
* Clusters of Orthologous Groups: https://www.ncbi.nlm.nih.gov/COG/.
*/
......
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