Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
213fe61b
Commit
213fe61b
authored
Feb 25, 2020
by
Piotr Gawron
Browse files
when there is problem with deserialization carry on without throwing error
parent
2fcf69ec
Pipeline
#21474
passed with stage
in 14 minutes and 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
213fe61b
...
...
@@ -23,8 +23,9 @@ minerva (14.0.9) stable; urgency=medium
*
Bug
fix
:
reaction
without
product
in
SBGN
crashed
upload
of
map
*
Bug
fix
:
when
SBGN
production
pointed
directly
to
process
instead
of
process
port
upload
crashed
*
Bug
fix
:
handle
properly
corrupted
cached
chembl
drug
data
(#
1140
)
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Mon
,
3
Feb
2020
15
:
00
:
00
+
0200
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Tue
,
25
Feb
2020
15
:
00
:
00
+
0200
minerva
(
14.0.8
)
stable
;
urgency
=
medium
*
Bug
fix
:
API
didn
't allow to upload pluins with local url (#1084,
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java
View file @
213fe61b
...
...
@@ -4,6 +4,7 @@ import java.io.IOException;
import
java.net.URLEncoder
;
import
java.util.*
;
import
org.apache.commons.lang3.SerializationException
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -319,9 +320,13 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService {
String
query
=
NAME_PREFIX
+
name
.
toLowerCase
().
trim
();
Drug
drug
=
getDrugSerializer
().
xmlToObject
(
getCacheNode
(
query
));
if
(
drug
!=
null
)
{
return
drug
;
try
{
Drug
drug
=
getDrugSerializer
().
xmlToObject
(
getCacheNode
(
query
));
if
(
drug
!=
null
)
{
return
drug
;
}
}
catch
(
SerializationException
e
)
{
logger
.
error
(
e
,
e
);
}
try
{
...
...
@@ -331,13 +336,13 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService {
Document
document
=
XmlParser
.
getXmlDocumentFromString
(
page
);
List
<
Drug
>
drugs
=
extractDrugsFromDocument
(
document
);
if
(
drugs
.
size
()==
0
)
{
if
(
drugs
.
size
()
==
0
)
{
accessUrl
=
DRUG_SYNONYM_API_URL
+
name
;
page
=
getWebPageContent
(
accessUrl
);
document
=
XmlParser
.
getXmlDocumentFromString
(
page
);
drugs
=
extractDrugsFromDocument
(
document
);
}
if
(
drugs
.
size
()
>
1
)
{
if
(
drugs
.
size
()
>
1
)
{
logger
.
warn
(
"More drugs than one found for query: "
+
query
);
}
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java
View file @
213fe61b
...
...
@@ -7,10 +7,13 @@ import static org.mockito.Mockito.when;
import
java.io.IOException
;
import
java.util.*
;
import
org.apache.commons.lang3.SerializationException
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.stubbing.Answer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.w3c.dom.Node
;
...
...
@@ -889,4 +892,22 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
}
}
@Test
public
void
testFindDrugWhenSerializerFails
()
throws
Exception
{
ChEMBLParser
parser
=
Mockito
.
spy
(
chemblParser
);
when
(
parser
.
getDrugSerializer
()).
then
(
new
Answer
<
XmlSerializer
<
Drug
>>()
{
@Override
public
XmlSerializer
<
Drug
>
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
@SuppressWarnings
(
"unchecked"
)
XmlSerializer
<
Drug
>
serializer
=
Mockito
.
mock
(
XmlSerializer
.
class
);
when
(
serializer
.
xmlToObject
(
any
())).
thenThrow
(
new
SerializationException
());
return
serializer
;
}
});
assertNotNull
(
parser
.
findDrug
(
"CABOZANTINIB"
));
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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