From: gmungoc Date: Wed, 15 Jun 2016 10:25:07 +0000 (+0100) Subject: JAL-2025 unit tests added X-Git-Tag: Release_2_10_0~177^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3e4960cd512411a430115676d4381aaee68e81dc;p=jalview.git JAL-2025 unit tests added --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 426f092..9464f66 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -338,7 +338,7 @@ public class StructureChooser extends GStructureChooser implements * @param seqName * @return */ - private static String sanitizeSeqName(String seqName) + static String sanitizeSeqName(String seqName) { Objects.requireNonNull(seqName); return seqName.replaceAll("\\[\\d*\\]", "") diff --git a/test/jalview/gui/StructureChooserTest.java b/test/jalview/gui/StructureChooserTest.java index c2209d6..ae6bf38 100644 --- a/test/jalview/gui/StructureChooserTest.java +++ b/test/jalview/gui/StructureChooserTest.java @@ -116,4 +116,22 @@ public class StructureChooserTest assertTrue(sc.getDiscoveredStructuresSet().size() > 0); } + + @Test(groups = { "Functional" }) + public void sanitizeSeqNameTest() + { + String name = "ab_cdEF|fwxyz012349"; + assertEquals(name, StructureChooser.sanitizeSeqName(name)); + + // remove a [nn] substring + name = "abcde12[345]fg"; + assertEquals("abcde12fg", StructureChooser.sanitizeSeqName(name)); + + // remove characters other than a-zA-Z0-9 | or _ + name = "ab[cd],.\t£$*!- \\\"@:e"; + assertEquals("abcde", StructureChooser.sanitizeSeqName(name)); + + name = "abcde12[345a]fg"; + assertEquals("abcde12345afg", StructureChooser.sanitizeSeqName(name)); + } }