Commit 6eb5553e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch...

Merge branch '489-allow-to-control-the-background-and-font-of-areas-drawn-from-text-areas-in-celldesigner-layers' into 'master'

Resolve "Allow to control the background and font of areas drawn from text areas in CellDesigner "layers""

Closes #489

See merge request !423
parents d77743c1 b4133849
Pipeline #6584 passed with stage
in 7 minutes and 30 seconds
......@@ -208,7 +208,7 @@
<!-- mockito used for testing -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
......@@ -20,6 +21,7 @@ import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.NotOLE2FileException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
......@@ -250,35 +252,55 @@ public class MiRNAParser extends CachableInterface implements IExternalService {
*/
private InputStream getSourceInputStream() throws IOException {
if (this.sourceInputStream == null) {
this.sourceInputStream = new ByteArrayOutputStream();
if (!bigFileCache.isCached(URL_SOURCE_DATABASE)) {
try {
bigFileCache.downloadFile(URL_SOURCE_DATABASE, false, new IProgressUpdater() {
@Override
public void setProgress(double progress) {
}
});
} catch (URISyntaxException e) {
throw new IOException("Problem with downloading file: " + URL_SOURCE_DATABASE, e);
}
downloadSourceFile();
}
String filename = bigFileCache.getAbsolutePathForFile(URL_SOURCE_DATABASE);
byte[] buffer = new byte[BUFFER_SIZE];
int len;
InputStream stream = new FileInputStream(new File(filename));
this.sourceInputStream = downloadedFileToInputStream(filename);
//if downloaded file is corrupted download it again
try {
while ((len = stream.read(buffer)) > -1) {
this.sourceInputStream.write(buffer, 0, len);
}
} finally {
stream.close();
NPOIFSFileSystem element = new NPOIFSFileSystem(new ByteArrayInputStream(sourceInputStream.toByteArray()));
element.close();
} catch (NotOLE2FileException e) {
bigFileCache.removeFile(URL_SOURCE_DATABASE);
downloadSourceFile();
this.sourceInputStream = downloadedFileToInputStream(filename);
}
this.sourceInputStream.flush();
}
return new ByteArrayInputStream(sourceInputStream.toByteArray());
}
private ByteArrayOutputStream downloadedFileToInputStream(String filename) throws FileNotFoundException, IOException {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
int len;
InputStream stream = new FileInputStream(new File(filename));
try {
while ((len = stream.read(buffer)) > -1) {
result.write(buffer, 0, len);
}
} finally {
stream.close();
}
result.flush();
return result;
}
private void downloadSourceFile() throws IOException {
try {
bigFileCache.downloadFile(URL_SOURCE_DATABASE, false, new IProgressUpdater() {
@Override
public void setProgress(double progress) {
}
});
} catch (URISyntaxException e) {
throw new IOException("Problem with downloading file: " + URL_SOURCE_DATABASE, e);
}
}
/**
* @param originalNames
* names of miRNAs
......
......@@ -55,7 +55,7 @@ public class PubmedParser extends CachableInterface implements IExternalService
/**
* Version of the remote API that is supported by this connecting class.
*/
static final String SUPPORTED_VERSION = "6.0.2";
static final String SUPPORTED_VERSION = "6.0.3";
static final String API_URL = "https://www.ebi.ac.uk/europepmc/webservices/rest/";
......@@ -295,9 +295,9 @@ public class PubmedParser extends CachableInterface implements IExternalService
/**
* Returns current version of the pmc API.
*
* @return version of the api to which this class is connected
* @return version of the API to which this class is connected
* @throws PubmedSearchException
* thrown when there is a problem with accessing external databes
* thrown when there is a problem with accessing external database
*/
public String getApiVersion() throws PubmedSearchException {
try {
......
......@@ -162,7 +162,6 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
LiteEntityList entities = client.getLiteEntity(name, SearchCategory.CHEBI_NAME, MAX_SEARCH_RESULTS_FROM_CHEBI_API,
StarsCategory.ALL);
List<LiteEntity> resultList = entities.getListElement();
for (LiteEntity liteEntity : resultList) {
Entity entity = client.getCompleteEntity(liteEntity.getChebiId());
String chebiName = entity.getChebiAsciiName();
......@@ -187,6 +186,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
}
entities = client.getLiteEntity(name, SearchCategory.ALL, MAX_SEARCH_RESULTS_FROM_CHEBI_API, StarsCategory.ALL);
resultList = entities.getListElement();
logger.debug(resultList);
for (LiteEntity liteEntity : resultList) {
Entity entity = client.getCompleteEntity(liteEntity.getChebiId());
for (DataItem dataItem : entity.getFormulae()) {
......@@ -426,7 +426,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
* thrown when there is a problem with accessing information from
* external chebi database
*/
private ChebiWebServiceClient getClient() throws ChebiSearchException {
ChebiWebServiceClient getClient() throws ChebiSearchException {
if (client == null) {
try {
client = new ChebiWebServiceClient();
......@@ -504,4 +504,5 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
void setClient(ChebiWebServiceClient client) {
this.client = client;
}
}
......@@ -6,6 +6,7 @@ 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.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
......@@ -288,7 +289,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("invalid xml");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("invalid xml");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetFromId(new MiriamData(MiriamType.CHEMBL_TARGET, "water"));
fail("Exception expected");
......@@ -310,7 +311,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("invalid xml");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("invalid xml");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.findDrug("test");
fail("Exception expected");
......@@ -332,7 +333,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetFromId(new MiriamData(MiriamType.CHEMBL_TARGET, "water"));
fail("Exception expected");
......@@ -394,7 +395,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("<target><unk/></target>");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("<target><unk/></target>");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetFromId(new MiriamData(MiriamType.CHEMBL_TARGET, "water"));
assertEquals(1, getWarnings().size());
......@@ -413,7 +414,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString()))
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenReturn("<target><target_components><target_component/></target_components></target>");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetFromId(new MiriamData(MiriamType.CHEMBL_TARGET, "water"));
......@@ -433,7 +434,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString()))
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenReturn("<target><target_chembl_id>inv id</target_chembl_id></target>");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetFromId(new MiriamData(MiriamType.CHEMBL_TARGET, "water"));
......@@ -829,7 +830,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
// simulate problem with downloading
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.refreshCacheQuery("http://google.pl/");
fail("Exception expected");
......@@ -853,7 +854,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
// simulate problem with downloading
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getDrugsByChemblTarget(new MiriamData());
......@@ -879,7 +880,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
// simulate problem with downloading
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getDrugsByChemblTarget(new MiriamData());
......@@ -907,7 +908,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
// simulate problem with downloading
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.refreshCacheQuery(query);
fail("Exception expected");
......@@ -936,7 +937,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = chemblParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.DOWN, chemblParser.getServiceStatus().getStatus());
} catch (Exception e) {
......@@ -952,7 +953,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = chemblParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString()))
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenReturn("<response><molecules/></response>");
chemblParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.CHANGED, chemblParser.getServiceStatus().getStatus());
......@@ -971,7 +972,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
// valid xml but with empty data
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("<response><molecules>"
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("<response><molecules>"
+ "<molecule><pref_name/><max_phase/><molecule_chembl_id/><molecule_synonyms/></molecule>"
+ "</molecules><mechanisms/><molecule_forms/></response>");
chemblParser.setWebPageDownloader(mockDownloader);
......@@ -1010,7 +1011,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("invalid xml");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("invalid xml");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetsByDrugId(new MiriamData(MiriamType.CHEMBL_COMPOUND, "123"));
fail("Exception expected");
......@@ -1030,7 +1031,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetsByDrugId(new MiriamData(MiriamType.CHEMBL_COMPOUND, "123"));
fail("Exception expected");
......@@ -1050,7 +1051,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getDrugListByTarget(new MiriamData(MiriamType.UNIPROT, "O60391"));
fail("Exception expected");
......@@ -1071,7 +1072,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("invalid xml");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("invalid xml");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getDrugListByTarget(new MiriamData(MiriamType.UNIPROT, "O60391"));
fail("Exception expected");
......@@ -1119,7 +1120,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("invalid xml");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("invalid xml");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getDrugById(new MiriamData(MiriamType.CHEMBL_COMPOUND, ""));
fail("Exception expected");
......@@ -1139,7 +1140,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getDrugById(new MiriamData(MiriamType.CHEMBL_COMPOUND, ""));
fail("Exception expected");
......@@ -1173,7 +1174,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetsForChildElements(new MiriamData());
fail("Exception expected");
......@@ -1193,7 +1194,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("invalid xml");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("invalid xml");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetsForChildElements(new MiriamData());
fail("Exception expected");
......@@ -1213,7 +1214,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
try {
chemblParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString()))
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenReturn("<response><molecule_forms><node/></molecule_forms></response>");
chemblParser.setWebPageDownloader(mockDownloader);
chemblParser.getTargetsForChildElements(new MiriamData());
......
......@@ -5,6 +5,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
......@@ -76,7 +77,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
// skip first call to cache, so we will have to at least parse the data
chemicalParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemicalParser.setWebPageDownloader(mockDownloader);
// Parkinson disease
chemicalParser.getChemicalsForDisease(parkinsonDiseaseId);
......@@ -414,7 +415,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
// simulate problem with downloading
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("");
chemicalParser.setWebPageDownloader(mockDownloader);
chemicalParser.refreshCacheQuery(query);
fail("Exception expected");
......@@ -443,7 +444,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = chemicalParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemicalParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.DOWN, chemicalParser.getServiceStatus().getStatus());
} catch (Exception e) {
......@@ -459,7 +460,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = chemicalParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("");
chemicalParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.CHANGED, chemicalParser.getServiceStatus().getStatus());
} catch (Exception e) {
......@@ -540,7 +541,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
chemicalParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
chemicalParser.setWebPageDownloader(mockDownloader);
try {
chemicalParser.getChemicals(parkinsonDiseaseId, idsList);
......
......@@ -6,6 +6,7 @@ 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.nullable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
......@@ -547,7 +548,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = drugBankHTMLParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
drugBankHTMLParser.setWebPageDownloader(mockDownloader);
drugBankHTMLParser.refreshCacheQuery("http://google.pl/");
fail("Exception expected");
......@@ -566,7 +567,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions {
GeneralCacheInterface cache = drugBankHTMLParser.getCache();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
drugBankHTMLParser.setWebPageDownloader(mockDownloader);
drugBankHTMLParser.setCache(null);
......@@ -659,7 +660,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = drugBankHTMLParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
drugBankHTMLParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.DOWN, drugBankHTMLParser.getServiceStatus().getStatus());
} catch (Exception e) {
......@@ -675,7 +676,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = drugBankHTMLParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenReturn("");
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn("");
drugBankHTMLParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.CHANGED, drugBankHTMLParser.getServiceStatus().getStatus());
} catch (Exception e) {
......
......@@ -6,6 +6,7 @@ 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.nullable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
......@@ -172,7 +173,7 @@ public class MeSHParserTest extends AnnotationTestFunctions {
MiriamData meshID = new MiriamData(MiriamType.MESH_2012, "D004298");
MeSHParser parserUnderTest = new MeSHParser();
WebPageDownloader webPageDownloader = Mockito.mock(WebPageDownloader.class);
when(webPageDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(webPageDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
parserUnderTest.setWebPageDownloader(webPageDownloader);
parserUnderTest.getMeSH(meshID);
......@@ -280,7 +281,7 @@ public class MeSHParserTest extends AnnotationTestFunctions {
try {
meshParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
meshParser.setWebPageDownloader(mockDownloader);
MiriamData meshID = new MiriamData(MiriamType.MESH_2012, "D010300");
......@@ -303,7 +304,7 @@ public class MeSHParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = meshParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
meshParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.DOWN, meshParser.getServiceStatus().getStatus());
} catch (Exception e) {
......@@ -319,7 +320,7 @@ public class MeSHParserTest extends AnnotationTestFunctions {
WebPageDownloader downloader = meshParser.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString()))
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenThrow(new WrongResponseCodeIOException(null, HttpStatus.SC_NOT_FOUND));
meshParser.setWebPageDownloader(mockDownloader);
assertEquals(ExternalServiceStatusType.CHANGED, meshParser.getServiceStatus().getStatus());
......
......@@ -49,7 +49,7 @@ public class MiRNAParserTest extends AnnotationTestFunctions {
@Test
public void testExternalDBStatus() throws Exception {
ExternalServiceStatus status = miRNAParser.getServiceStatus();
assertTrue(status.getStatus().equals(ExternalServiceStatusType.OK));
assertEquals(status.getStatus(), ExternalServiceStatusType.OK);
}
@Test
......@@ -156,7 +156,7 @@ public class MiRNAParserTest extends AnnotationTestFunctions {
}
@Test(timeout = 50000)
public void testCachableInterfaceInvalidateChemical() throws Exception {
public void testCachableInterfaceInvalidateMiRNA() throws Exception {
try {
List<String> listIds = new ArrayList<>();
listIds.add("gga-miR-489-3p");
......
......@@ -6,6 +6,7 @@ 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.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
......@@ -230,7 +231,7 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
try {
miriamConnector.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
miriamConnector.setWebPageDownloader(mockDownloader);
miriamConnector.getUrlString2(TaxonomyBackend.HUMAN_TAXONOMY);
......@@ -251,7 +252,7 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
WebPageDownloader downloader = miriamConnector.getWebPageDownloader();
try {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).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");
......
......@@ -6,6 +6,7 @@ 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.nullable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
......@@ -232,7 +233,7 @@ public class PubmedParserTest extends AnnotationTestFunctions {
try {
pubmedParser.setCache(null);
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), anyString())).thenThrow(new IOException());
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException());
pubmedParser.setWebPageDownloader(mockDownloader);
String query = PubmedParser.PUBMED_PREFIX + PubmedParser.SERVICE_STATUS_PUBMED_ID;
...