From c8b35bed08a4bd8688b762bd50f13195c1cfb1c6 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 26 Jan 2017 09:38:31 +0000 Subject: [PATCH] JAL-2344 test fix and code tidy for review comments --- src/jalview/io/FileFormats.java | 4 +++- src/jalview/ws/rest/params/Alignment.java | 4 ++-- test/jalview/io/FileFormatsTest.java | 22 +++++++++++++--------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/jalview/io/FileFormats.java b/src/jalview/io/FileFormats.java index 158489e..19a61cf 100644 --- a/src/jalview/io/FileFormats.java +++ b/src/jalview/io/FileFormats.java @@ -74,7 +74,9 @@ public class FileFormats */ public void registerFileFormat(FileFormatI format) { - registerFileFormat(format, false); + boolean isIdentifiable = format instanceof FileFormat + && ((FileFormat) format).isIdentifiable(); + registerFileFormat(format, isIdentifiable); } protected void registerFileFormat(FileFormatI format, diff --git a/src/jalview/ws/rest/params/Alignment.java b/src/jalview/ws/rest/params/Alignment.java index a8258e2..b85073f 100644 --- a/src/jalview/ws/rest/params/Alignment.java +++ b/src/jalview/ws/rest/params/Alignment.java @@ -108,8 +108,8 @@ public class Alignment extends InputType @Override public List getURLEncodedParameter() { - ArrayList prms = new ArrayList(); - prms.add("format='" + format + "'"); + List prms = new ArrayList(); + prms.add("format='" + format.getName() + "'"); if (type != null) { prms.add("type='" + type.toString() + "'"); diff --git a/test/jalview/io/FileFormatsTest.java b/test/jalview/io/FileFormatsTest.java index 8df228f..ffc844c 100644 --- a/test/jalview/io/FileFormatsTest.java +++ b/test/jalview/io/FileFormatsTest.java @@ -21,17 +21,21 @@ public class FileFormatsTest } @Test(groups = "Functional") - public void testIsDynamic() + public void testIsIdentifiable() { FileFormats formats = FileFormats.getInstance(); - for (FileFormatI ff : FileFormat.values()) - { - assertFalse(formats.isIdentifiable(ff)); - } - assertTrue(formats.isIdentifiable(null)); + assertTrue(formats.isIdentifiable(formats.forName(FileFormat.Fasta + .getName()))); + assertTrue(formats.isIdentifiable(formats.forName(FileFormat.MMCif + .getName()))); + assertTrue(formats.isIdentifiable(formats.forName(FileFormat.Jnet + .getName()))); + assertFalse(formats.isIdentifiable(formats.forName(FileFormat.Jalview + .getName()))); + assertFalse(formats.isIdentifiable(null)); /* - * remove and re-add a format: it is now considered 'dynamically added' + * remove and re-add a format: it is still 'identifiable' */ formats.deregisterFileFormat(FileFormat.Fasta.getName()); assertNull(formats.forName(FileFormat.Fasta.getName())); @@ -104,7 +108,7 @@ public class FileFormatsTest FileFormats formats = FileFormats.getInstance(); assertSame(FileFormat.MMCif, formats.forName(FileFormat.MMCif.getName())); - assertFalse(formats.isIdentifiable(FileFormat.MMCif)); + assertTrue(formats.isIdentifiable(FileFormat.MMCif)); /* * deregister mmCIF format @@ -114,7 +118,7 @@ public class FileFormatsTest /* * re-register mmCIF format - * it is reinstated (but now classed as 'dynamic') + * it is reinstated (still 'identifiable') */ formats.registerFileFormat(FileFormat.MMCif); assertSame(FileFormat.MMCif, -- 1.7.10.2