Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
12c3451e
Commit
12c3451e
authored
Aug 28, 2019
by
Piotr Gawron
Browse files
when processing file throw proper exception if type in is invalid
parent
a1e42577
Changes
3
Hide whitespace changes
Inline
Side-by-side
service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java
View file @
12c3451e
...
...
@@ -104,7 +104,14 @@ public class ColorSchemaReader {
return
readGenericColorSchema
(
colorInputStream
);
}
}
else
{
ColorSchemaType
type
=
ColorSchemaType
.
valueOf
(
params
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
));
ColorSchemaType
type
=
null
;
try
{
type
=
ColorSchemaType
.
valueOf
(
params
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
));
}
catch
(
IllegalArgumentException
e
)
{
String
options
=
StringUtils
.
join
(
ColorSchemaType
.
values
(),
", "
);
throw
new
InvalidColorSchemaException
(
"Invalid overlay type: "
+
params
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
)
+
". Allowed options: "
+
options
);
}
if
(
type
==
null
)
{
logger
.
warn
(
"Unknown type of layout file: "
+
params
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
));
return
readGenericColorSchema
(
colorInputStream
);
...
...
service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java
View file @
12c3451e
...
...
@@ -480,5 +480,14 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
}
}
@Test
(
expected
=
InvalidColorSchemaException
.
class
)
public
void
testReadColorSchemaWithInvalidType
()
throws
Exception
{
FileInputStream
fis
=
new
FileInputStream
(
"testFiles/coloring/invalidType.txt"
);
FileInputStream
fis2
=
new
FileInputStream
(
"testFiles/coloring/invalidType.txt"
);
ColorSchemaReader
reader
=
new
ColorSchemaReader
();
reader
.
readColorSchema
(
fis
,
TextFileUtils
.
getHeaderParametersFromFile
(
fis2
));
}
}
service/testFiles/coloring/invalidType.txt
0 → 100644
View file @
12c3451e
#TYPE=gen
value identifier Chebi
-0,943978048 HGNC:11138
-0,941309505 CHEBI:15377
1 CHEBI:15376
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