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
67b94844
Commit
67b94844
authored
Apr 01, 2019
by
Piotr Gawron
Browse files
invalid pubmed id could break clicking on elements or listing publications
parent
4c18ff64
Pipeline
#9564
passed with stage
in 8 minutes and 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
67b94844
...
...
@@ -4,6 +4,8 @@ minerva (12.2.1) stable; urgency=medium
*
Bug
fix
:
removing
active
plugin
didn
't switch plugin tab to the next loaded
plugin (#757)
* Bug fix: closed submap will not be reopened after page refresh (#763)
* Bug fix: invalid pubmed identifier could break clicking on element
containing it (#764, #765, #769)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 1 Apr 2019 17:00:00 +0200
...
...
rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java
View file @
67b94844
...
...
@@ -19,6 +19,7 @@ import javax.xml.transform.TransformerFactoryConfigurationError;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.ClassPathResource
;
...
...
@@ -116,11 +117,15 @@ public abstract class BaseRestImpl {
}
}
if
(
MiriamType
.
PUBMED
.
equals
(
annotation
.
getDataType
()))
{
try
{
Article
article
=
pubmedParser
.
getPubmedArticleById
(
annotation
.
getResource
());
result
.
put
(
"article"
,
article
);
}
catch
(
PubmedSearchException
e
)
{
logger
.
error
(
"Problem with accessing info about pubmed"
,
e
);
if
(
NumberUtils
.
isDigits
(
annotation
.
getResource
()))
{
try
{
Article
article
=
pubmedParser
.
getPubmedArticleById
(
annotation
.
getResource
());
result
.
put
(
"article"
,
article
);
}
catch
(
PubmedSearchException
e
)
{
logger
.
error
(
"Problem with accessing info about pubmed"
,
e
);
}
}
else
{
logger
.
error
(
"Invalid pubmed identifier: "
+
annotation
.
getResource
());
}
}
result
.
put
(
"type"
,
annotation
.
getDataType
().
name
());
...
...
rest-api/src/test/java/lcsb/mapviewer/api/BaseRestImplTest.java
View file @
67b94844
...
...
@@ -20,10 +20,10 @@ import lcsb.mapviewer.model.map.MiriamType;
public
class
BaseRestImplTest
extends
RestTestFunctions
{
Logger
logger
=
Logger
.
getLogger
(
BaseRestImplTest
.
class
);
@Autowired
MiriamConnector
mc
;
@Autowired
PubmedParser
pubmedParser
;
...
...
@@ -44,7 +44,7 @@ public class BaseRestImplTest extends RestTestFunctions {
String
presentationXml2
=
controller
.
mathMLToPresentationML
(
content
);
assertEquals
(
presentationXml
,
presentationXml2
);
}
@Test
public
void
testMathMLToPresentationMLCalledTwiceShouldntHaveXmlNode
()
throws
Exception
{
BaseRestImpl
controller
=
Mockito
.
mock
(
BaseRestImpl
.
class
,
CALLS_REAL_METHODS
);
...
...
@@ -52,16 +52,31 @@ public class BaseRestImplTest extends RestTestFunctions {
String
presentationXml
=
controller
.
mathMLToPresentationML
(
content
);
assertFalse
(
presentationXml
.
startsWith
(
"<?xml"
));
}
@Test
public
void
testCreateAnnotationWithWhitespace
()
throws
Exception
{
BaseRestImpl
controller
=
Mockito
.
mock
(
BaseRestImpl
.
class
,
CALLS_REAL_METHODS
);
controller
.
setMiriamConnector
(
mc
);
controller
.
setPubmedParser
(
pubmedParser
);
Map
<
String
,
Object
>
response
=
controller
.
createAnnotation
(
new
MiriamData
(
MiriamType
.
PUBMED
,
"28255955 "
));
Map
<
String
,
Object
>
response
=
controller
.
createAnnotation
(
new
MiriamData
(
MiriamType
.
PUBMED
,
"28255955 "
));
assertNotNull
(
response
);
}
@Test
public
void
testCreateAnnotationWithNonNumericValues
()
throws
Exception
{
BaseRestImpl
controller
=
Mockito
.
mock
(
BaseRestImpl
.
class
,
CALLS_REAL_METHODS
);
controller
.
setMiriamConnector
(
mc
);
controller
.
setPubmedParser
(
pubmedParser
);
Map
<
String
,
Object
>
response
=
controller
.
createAnnotation
(
new
MiriamData
(
MiriamType
.
PUBMED
,
"28255955PG"
));
assertNotNull
(
response
);
}
@Test
public
void
testCreateAnnotationWithEmptyValue
()
throws
Exception
{
BaseRestImpl
controller
=
Mockito
.
mock
(
BaseRestImpl
.
class
,
CALLS_REAL_METHODS
);
controller
.
setMiriamConnector
(
mc
);
controller
.
setPubmedParser
(
pubmedParser
);
Map
<
String
,
Object
>
response
=
controller
.
createAnnotation
(
new
MiriamData
(
MiriamType
.
PUBMED
,
""
));
assertNotNull
(
response
);
}
}
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