Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
30c274cb
Commit
30c274cb
authored
Nov 15, 2017
by
Piotr Gawron
Browse files
fixes on unit tests
parent
e5aaec92
Pipeline
#2597
passed with stage
in 40 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java
View file @
30c274cb
...
...
@@ -86,7 +86,7 @@ public final class ApplicationLevelCache extends XmlParser implements QueryCache
@Override
public
synchronized
void
setCachedQuery
(
String
query
,
CacheType
type
,
Object
object
)
{
setCachedQuery
(
query
,
type
,
object
,
type
.
getValidity
()
);
setCachedQuery
(
query
,
type
,
object
,
0
);
}
@Override
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/ChemicalParserTest.java
View file @
30c274cb
...
...
@@ -574,6 +574,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
public
void
testGetEmptySuggestedQueryList
()
throws
Exception
{
try
{
Project
project
=
new
Project
();
project
.
setId
(-
1
);
List
<
String
>
result
=
chemicalParser
.
getSuggestedQueryList
(
project
,
parkinsonDiseaseId
);
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java
View file @
30c274cb
...
...
@@ -219,16 +219,16 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
}
}
@Test
public
void
testGetUrl2WithInvalidApiResponse
()
throws
Exception
{
WebPageDownloader
downloader
=
miriamConnector
.
getWebPageDownloader
();
GeneralCacheInterface
cache
=
miriamConnector
.
getCache
();
try
{
// exclude first cached value
miriamConnector
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
anyString
())).
thenThrow
(
new
IOException
());
miriamConnector
.
setWebPageDownloader
(
mockDownloader
);
@Test
public
void
testGetUrl2WithInvalidApiResponse
()
throws
Exception
{
WebPageDownloader
downloader
=
miriamConnector
.
getWebPageDownloader
();
GeneralCacheInterface
cache
=
miriamConnector
.
getCache
();
try
{
// exclude first cached value
miriamConnector
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
anyString
())).
thenThrow
(
new
IOException
());
miriamConnector
.
setWebPageDownloader
(
mockDownloader
);
miriamConnector
.
getUrlString2
(
TaxonomyBackend
.
HUMAN_TAXONOMY
);
...
...
@@ -243,49 +243,24 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
}
}
@Test
public
void
testGetUrl2WithInvalidApiResponse2
()
throws
Exception
{
WebPageDownloader
downloader
=
miriamConnector
.
getWebPageDownloader
();
GeneralCacheInterface
cache
=
miriamConnector
.
getCache
();
try
{
// exclude first cached value
miriamConnector
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
anyString
())).
thenReturn
(
""
);
miriamConnector
.
setWebPageDownloader
(
mockDownloader
);
miriamConnector
.
getUrlString2
(
TaxonomyBackend
.
HUMAN_TAXONOMY
);
}
catch
(
AnnotationException
e
)
{
assertTrue
(
e
.
getMessage
().
contains
(
"Problem with parsing miriam REST API response"
));
@Test
public
void
testRefreshCacheQueryNotAvailable
()
throws
Exception
{
WebPageDownloader
downloader
=
miriamConnector
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
anyString
())).
thenThrow
(
new
IOException
());
miriamConnector
.
setWebPageDownloader
(
mockDownloader
);
miriamConnector
.
refreshCacheQuery
(
"http://google.pl/"
);
fail
(
"Exception expected"
);
}
catch
(
SourceNotAvailable
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
miriamConnector
.
setWebPageDownloader
(
downloader
);
miriamConnector
.
setCache
(
cache
);
}
}
@Test
public
void
testRefreshCacheQueryNotAvailable
()
throws
Exception
{
WebPageDownloader
downloader
=
miriamConnector
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
anyString
())).
thenThrow
(
new
IOException
());
miriamConnector
.
setWebPageDownloader
(
mockDownloader
);
miriamConnector
.
refreshCacheQuery
(
"http://google.pl/"
);
fail
(
"Exception expected"
);
}
catch
(
SourceNotAvailable
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
miriamConnector
.
setWebPageDownloader
(
downloader
);
}
}
@Test
public
void
testRefreshInvalidCacheQuery
()
throws
Exception
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment